/* ==========================================================
   UniLibrary Rooms — Auth CSS
   Login + Register + Forgot-Password
   ========================================================== */

/* ── Design Tokens ── */
:root {
  --primary:         #2563EB;
  --primary-hover:   #1D4ED8;
  --primary-100:     #DBEAFE;
  --primary-50:      #EFF6FF;
  --navy-950:        #0B2239;
  --navy-900:        #102A43;
  --navy-800:        #173B5C;
  --text-primary:    #172033;
  --text-secondary:  #475569;
  --text-muted:      #94A3B8;
  --surface:         #FFFFFF;
  --border:          #E2E8F0;
  --success-600:     #15803D;
  --success-100:     #DCFCE7;
  --danger-600:      #DC2626;
  --danger-100:      #FEE2E2;
  --radius-sm:       6px;
  --radius-md:       10px;
  --radius-lg:       14px;
  --shadow-card:     0 2px 8px rgba(15, 23, 42, 0.07);
  --shadow-md:       0 4px 16px rgba(15, 23, 42, 0.09);
  --shadow-lift:     0 20px 60px rgba(0, 0, 0, 0.28);
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(ellipse 72% 62% at 50% 44%, rgba(37, 92, 148, 0.14) 0%, transparent 68%),
    linear-gradient(145deg, #061523 0%, #0A2237 48%, #0D2C42 100%);
  min-height: 100vh;
  position: relative;
  isolation: isolate;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: clamp(420px, 54vw, 760px);
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(88px);
  opacity: 0.34;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}

body::before {
  top: -32%;
  left: -18%;
  background: radial-gradient(circle, rgba(44, 101, 158, 0.72) 0%, rgba(30, 78, 128, 0.26) 48%, transparent 72%);
  animation: auth-blue-drift 28s ease-in-out infinite alternate;
}

body::after {
  right: -20%;
  bottom: -38%;
  background: radial-gradient(circle, rgba(24, 111, 112, 0.62) 0%, rgba(18, 82, 94, 0.24) 50%, transparent 73%);
  animation: auth-teal-drift 34s ease-in-out infinite alternate;
}

.auth-cursor-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: clamp(420px, 46vw, 680px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(54, 112, 169, 0.24) 0%,
    rgba(31, 105, 126, 0.12) 38%,
    transparent 70%
  );
  filter: blur(24px);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transform: translate3d(-50%, -50%, 0);
  transition: opacity 600ms ease;
  will-change: transform, opacity;
}

.auth-cursor-glow.is-visible { opacity: 0.7; }

.auth-page,
.register-page {
  position: relative;
  z-index: 1;
  isolation: isolate;
  overflow-x: clip;
}

.auth-page::before,
.register-page::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: clamp(440px, 62vw, 780px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(52, 112, 173, 0.18) 0%, rgba(34, 86, 139, 0.08) 40%, transparent 70%);
  filter: blur(18px);
  opacity: 0.78;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 0;
  animation: auth-card-glow 16s ease-in-out infinite alternate;
}

.auth-left,
.register-container {
  position: relative;
  z-index: 1;
}

@keyframes auth-blue-drift {
  0% { transform: translate3d(-3%, -2%, 0) scale(1); }
  50% { transform: translate3d(7%, 5%, 0) scale(1.06); }
  100% { transform: translate3d(2%, 10%, 0) scale(0.98); }
}

@keyframes auth-teal-drift {
  0% { transform: translate3d(2%, 3%, 0) scale(1); }
  50% { transform: translate3d(-7%, -4%, 0) scale(1.05); }
  100% { transform: translate3d(-2%, -9%, 0) scale(0.99); }
}

@keyframes auth-card-glow {
  0% { opacity: 0.68; transform: translate(-50%, -50%) scale(0.98); }
  100% { opacity: 0.86; transform: translate(-50%, -50%) scale(1.04); }
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { cursor: pointer; font-family: inherit; }
input, select, textarea, button { font-family: inherit; }

/* ================================================================
   LOGIN PAGE
   ================================================================ */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px 20px;
}

/* Hide the decorative right panel */
.auth-right { display: none !important; }

/* Left panel becomes the only visible column */
.auth-left {
  width: 100%;
  max-width: 420px;
}

/* ── Auth Card ── */
.auth-box {
  background: var(--surface);
  border-radius: 18px;
  padding: 40px 40px 36px;
  box-shadow: var(--shadow-lift);
  position: relative;
}

/* ── Brand Row ── */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.brand h1 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* ── Card Titles ── */
.auth-box h2 {
  font-size: 21px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 28px;
}

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

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group input[type="tel"],
.form-group select {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #F8FAFC;
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

/* ── Remember + Forgot Row ── */
.form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  gap: 12px;
}

.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.remember input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

.text-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
}

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

/* ── Primary Button ── */
.primary-btn {
  display: block;
  width: 100%;
  height: 46px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 150ms ease, transform 100ms ease, box-shadow 150ms ease;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.primary-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

/* ── Verify check button ── */
.verify-check-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  transition: border-color 150ms, background 150ms, color 150ms;
}

.verify-check-btn:hover {
  border-color: var(--primary);
  background: var(--primary-50);
  color: var(--primary);
}

/* ── Status Messages ── */
.message {
  min-height: 18px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

/* ── Auth Footer (Sign up link) ── */
.auth-footer {
  border-top: 1px solid var(--border);
  margin-top: 26px;
  padding-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--primary);
  font-weight: 600;
  margin-left: 4px;
}

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

/* Email verification callback */
.verification-box { text-align: center; }
.verification-box .brand { justify-content: center; }

.verification-state-icon {
  width: 48px;
  height: 48px;
  margin: 2px auto 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
}

.verification-state-icon.is-loading {
  border: 3px solid var(--primary-100);
  border-top-color: var(--primary);
  animation: verification-spin 900ms linear infinite;
}

.verification-state-icon.is-success { background: var(--success-100); color: var(--success-600); }
.verification-state-icon.is-success::before { content: "\2713"; }
.verification-state-icon.is-error { background: var(--danger-100); color: var(--danger-600); }
.verification-state-icon.is-error::before { content: "!"; }
.verification-message { margin-bottom: 24px; }

.verification-login-link {
  display: grid;
  place-items: center;
  text-decoration: none;
}

.verification-login-link[hidden] { display: none; }
.verification-login-link:hover { text-decoration: none; }

@keyframes verification-spin { to { transform: rotate(360deg); } }

/* ── Sub-note below login card ── */
.secure-note {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.42);
  letter-spacing: 0.02em;
}

/* ================================================================
   REGISTER PAGE
   ================================================================ */

.register-page {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 20px 56px;
}

.register-container {
  width: 100%;
  max-width: 520px;
}

/* ── Register page heading above the card ── */
.register-header {
  text-align: center;
  margin-bottom: 24px;
}

.register-icon {
  width: 42px;
  height: 42px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  margin: 0 auto 14px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.register-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.register-header p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
}

/* ── Register card (the form) ── */
.register-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 36px 36px 32px;
  box-shadow: var(--shadow-lift);
}

.register-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: 20px;
}

/* ── 2-column form grid ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Register card inherits the same .form-group styles */
.register-card .form-group label { color: #374151; }
.register-card .form-group input,
.register-card .form-group select { background: #F8FAFC; }

/* Info / helper box on registration page */
.info-box {
  margin-top: 16px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  line-height: 1.6;
}

/* ── Register button — same as .primary-btn ── */
.register-card .primary-btn { margin-top: 4px; }

/* ── Register message ── */
#registerMessage {
  min-height: 18px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

/* ================================================================
   FORGOT PASSWORD MODAL
   ================================================================ */

.fp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 15, 30, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.fp-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 36px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
}

.fp-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.fp-modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.fp-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 150ms, background 150ms;
}

.fp-close:hover {
  color: var(--text-primary);
  background: #F4F7FB;
}

.fp-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin: 0 0 22px;
}

.fp-input {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #F8FAFC;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 14px;
  transition: border-color 150ms, box-shadow 150ms;
}

.fp-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.fp-msg {
  min-height: 16px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 16px;
  text-align: center;
}

.fp-submit-btn {
  display: block;
  width: 100%;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 150ms, box-shadow 150ms;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.fp-submit-btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.38);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 600px) {
  .auth-box {
    padding: 28px 22px 24px;
    border-radius: 14px;
  }

  .register-card {
    padding: 24px 20px 20px;
    border-radius: 14px;
  }

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

  .register-page {
    padding: 28px 16px 40px;
  }

  .auth-page {
    padding: 28px 16px;
  }

  .fp-modal {
    padding: 24px 22px 20px;
  }
}

@media (hover: none), (pointer: coarse) {
  .auth-cursor-glow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-cursor-glow { display: none; }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ================================================================
   RESPONSIVE COMPATIBILITY PASS
   Breakpoints: 1024px / 768px / 480px
   ================================================================ */

html,
body,
.auth-page,
.register-page {
  max-width: 100%;
}

html { overflow-x: clip; }
body { min-height: 100dvh; overflow-x: hidden; }

img {
  max-width: 100%;
  height: auto;
}

@media (max-width: 1024px) {
  .auth-page {
    padding-right: 24px;
    padding-left: 24px;
  }

  .register-page {
    padding-right: 24px;
    padding-left: 24px;
  }
}

@media (max-width: 768px) {
  .auth-page,
  .register-page {
    min-height: 100dvh;
    padding-top: calc(28px + env(safe-area-inset-top));
    padding-right: 16px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
    padding-left: 16px;
  }

  .auth-left,
  .register-container {
    min-width: 0;
    max-width: 520px;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  select,
  textarea {
    min-height: 44px;
    font-size: 16px !important;
  }

  button,
  [role="button"],
  .primary-btn,
  .verification-login-link,
  .text-link {
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
  }

  label:has(> input[type="checkbox"]),
  label:has(> input[type="radio"]) {
    min-height: 44px;
    align-items: center;
  }

  .fp-overlay {
    align-items: stretch;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
    overflow: hidden;
  }

  .fp-modal {
    width: 100%;
    max-width: 100%;
    max-height: 100dvh;
    margin: auto 0 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .fp-close {
    width: 44px;
    height: 44px;
    padding: 0;
  }
}

@media (max-width: 480px) {
  .auth-page,
  .register-page {
    padding-right: 12px;
    padding-left: 12px;
  }

  .auth-box,
  .register-card {
    padding: 24px 18px 22px;
    border-radius: 12px;
  }

  .brand {
    margin-bottom: 22px;
  }

  .auth-box h2 {
    font-size: 19px;
  }

  .form-row,
  .auth-footer {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px 14px;
  }

  .fp-modal {
    padding: 22px 18px calc(20px + env(safe-area-inset-bottom));
  }
}
