/* ============================================================
   CatRouting — Auth Pages Stylesheet
   Premium dark B2B SMS platform authentication UI
   ============================================================ */

/* ────────────────────────────────────────────────────────────
   0. Custom Properties
   ──────────────────────────────────────────────────────────── */
:root {
  --bg:            #0C1518;
  --bg-2:          #101D20;
  --surface:       #152928;
  --surface-2:     #1A3230;
  --border:        rgba(168, 218, 220, 0.08);
  --border-light:  rgba(168, 218, 220, 0.14);
  --accent:        #34867F;
  --accent-2:      #A8DADC;
  --brand-primary: #1A4544;
  --glow-teal:     rgba(52, 134, 127, 0.15);
  --text:          #EDEDED;
  --text-2:        #A3B5B4;
  --text-3:        #6E8584;

  --font-display:  'Sora', sans-serif;
  --font-body:     'Inter', system-ui, sans-serif;
  --font-mono:     'JetBrains Mono', monospace;

  --ease:          cubic-bezier(0.16, 1, 0.3, 1);

  --radius-sm:     8px;
  --radius-md:     10px;
  --radius-lg:     16px;

  --danger:        #f87171;
  --danger-bg:     rgba(248, 113, 113, 0.08);
  --success:       #34d399;
  --success-bg:    rgba(52, 211, 153, 0.08);
  --info:          #60a5fa;
  --info-bg:       rgba(96, 165, 250, 0.08);
}

/* ────────────────────────────────────────────────────────────
   1. Reset
   ──────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  outline: none;
  border: none;
  background: none;
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

/* ────────────────────────────────────────────────────────────
   2. Auth Page — Full Viewport Wrapper
   ──────────────────────────────────────────────────────────── */
.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 20px;
  background:
    radial-gradient(ellipse 60% 50% at 50% 40%, rgba(26, 69, 68, 0.18) 0%, transparent 70%),
    var(--bg);
}

/* ────────────────────────────────────────────────────────────
   3. Logo Area
   ──────────────────────────────────────────────────────────── */
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
  text-decoration: none;
}

.auth-logo img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
}

.auth-logo span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.auth-logo__accent {
  color: var(--accent-2);
}

/* ────────────────────────────────────────────────────────────
   4. Auth Card
   ──────────────────────────────────────────────────────────── */
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 0 0 1px var(--border),
    0 4px 24px rgba(0, 0, 0, 0.25),
    0 0 80px -20px var(--glow-teal);
  animation: cardEntrance 0.5s var(--ease) both;
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Card Header */
.auth-card__header {
  padding: 40px 40px 0;
  text-align: center;
}

.auth-card__header h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.auth-card__header p {
  font-size: 0.9375rem;
  color: var(--text-2);
  line-height: 1.5;
}

/* Card Form (direct child) */
.auth-card > form {
  padding: 32px 40px;
}

/* Card Footer */
.auth-card__footer {
  padding: 0 40px 32px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-3);
}

.auth-card__footer a {
  color: var(--accent-2);
  font-weight: 500;
  transition: color 0.2s ease;
}

.auth-card__footer a:hover {
  text-decoration: underline;
}

/* ────────────────────────────────────────────────────────────
   5. Form Groups
   ──────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}

/* Two-column row (e.g. first name / last name) */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row .form-group {
  margin-bottom: 20px;
}

/* ────────────────────────────────────────────────────────────
   6. Form Input
   ──────────────────────────────────────────────────────────── */
.form-input {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.9375rem;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.form-input::placeholder {
  color: var(--text-3);
}

.form-input:hover {
  border-color: var(--border-light);
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glow-teal);
  background: var(--bg);
}

/* Error state */
.form-input--error,
.form-input.input-error,
.form-group.has-error .form-input {
  border-color: var(--danger);
}

.form-input--error:focus,
.form-input.input-error:focus,
.form-group.has-error .form-input:focus {
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.1);
}

/* ────────────────────────────────────────────────────────────
   7. Form Select
   ──────────────────────────────────────────────────────────── */
.form-select {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 40px 0 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.9375rem;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236E8584' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 4 3.5-4H4.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glow-teal);
}

.form-select option {
  background: var(--bg-2);
  color: var(--text);
}

/* ────────────────────────────────────────────────────────────
   8. Form Error
   ──────────────────────────────────────────────────────────── */
.form-error {
  display: block;
  font-size: 0.8125rem;
  color: var(--danger);
  margin-top: 6px;
  line-height: 1.4;
  min-height: 0;
}

.form-error:empty {
  display: none;
}

.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 4px;
}

/* ────────────────────────────────────────────────────────────
   9. Password Input Wrapper
   ──────────────────────────────────────────────────────────── */
.input-wrapper {
  position: relative;
}

.input-wrapper .form-input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: var(--text-3);
  transition: color 0.2s ease, background 0.2s ease;
}

.password-toggle:hover {
  color: var(--text-2);
  background: rgba(168, 218, 220, 0.06);
}

.password-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ────────────────────────────────────────────────────────────
   10. Password Strength Meter
   ──────────────────────────────────────────────────────────── */
.password-strength {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.password-strength__bar {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.3s ease;
}

/* Strength levels */
.password-strength.strength-1 .password-strength__bar:nth-child(1) {
  background: #ef4444;
}

.password-strength.strength-2 .password-strength__bar:nth-child(-n+2) {
  background: #f59e0b;
}

.password-strength.strength-3 .password-strength__bar:nth-child(-n+3) {
  background: #34d399;
}

.password-strength.strength-4 .password-strength__bar {
  background: #22c55e;
}

.password-strength__label {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 4px;
}

/* ────────────────────────────────────────────────────────────
   11. Checkbox Label
   ──────────────────────────────────────────────────────────── */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-2);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background: var(--bg-2);
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.checkbox-label input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-label input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 4px;
  width: 5px;
  height: 8px;
  border: solid var(--text);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-label input[type="checkbox"]:focus-visible {
  box-shadow: 0 0 0 3px var(--glow-teal);
}

.checkbox-label a {
  color: var(--accent-2);
  font-weight: 500;
}

.checkbox-label a:hover {
  text-decoration: underline;
}

/* ────────────────────────────────────────────────────────────
   11c. Form Row Utilities
   ──────────────────────────────────────────────────────────── */
.form-row--between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.form-link {
  font-size: 0.875rem;
  color: var(--accent-2);
  font-weight: 500;
  transition: color 0.2s ease;
}

.form-link:hover {
  text-decoration: underline;
}

/* Checkbox error state */
.checkbox-label input[type="checkbox"].input-error {
  border-color: var(--danger);
}

/* text-muted */
.text-muted {
  color: var(--text-3);
  font-size: 0.8125rem;
}

/* ────────────────────────────────────────────────────────────
   12. Primary Button
   ──────────────────────────────────────────────────────────── */
.form-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  padding: 0 24px;
  background: linear-gradient(135deg, var(--accent), var(--brand-primary));
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9375rem;
  border-radius: var(--radius-md);
  letter-spacing: -0.01em;
  transition:
    filter 0.2s ease,
    transform 0.15s ease,
    box-shadow 0.2s ease;
}

.form-btn:hover {
  filter: brightness(1.1);
  transform: scale(1.01);
  box-shadow: 0 4px 20px var(--glow-teal);
}

.form-btn:active {
  transform: scale(0.985);
  filter: brightness(0.95);
}

.form-btn:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.form-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  filter: none;
  box-shadow: none;
}

.auth-card .form-btn {
  margin-top: 8px;
}

a.form-btn {
  text-decoration: none;
}

/* Loading state */
.form-btn--loading {
  pointer-events: none;
  position: relative;
  color: transparent;
}

.form-btn--loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(237, 237, 237, 0.3);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spinner 0.8s linear infinite;
}

@keyframes spinner {
  to {
    transform: rotate(360deg);
  }
}

/* ────────────────────────────────────────────────────────────
   13. Form Divider ("or")
   ──────────────────────────────────────────────────────────── */
.form-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  color: var(--text-3);
  font-size: 0.8125rem;
}

.form-divider::before,
.form-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ────────────────────────────────────────────────────────────
   14. Alert / Notification Banner
   ──────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 20px;
  border: 1px solid;
}

.alert--success {
  background: var(--success-bg);
  border-color: rgba(52, 211, 153, 0.2);
  color: var(--success);
}

.alert--error {
  background: var(--danger-bg);
  border-color: rgba(248, 113, 113, 0.2);
  color: var(--danger);
}

.alert--info {
  background: var(--info-bg);
  border-color: rgba(96, 165, 250, 0.2);
  color: var(--info);
}

.alert svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

/* ────────────────────────────────────────────────────────────
   15. Auth Success State
   ──────────────────────────────────────────────────────────── */
.auth-success[hidden] {
  display: none;
}

.auth-success {
  text-align: center;
  padding: 48px 40px;
}

.auth-success__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success-bg);
  margin-bottom: 20px;
}

.auth-success__icon svg {
  width: 32px;
  height: 32px;
  stroke: var(--success);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-success__icon svg .checkmark-circle {
  stroke-dasharray: 190;
  stroke-dashoffset: 190;
  animation: drawCircle 0.6s var(--ease) forwards;
}

.auth-success__icon svg .checkmark-check {
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: drawCheck 0.4s 0.4s var(--ease) forwards;
}

@keyframes drawCircle {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes drawCheck {
  to {
    stroke-dashoffset: 0;
  }
}

.auth-success h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  margin-bottom: 8px;
}

.auth-success p {
  font-size: 0.9375rem;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 16px;
}

.auth-success .form-btn {
  margin-bottom: 16px;
}

.auth-success small {
  display: block;
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 8px;
}

/* ────────────────────────────────────────────────────────────
   16. Auth Links (below card — privacy, terms)
   ──────────────────────────────────────────────────────────── */
.auth-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  font-size: 0.8125rem;
  color: var(--text-3);
}

.auth-links a {
  color: var(--text-3);
  transition: color 0.2s ease;
}

.auth-links a:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

.auth-links__sep {
  color: var(--border-light);
  user-select: none;
}

/* ────────────────────────────────────────────────────────────
   17. Utility — Links within text
   ──────────────────────────────────────────────────────────── */
.link {
  color: var(--accent-2);
  font-weight: 500;
  transition: color 0.2s ease;
}

.link:hover {
  text-decoration: underline;
}

/* ────────────────────────────────────────────────────────────
   18. Responsive — Mobile (< 480px)
   ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .auth-page {
    padding: 24px 0 0;
    justify-content: flex-start;
  }

  .auth-logo {
    margin-bottom: 24px;
  }

  .auth-card {
    max-width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow:
      0 4px 24px rgba(0, 0, 0, 0.25),
      0 0 60px -20px var(--glow-teal);
  }

  .auth-card__header {
    padding: 28px 24px 0;
  }

  .auth-card > form {
    padding: 24px;
  }

  .auth-card__footer {
    padding: 0 24px 24px;
  }

  .auth-success {
    padding: 36px 24px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .auth-links {
    margin-top: 20px;
    padding-bottom: 24px;
  }
}

/* ────────────────────────────────────────────────────────────
   18b. Browser Autofill Dark Theme
   ──────────────────────────────────────────────────────────── */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0px 1000px var(--bg-2) inset;
  transition: background-color 5000s ease-in-out 0s;
  border-color: var(--border-light);
}

/* ────────────────────────────────────────────────────────────
   19. Selection
   ──────────────────────────────────────────────────────────── */
::selection {
  background: var(--accent);
  color: var(--text);
}

/* ────────────────────────────────────────────────────────────
   20. Reduced Motion
   ──────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .auth-card {
    animation: none;
  }

  .auth-success__icon svg .checkmark-circle,
  .auth-success__icon svg .checkmark-check {
    animation: none;
    stroke-dashoffset: 0;
  }

  .form-btn--loading::after {
    animation-duration: 1.5s;
  }

  .form-input,
  .form-select,
  .form-btn,
  .password-toggle,
  .checkbox-label input[type="checkbox"],
  .link,
  .auth-links a,
  .auth-card__footer a {
    transition: none;
  }
}
