:root {
  --bg: #060c18;
  --surface: #0d182c;
  --line: #25385c;
  --ink: #ebf2ff;
  --muted: #9db0d0;
  --green: #1dd75e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Tajawal", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 100% 0%, rgba(29, 215, 94, 0.16), transparent 30%),
    radial-gradient(circle at 0% 0%, rgba(36, 95, 221, 0.2), transparent 28%),
    linear-gradient(180deg, #050b18, #081224 52%, #0a1426);
}

html.light-mode body {
  color: #111;
  background:
    radial-gradient(circle at 100% 0%, rgba(60, 179, 113, 0.12), transparent 30%),
    radial-gradient(circle at 0% 0%, rgba(143, 188, 143, 0.16), transparent 28%),
    linear-gradient(180deg, #f0fff0, #ffffff 52%, #f8fffb);
}

@keyframes authRise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(13, 24, 44, 0.94);
  backdrop-filter: blur(7px);
  padding: 1.2rem;
  animation: authRise 0.48s ease both;
  transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
}

html.light-mode .auth-card {
  background: #ffffff;
  border-color: #cfe4d6;
  box-shadow: 0 16px 32px rgba(46, 139, 87, 0.12);
}

.auth-card:hover {
  transform: translateY(-4px);
  border-color: #2f4a76;
  box-shadow: 0 16px 32px rgba(9, 21, 40, 0.35);
}

.back-link {
  display: inline-block;
  color: #b8caeb;
  text-decoration: none;
  font-weight: 700;
  margin-bottom: 0.8rem;
}

html.light-mode .back-link { color: #2e8b57; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.brand-mark {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 0.72rem;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, #2be676, #16c65a);
  color: #062f15;
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 1.28rem;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

html.light-mode .brand p { color: #4e6158; }
html.light-mode .auth-title { color: #111; }

.auth-title {
  margin: 0 0 0.85rem;
  font-size: 1.35rem;
  font-weight: 900;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.mode-btn {
  min-height: 2.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #101d33;
  color: #cfdcf7;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

html.light-mode .mode-btn {
  background: #ffffff;
  color: #1f2d26;
  border-color: #cfe4d6;
}

.mode-btn:hover {
  transform: translateY(-2px);
  border-color: #3c5f92;
}

.mode-btn.active {
  border-color: #2fce6b;
  background: linear-gradient(145deg, #1ad660, #15bb53);
  color: #fff;
}

.auth-form {
  display: grid;
  gap: 0.74rem;
}

.auth-form label {
  display: grid;
  gap: 0.3rem;
  font-weight: 700;
  color: #c6d5f3;
}

html.light-mode .auth-form label { color: #1f2d26; }

.auth-form input,
.auth-form select {
  width: 100%;
  min-height: 2.9rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0d1729;
  color: var(--ink);
  padding: 0 0.8rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

html.light-mode .auth-form input,
html.light-mode .auth-form select {
  background: #ffffff;
  color: #111;
  border-color: #cfe4d6;
}

.auth-form input:focus,
.auth-form select:focus {
  border-color: #2fce6b;
  box-shadow: 0 0 0 3px rgba(29, 215, 94, 0.16);
  outline: none;
}

.submit-btn {
  min-height: 3rem;
  border-radius: 10px;
  border: 0;
  background: linear-gradient(145deg, #1ad660, #15bb53);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, filter 0.22s ease;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(17, 128, 60, 0.36);
  filter: brightness(1.02);
}

.switch-copy {
  margin: 0.15rem 0 0;
  color: #b8caeb;
  text-align: center;
  font-weight: 700;
}

html.light-mode .switch-copy { color: #4e6158; }

.inline-action {
  border: 0;
  background: transparent;
  color: #2be676;
  font-family: inherit;
  font-weight: 900;
  cursor: pointer;
  text-decoration: none;
  padding: 0;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

html.light-mode .inline-action { color: #2e8b57; }

.inline-action:hover {
  color: #55f294;
  text-shadow: 0 8px 22px rgba(29, 215, 94, 0.25);
}

.back-link,
.submit-btn,
.mode-btn,
.inline-action {
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease, color 0.22s ease;
}

.back-link:hover {
  transform: translateY(-1px);
  color: #d4e4ff;
}

.back-link:focus-visible,
.mode-btn:focus-visible,
.submit-btn:focus-visible,
.inline-action:focus-visible,
.auth-form input:focus-visible,
.auth-form select:focus-visible {
  outline: 2px solid rgba(29, 215, 94, 0.58);
  outline-offset: 2px;
}

.auth-message {
  min-height: 1.2rem;
  margin: 0 0 0.7rem;
  color: #ffb4b4;
  font-weight: 700;
}

html.light-mode .auth-message { color: #c0392b; }
html.light-mode .auth-message.ok { color: #2e8b57; }

.auth-message.ok {
  color: #7ff0aa;
}

.hidden { display: none; }

@media (max-width: 640px) {
  .auth-shell {
    padding: 0.75rem;
    align-items: start;
  }

  .auth-card {
    border-radius: 14px;
    padding: 0.9rem;
    margin-top: 0.65rem;
  }

  .brand {
    gap: 0.55rem;
    margin-bottom: 0.75rem;
  }

  .brand h1 {
    font-size: 1.08rem;
  }

  .brand p {
    font-size: 0.72rem;
  }

  .auth-title {
    font-size: 1.1rem;
    margin-bottom: 0.65rem;
  }

  .mode-btn,
  .submit-btn,
  .auth-form input,
  .auth-form select {
    min-height: 2.65rem;
    font-size: 0.9rem;
  }

  .switch-copy,
  .auth-message {
    font-size: 0.86rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card,
  .back-link,
  .submit-btn,
  .mode-btn,
  .inline-action,
  .auth-form input,
  .auth-form select {
    transition: none;
  }

  .auth-card {
    animation: none;
  }
}

/* Global hover layer for auth pages */
@media (hover: hover) and (pointer: fine) {
  a,
  button,
  .auth-card,
  .back-link,
  .submit-btn,
  .mode-btn,
  .inline-action,
  .auth-form input,
  .auth-form select {
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease, background-color 0.22s ease, color 0.22s ease;
  }

  a:hover,
  button:hover,
  .back-link:hover,
  .submit-btn:hover,
  .mode-btn:hover,
  .inline-action:hover {
    transform: translateY(-2px);
  }

  .auth-card:hover,
  .auth-form input:hover,
  .auth-form select:hover {
    box-shadow: 0 16px 30px rgba(9, 21, 40, 0.28);
  }
}
