/**
 * Auth — Login / Sign up (phone + OTP)
 */

html.auth-html,
body.auth-body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

.auth-page {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(208, 225, 251, 0.55), transparent 60%),
    linear-gradient(180deg, var(--surface-container-low) 0%, var(--background) 45%, var(--surface) 100%);
}

/* Form panel */
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-height: 100%;
  padding: var(--container-padding);
  overflow: hidden;
}

.auth-brand-inline {
  margin: 0 0 16px;
  font-size: var(--headline-md-size);
  font-weight: 700;
  line-height: 24px;
  letter-spacing: -0.02em;
  color: var(--primary);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  max-height: 100%;
  background: var(--surface-container-lowest);
  border: var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  overflow: hidden;
  text-align: center;
}

.auth-card-title {
  margin: 0 0 4px;
  font-size: var(--headline-md-size);
  font-weight: 600;
  line-height: 24px;
  color: var(--on-surface);
}

.auth-card-sub {
  margin: 0 0 20px;
  font-size: var(--body-sm-size);
  line-height: 18px;
  color: var(--on-surface-variant);
}

/* Mode tabs */
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--surface-container);
  border-radius: var(--radius);
}

.auth-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--on-surface-variant);
  font-size: var(--label-md-size);
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0.01em;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.auth-tab:hover {
  color: var(--on-surface);
}

.auth-tab.is-active {
  background: var(--surface-container-lowest);
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(26, 27, 32, 0.06);
}

/* Forms */
.auth-form {
  display: none;
}

.auth-form.is-active {
  display: block;
}

.auth-step {
  display: none;
}

.auth-step.is-active {
  display: block;
  animation: auth-fade 0.2s ease;
}

@keyframes auth-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.field {
  margin-bottom: 14px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--label-sm-size);
  font-weight: 600;
  line-height: 14px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  text-align: center;
}

.field-hint {
  margin: 6px 0 0;
  font-size: var(--label-md-size);
  line-height: 16px;
  color: var(--outline);
  text-align: center;
}

.phone-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 8px;
  align-items: center;
}

.phone-prefix {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--row-height-dense);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius);
  background: var(--surface-container);
  color: var(--on-surface);
  font-size: var(--body-sm-size);
  font-weight: 600;
  line-height: 18px;
}

.input,
.select {
  width: 100%;
  height: var(--row-height-dense);
  padding: 0 10px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius);
  background: var(--surface-container-lowest);
  color: var(--on-surface);
  font-size: var(--body-sm-size);
  line-height: 18px;
  outline: none;
  text-align: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.input::placeholder {
  color: var(--outline);
}

.input.is-error,
.select.is-error {
  border-color: var(--error);
}

.input-file {
  width: 100%;
  height: var(--row-height-dense);
  padding: 4px 8px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius);
  background: var(--surface-container-low);
  color: var(--on-surface-variant);
  font-size: var(--body-sm-size);
  line-height: 18px;
}

.input-file::file-selector-button {
  height: 24px;
  margin-right: 8px;
  padding: 0 10px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-sm);
  background: var(--surface-container-lowest);
  color: var(--on-surface);
  font-family: var(--font-sans);
  font-size: var(--label-md-size);
  font-weight: 500;
  cursor: pointer;
}

/* OTP */
.otp-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.otp-digit {
  width: 100%;
  height: 40px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0;
  padding: 0;
}

.otp-sent-to {
  margin: 0 0 16px;
  font-size: var(--body-sm-size);
  color: var(--on-surface-variant);
}

.otp-sent-to strong {
  color: var(--on-surface);
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--row-height-standard);
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: var(--body-sm-size);
  font-weight: 600;
  line-height: 18px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-container);
}

.btn-ghost {
  background: transparent;
  border-color: var(--outline-variant);
  color: var(--on-surface);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-container-low);
}

.btn-link {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  color: var(--primary);
  font-size: var(--body-sm-size);
  font-weight: 500;
  cursor: pointer;
}

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

.btn-link:disabled {
  color: var(--outline);
  cursor: not-allowed;
  text-decoration: none;
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.auth-secondary-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
  font-family: var(--font-mono);
  font-size: var(--label-sm-size);
  font-weight: 500;
  line-height: 14px;
}

/* Alerts */
.auth-alert {
  display: none;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border-left: 3px solid var(--primary);
  background: var(--primary-fixed);
  color: var(--on-primary-fixed);
  font-size: var(--body-sm-size);
  line-height: 18px;
}

.auth-alert.is-visible {
  display: block;
}

.auth-alert.is-error {
  border-left-color: var(--error);
  background: var(--error-container);
  color: var(--on-error-container);
}

.auth-alert.is-success {
  border-left-color: var(--success);
  background: #d1fae5;
  color: #065f46;
}

.auth-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--outline-variant);
  font-size: var(--label-md-size);
  line-height: 16px;
  color: var(--outline);
  text-align: center;
}

.resend-timer {
  font-family: var(--font-mono);
  font-size: var(--label-sm-size);
  color: var(--outline);
}

@media (max-width: 1024px) {
  .auth-panel {
    padding: 12px;
  }

  .auth-card {
    padding: 18px 16px 14px;
  }

  .auth-brand-inline {
    margin-bottom: 10px;
    font-size: 16px;
    line-height: 22px;
  }

  .auth-card-title {
    font-size: 16px;
    line-height: 22px;
  }

  .auth-card-sub {
    margin-bottom: 12px;
  }

  .auth-tabs {
    margin-bottom: 12px;
  }

  .auth-tab {
    padding: 6px 10px;
  }

  .field {
    margin-bottom: 10px;
  }

  .field-hint {
    display: none;
  }

  .auth-alert {
    margin-bottom: 10px;
    padding: 8px 10px;
  }

  .auth-actions {
    gap: 8px;
    margin-top: 4px;
  }

  .btn {
    height: 36px;
  }

  .btn .kbd {
    display: none;
  }

  .auth-footer {
    margin-top: 12px;
    padding-top: 10px;
  }

  .otp-sent-to {
    margin-bottom: 10px;
  }

  .otp-digit {
    height: 36px;
  }
}

@media (max-width: 480px), (max-height: 700px) {
  .auth-panel {
    padding: 8px;
  }

  .auth-card {
    padding: 14px 14px 12px;
    border-radius: var(--radius-md);
  }

  .auth-brand-inline {
    margin-bottom: 8px;
  }

  .auth-card-sub {
    margin-bottom: 10px;
    font-size: 12px;
    line-height: 16px;
  }

  .auth-tabs {
    margin-bottom: 10px;
  }

  .field {
    margin-bottom: 8px;
  }

  .auth-footer {
    margin-top: 10px;
    padding-top: 8px;
    font-size: 11px;
  }
}

@media (max-width: 420px) {
  .otp-row {
    gap: 6px;
  }

  .otp-digit {
    height: 34px;
    font-size: 14px;
  }

  .phone-row {
    grid-template-columns: 52px 1fr;
  }
}
