/*
  SCOPIA DESIGN SYSTEM
  Login premium · Light + Dark theme · Split layout
*/

/* ── Lucide icon system ── */
[data-lucide] { display: inline-flex; vertical-align: middle; line-height: 0; }
[data-lucide] svg { width: 1em; height: 1em; stroke-width: 2; }
.icon-inline { display: inline-flex; align-items: center; vertical-align: -0.15em; }
.icon-inline svg { width: 1em; height: 1em; }

/* ─────────────────────────────────────────────────────────────
   THEME TOKENS
   ───────────────────────────────────────────────────────────── */

:root,
[data-theme="dark"] {
  --primary: #185EAF;
  --primary-strong: #1E6FD0;
  --cyan: #41B8D5;
  --purple: #8A68F3;

  --bg: #060E1E;
  --bg-grad-1: #060E1E;
  --bg-grad-2: #0A1730;
  --surface: rgba(13, 30, 58, 0.72);
  --surface-solid: #0D1E3A;
  --surface-soft: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);

  --text: #EEF4FF;
  --text-strong: #FFFFFF;
  --subtext: #8AA4C8;
  --muted: #5C7BA0;

  --border: rgba(65, 184, 213, 0.18);
  --border-strong: rgba(65, 184, 213, 0.32);
  --border-soft: rgba(255, 255, 255, 0.06);

  --error: #FF4B5C;
  --error-bg: rgba(255, 75, 92, 0.10);
  --error-border: rgba(255, 75, 92, 0.28);
  --success: #22C55E;

  --shadow-card: 0 30px 80px rgba(0, 0, 0, 0.55), 0 4px 16px rgba(0, 0, 0, 0.30);
  --shadow-btn: 0 12px 32px rgba(24, 94, 175, 0.45);
  --shadow-btn-hover: 0 16px 40px rgba(65, 184, 213, 0.45);
  --ring: 0 0 0 4px rgba(65, 184, 213, 0.18);

  --grad-primary: linear-gradient(135deg, #185EAF 0%, #41B8D5 100%);
  --grad-purple: linear-gradient(135deg, #41B8D5 0%, #8A68F3 100%);
  --grad-brand: linear-gradient(160deg, #060E1E 0%, #0A1B3A 35%, #112C5A 65%, #185EAF 110%);

  --logo-light-display: none;   /* logo.svg (fondo blanco) — oculto en dark */
  --logo-dark-display: inline;  /* logo-dark.svg (texto blanco) — visible en dark */
}

[data-theme="light"] {
  --primary: #185EAF;
  --primary-strong: #134B8C;
  --cyan: #41B8D5;
  --purple: #8A68F3;

  --bg: #F4F7FB;
  --bg-grad-1: #EEF4FB;
  --bg-grad-2: #DCE7F5;
  --surface: rgba(255, 255, 255, 0.85);
  --surface-solid: #FFFFFF;
  --surface-soft: rgba(15, 39, 78, 0.04);
  --surface-hover: rgba(15, 39, 78, 0.07);

  --text: #0E1E3A;
  --text-strong: #050D1F;
  --subtext: #4F6B8E;
  --muted: #7E94B0;

  --border: rgba(24, 94, 175, 0.18);
  --border-strong: rgba(24, 94, 175, 0.34);
  --border-soft: rgba(15, 39, 78, 0.08);

  --error: #DC2638;
  --error-bg: rgba(220, 38, 56, 0.08);
  --error-border: rgba(220, 38, 56, 0.24);
  --success: #16A34A;

  --shadow-card: 0 24px 64px rgba(15, 39, 78, 0.14), 0 4px 12px rgba(15, 39, 78, 0.06);
  --shadow-btn: 0 12px 28px rgba(24, 94, 175, 0.32);
  --shadow-btn-hover: 0 16px 36px rgba(24, 94, 175, 0.40);
  --ring: 0 0 0 4px rgba(24, 94, 175, 0.14);

  --grad-primary: linear-gradient(135deg, #185EAF 0%, #41B8D5 100%);
  --grad-purple: linear-gradient(135deg, #41B8D5 0%, #8A68F3 100%);
  --grad-brand: linear-gradient(160deg, #185EAF 0%, #1F76C4 35%, #41B8D5 75%, #6FCDE2 110%);

  --logo-light-display: inline; /* logo.svg en light */
  --logo-dark-display: none;
}

/* ─────────────────────────────────────────────────────────────
   RESET
   ───────────────────────────────────────────────────────────── */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 80% -10%, color-mix(in oklab, var(--primary) 18%, transparent) 0%, transparent 60%),
    radial-gradient(900px 600px at -10% 110%, color-mix(in oklab, var(--cyan) 14%, transparent) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed;
  color: var(--text);
  font-family: 'DM Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.05;
  mix-blend-mode: overlay;
}

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

/* ─────────────────────────────────────────────────────────────
   THEME TOGGLE
   ───────────────────────────────────────────────────────────── */

.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 50;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}
.theme-toggle:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}
.theme-icon { width: 20px; height: 20px; }
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ─────────────────────────────────────────────────────────────
   AUTH SHELL — split layout
   ───────────────────────────────────────────────────────────── */

.auth-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────────────────────────
   BRAND PANEL (izquierda)
   ───────────────────────────────────────────────────────────── */

.brand-panel {
  position: relative;
  overflow: hidden;
  background: var(--grad-brand);
  color: #FFFFFF;
  padding: 56px 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  isolation: isolate;
}

[data-theme="light"] .brand-panel {
  color: #FFFFFF;
}

@media (max-width: 980px) {
  .brand-panel { display: none; }
}

.brand-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 30% 40%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 30% 40%, #000 30%, transparent 75%);
  z-index: 0;
  pointer-events: none;
}

.brand-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  animation: drift 18s ease-in-out infinite;
}
.brand-orb-1 {
  width: 480px; height: 480px;
  background: rgba(65, 184, 213, 0.55);
  top: -120px; left: -100px;
}
.brand-orb-2 {
  width: 360px; height: 360px;
  background: rgba(138, 104, 243, 0.40);
  bottom: -80px; right: -60px;
  animation-delay: -6s;
}
.brand-orb-3 {
  width: 280px; height: 280px;
  background: rgba(24, 94, 175, 0.55);
  top: 40%; left: 55%;
  animation-delay: -12s;
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(30px, -20px) scale(1.05); }
  66%      { transform: translate(-20px, 25px) scale(0.97); }
}

.brand-content {
  position: relative;
  z-index: 1;
  max-width: 540px;
  animation: fadeUp .8s ease both;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  margin-bottom: 56px;
}
.brand-logo img { height: 52px; width: auto; }

.brand-title {
  font-family: 'Poppins', sans-serif;
  font-size: clamp(2.1rem, 3.6vw, 3.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: #FFFFFF;
  margin-bottom: 20px;
}

.gradient-text {
  background: linear-gradient(120deg, #FFFFFF 0%, #B7E4F2 40%, #41B8D5 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.brand-subtitle {
  font-size: 16px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.78);
  max-width: 480px;
  margin-bottom: 36px;
}

.brand-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.brand-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
}
.feature-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 4px rgba(65, 184, 213, 0.20);
  flex-shrink: 0;
}

.brand-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
}
.brand-footer-dot { opacity: 0.5; }

/* ─────────────────────────────────────────────────────────────
   FORM PANEL (derecha)
   ───────────────────────────────────────────────────────────── */

.form-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 32px;
  overflow: hidden;
}

.form-decor {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}
.form-decor-1 {
  width: 380px; height: 380px;
  background: color-mix(in oklab, var(--primary) 22%, transparent);
  top: -120px; right: -100px;
}
.form-decor-2 {
  width: 280px; height: 280px;
  background: color-mix(in oklab, var(--purple) 18%, transparent);
  bottom: -80px; left: -80px;
}

/* ─────────────────────────────────────────────────────────────
   LOGIN CARD
   ───────────────────────────────────────────────────────────── */

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 44px 40px 36px;
  box-shadow: var(--shadow-card);
  animation: fadeUp .7s ease both;
}

.card-head { margin-bottom: 28px; }

.logo-mini {
  display: none;
  margin-bottom: 24px;
}
.logo-mini img { height: 44px; width: auto; }
.logo-mini .logo-on-light { display: var(--logo-light-display); }
.logo-mini .logo-on-dark  { display: var(--logo-dark-display); }

@media (max-width: 980px) {
  .logo-mini { display: block; }
}

.login-card h2 {
  font-family: 'Poppins', sans-serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-strong);
  margin-bottom: 8px;
}
.login-card .subtitle {
  color: var(--subtext);
  font-size: 14.5px;
  line-height: 1.5;
}

/* ─────────────────────────────────────────────────────────────
   FORM FIELDS
   ───────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 18px; }

.form-group label,
.label-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.label-row label { margin-bottom: 0; }

.link-quiet {
  font-size: 12.5px;
  color: var(--cyan);
  text-decoration: none;
  font-weight: 500;
  transition: color .2s ease;
}
.link-quiet:hover { color: var(--primary-strong); text-decoration: underline; }

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  width: 18px; height: 18px;
  color: var(--muted);
  pointer-events: none;
  transition: color .2s ease;
}

.input-wrapper input {
  width: 100%;
  background: var(--surface-soft);
  border: 1.5px solid var(--border-soft);
  border-radius: 12px;
  padding: 13px 14px 13px 42px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
  outline: none;
}
.input-wrapper input::placeholder { color: var(--muted); }
.input-wrapper input:hover { background: var(--surface-hover); }
.input-wrapper input:focus {
  border-color: var(--cyan);
  background: var(--surface-hover);
  box-shadow: var(--ring);
}
.input-wrapper input:focus + .input-icon,
.input-wrapper:focus-within .input-icon { color: var(--cyan); }

/* Mostrar / ocultar password */
.input-action {
  position: absolute;
  right: 8px;
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .2s ease, background .2s ease;
}
.input-action:hover { color: var(--text); background: var(--surface-hover); }
.input-action svg { width: 18px; height: 18px; }
.input-action .eye-hide { display: none; }
.input-action.is-visible .eye-show { display: none; }
.input-action.is-visible .eye-hide { display: block; }

/* Has icon padding adjust for password */
.input-wrapper:has(.input-action) input { padding-right: 48px; }

/* ─────────────────────────────────────────────────────────────
   REMEMBER CHECKBOX
   ───────────────────────────────────────────────────────────── */

.remember-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 22px;
  cursor: pointer;
  user-select: none;
}
.remember-row input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .2s ease;
  flex-shrink: 0;
  position: relative;
}
.check-box::after {
  content: '';
  width: 10px; height: 10px;
  background: var(--grad-primary);
  border-radius: 2px;
  transform: scale(0);
  transition: transform .15s ease;
}
.remember-row input:checked + .check-box {
  border-color: var(--cyan);
  background: color-mix(in oklab, var(--cyan) 12%, transparent);
}
.remember-row input:checked + .check-box::after { transform: scale(1); }
.check-label { font-size: 13.5px; color: var(--subtext); font-weight: 500; }

/* ─────────────────────────────────────────────────────────────
   PRIMARY BUTTON
   ───────────────────────────────────────────────────────────── */

.btn-primary {
  position: relative;
  width: 100%;
  background: var(--grad-primary);
  border: none;
  color: #FFFFFF;
  padding: 14px 18px;
  border-radius: 12px;
  font-family: 'Poppins', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .25s ease, filter .2s ease;
  box-shadow: var(--shadow-btn);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
}
.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg,
    transparent 0%,
    rgba(255, 255, 255, 0.20) 50%,
    transparent 100%);
  transform: translateX(-100%);
  transition: transform .55s ease;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-btn-hover);
  filter: brightness(1.05);
}
.btn-primary:hover::before { transform: translateX(100%); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { cursor: not-allowed; opacity: .85; }

.btn-arrow {
  width: 18px; height: 18px;
  transition: transform .2s ease;
}
.btn-primary:hover .btn-arrow { transform: translateX(3px); }

.btn-spinner {
  display: none;
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn-primary.is-loading .btn-label,
.btn-primary.is-loading .btn-arrow { display: none; }
.btn-primary.is-loading .btn-spinner { display: inline-block; }

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

/* ─────────────────────────────────────────────────────────────
   DIVIDER + FOOTER
   ───────────────────────────────────────────────────────────── */

.divider {
  position: relative;
  text-align: center;
  margin: 24px 0 16px;
}
.divider::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--border-soft);
}
.divider span {
  position: relative;
  display: inline-block;
  padding: 0 14px;
  background: var(--surface-solid);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.footer-links {
  text-align: center;
  font-size: 14px;
  color: var(--subtext);
}
.footer-links a {
  color: var(--cyan);
  text-decoration: none;
  font-weight: 600;
}
.footer-links a:hover { text-decoration: underline; }

.form-mini-foot {
  position: relative;
  z-index: 1;
  margin-top: 24px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.form-mini-foot a {
  color: var(--subtext);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px dashed var(--border-strong);
}
.form-mini-foot a:hover { color: var(--cyan); border-color: var(--cyan); }

/* ─────────────────────────────────────────────────────────────
   ERROR MESSAGE
   ───────────────────────────────────────────────────────────── */

#error-message {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 18px;
  display: none;
  text-align: left;
  animation: shake .4s ease;
}
#error-message:not(:empty) { display: block; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}

/* ─────────────────────────────────────────────────────────────
   ANIMATIONS
   ───────────────────────────────────────────────────────────── */

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

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 540px) {
  .form-panel { padding: 40px 18px; }
  .login-card { padding: 32px 24px 28px; border-radius: 20px; }
  .login-card h2 { font-size: 24px; }
  .theme-toggle { top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 12px; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
