/* =====================================================================
   auth.css — GSTBill.app sign-in modal
   Mobile OTP dominant (India-first). Navy + Emerald on-brand palette.
   Bottom-sheet on phones, centered card on desktop. 44px tap targets.
   ===================================================================== */

:root {
  --auth-navy: #0B2545;
  --auth-navy-deep: #081A31;
  --auth-navy-tint: #13315C;
  --auth-green: #059669;
  --auth-green-dark: #047857;
  --auth-green-light: #D1FAE5;
  --auth-green-pale: #ECFDF5;
  --auth-ink: #111827;
  --auth-muted: #6B7280;
  --auth-line: #E5E7EB;
  --auth-bg: #FFFFFF;
  --auth-tap: 44px;
  --auth-shadow: 0 20px 50px rgba(11, 37, 69, 0.25);
  --auth-radius: 16px;
}

/* ── Overlay ─────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 26, 49, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 9999;
  padding: 0;
  opacity: 0;
  transition: opacity .18s ease;
}
.auth-overlay.is-open {
  display: flex;
  opacity: 1;
}
@media (min-width: 640px) {
  .auth-overlay { align-items: center; padding: 24px; }
}

/* ── Modal shell ─────────────────────────────────────────────── */
.auth-modal {
  background: var(--auth-bg);
  width: 100%;
  max-width: 440px;
  border-radius: var(--auth-radius) var(--auth-radius) 0 0;
  box-shadow: var(--auth-shadow);
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  max-height: 92vh;
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform .22s ease;
  -webkit-overflow-scrolling: touch;
}
.auth-overlay.is-open .auth-modal { transform: translateY(0); }
@media (min-width: 640px) {
  .auth-modal {
    border-radius: var(--auth-radius);
    padding: 28px 28px 24px;
  }
}

/* Grab handle (mobile only) */
.auth-handle {
  width: 44px;
  height: 4px;
  border-radius: 2px;
  background: #D1D5DB;
  margin: -4px auto 14px;
}
@media (min-width: 640px) { .auth-handle { display: none; } }

/* ── Header ─────────────────────────────────────────────────── */
.auth-header { position: relative; margin-bottom: 14px; }
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.auth-brand svg { width: 28px; height: 28px; }
.auth-brand-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--auth-navy);
  letter-spacing: -0.01em;
}
.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--auth-ink);
  margin: 2px 0 2px;
  letter-spacing: -0.02em;
}
.auth-sub {
  font-size: 14px;
  color: var(--auth-muted);
  margin: 0 0 14px;
  line-height: 1.45;
}
.auth-close {
  position: absolute;
  top: -4px;
  right: -4px;
  width: var(--auth-tap);
  height: var(--auth-tap);
  border: none;
  background: transparent;
  color: var(--auth-muted);
  font-size: 26px;
  cursor: pointer;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: rgba(11,37,69,.08);
}
.auth-close:hover, .auth-close:focus-visible {
  background: #F3F4F6;
  color: var(--auth-ink);
  outline: none;
}

/* ── Tabs ───────────────────────────────────────────────────── */
.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: #F3F4F6;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}
.auth-tab {
  min-height: 40px;
  border: none;
  background: transparent;
  color: var(--auth-muted);
  font-size: 14px;
  font-weight: 600;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s ease, color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.auth-tab:hover { color: var(--auth-ink); }
.auth-tab.is-active {
  background: #FFFFFF;
  color: var(--auth-navy);
  box-shadow: 0 1px 3px rgba(11,37,69,.08);
}
.auth-tab svg { width: 16px; height: 16px; }

/* ── Panels ─────────────────────────────────────────────────── */
.auth-panel { display: none; }
.auth-panel.is-active { display: block; }

/* ── Fields ─────────────────────────────────────────────────── */
.auth-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--auth-ink);
  margin: 0 0 6px;
}
.auth-field {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--auth-line);
  border-radius: 12px;
  padding: 0 12px;
  height: 52px;
  background: #FFFFFF;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-field:focus-within {
  border-color: var(--auth-green);
  box-shadow: 0 0 0 4px rgba(5,150,105,.12);
}
.auth-field .auth-prefix {
  font-size: 15px;
  color: var(--auth-ink);
  font-weight: 600;
  padding-right: 8px;
  border-right: 1px solid var(--auth-line);
}
.auth-field input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px; /* prevents iOS zoom */
  color: var(--auth-ink);
  background: transparent;
  width: 100%;
  min-width: 0;
  font-family: inherit;
  letter-spacing: .01em;
}
.auth-field input::placeholder { color: #9CA3AF; }

.auth-hint {
  font-size: 12px;
  color: var(--auth-muted);
  margin: 6px 2px 0;
  line-height: 1.4;
}
.auth-hint a { color: var(--auth-green-dark); text-decoration: underline; }

/* ── OTP digit inputs (6 boxes) ─────────────────────────────── */
.auth-otp {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 6px 0 4px;
}
.auth-otp input {
  -moz-appearance: textfield;
  appearance: textfield;
  width: 100%;
  height: 54px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--auth-ink);
  border: 1.5px solid var(--auth-line);
  border-radius: 12px;
  background: #FFFFFF;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-otp input::-webkit-outer-spin-button,
.auth-otp input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.auth-otp input:focus {
  border-color: var(--auth-green);
  box-shadow: 0 0 0 4px rgba(5,150,105,.12);
}

/* ── Buttons ────────────────────────────────────────────────── */
.auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  letter-spacing: -0.01em;
}
.auth-btn:active { transform: translateY(1px); }
.auth-btn[disabled] { opacity: .55; cursor: not-allowed; }

.auth-btn-primary {
  background: var(--auth-green);
  color: #FFFFFF;
  box-shadow: 0 6px 14px rgba(5,150,105,.28);
}
.auth-btn-primary:hover:not([disabled]),
.auth-btn-primary:focus-visible:not([disabled]) {
  background: var(--auth-green-dark);
  outline: none;
}

.auth-btn-ghost {
  background: #FFFFFF;
  color: var(--auth-ink);
  border: 1.5px solid var(--auth-line);
}
.auth-btn-ghost:hover, .auth-btn-ghost:focus-visible {
  border-color: #9CA3AF;
  background: #F9FAFB;
  outline: none;
}
.auth-btn-ghost svg { width: 18px; height: 18px; }

/* Spinner */
.auth-btn .auth-spinner {
  width: 16px; height: 16px;
  border: 2.5px solid rgba(255,255,255,.45);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: auth-spin .7s linear infinite;
  display: none;
}
.auth-btn.is-loading .auth-spinner { display: inline-block; }
.auth-btn.is-loading .auth-btn-label { opacity: .85; }
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* ── Divider ────────────────────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--auth-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--auth-line);
}

/* ── Helper rows ────────────────────────────────────────────── */
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.auth-link {
  background: none; border: none; padding: 6px 0;
  font-size: 13px; font-weight: 600; color: var(--auth-green-dark);
  cursor: pointer; text-align: left;
  font-family: inherit;
}
.auth-link:hover, .auth-link:focus-visible { text-decoration: underline; outline: none; }
.auth-link[disabled] { opacity: .55; cursor: not-allowed; text-decoration: none; }

/* ── Alerts ─────────────────────────────────────────────────── */
.auth-alert {
  display: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.auth-alert.is-visible { display: block; }
.auth-alert-error {
  background: #FEF2F2;
  color: #991B1B;
  border-color: #FECACA;
}
.auth-alert-ok {
  background: var(--auth-green-pale);
  color: var(--auth-green-dark);
  border-color: var(--auth-green-light);
}

/* ── Footer (legal) ─────────────────────────────────────────── */
.auth-legal {
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--auth-muted);
  text-align: center;
  line-height: 1.5;
}
.auth-legal a { color: var(--auth-navy-tint); text-decoration: underline; }

/* ── Body scroll-lock when modal open ───────────────────────── */
body.auth-open { overflow: hidden; }

/* ── Motion preferences ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .auth-overlay, .auth-modal, .auth-btn { transition: none !important; }
  @keyframes auth-spin { to { transform: rotate(0deg); } }
}

/* ── Narrow Android phones (360-380px) ──────────────────────── */
@media (max-width: 380px) {
  .auth-modal { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .auth-title { font-size: 20px; }
  .auth-tab { font-size: 13px; }
  .auth-otp { gap: 6px; }
  .auth-otp input { height: 48px; font-size: 19px; }
}
