/* ==========================================================================
   SECURYTECH MASTER ENTERPRISE V1.0 — AUTHENTICATION DESIGN SYSTEM (V4.0 FINAL)
   Layout 100vh exacto sin desbordamiento | Light & Dark Mode
   ========================================================================== */

:root {
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-ring: rgba(15, 118, 110, 0.28);
  --accent-soft: rgba(15, 118, 110, 0.10);

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --input-bg: #ffffff;

  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: rgba(185, 28, 28, 0.25);
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --ok-border: rgba(21, 128, 61, 0.25);
  --warn: #b45309;
  --warn-bg: #fffbeb;

  --radius: 10px;
  --radius-lg: 18px;
  --shadow-card: 0 20px 45px -12px rgba(15, 23, 42, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.04);
}

html[data-theme="dark"] {
  --accent: #14b8a6;
  --accent-hover: #0d9488;
  --accent-ring: rgba(20, 184, 166, 0.32);
  --accent-soft: rgba(20, 184, 166, 0.15);

  --bg: #070d19;
  --surface: #111c2d;
  --surface-subtle: #162235;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #1e293b;
  --border-strong: #334155;
  --input-bg: #0b1322;

  --danger: #f87171;
  --danger-bg: rgba(185, 28, 28, 0.18);
  --danger-border: rgba(248, 113, 113, 0.3);
  --ok: #4ade80;
  --ok-bg: rgba(21, 128, 61, 0.18);
  --ok-border: rgba(74, 222, 128, 0.3);
  --warn: #fbbf24;
  --warn-bg: rgba(180, 83, 9, 0.18);

  --shadow-card: 0 25px 55px -12px rgba(0, 0, 0, 0.65);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; }

/* ---------- Layout Principal ---------- */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- Panel Izquierdo Corporativo ---------- */
.brand-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 36px 52px;
  color: #ffffff;
  background:
    radial-gradient(circle at 88% 12%, rgba(20, 184, 166, 0.28) 0%, transparent 42%),
    radial-gradient(circle at 12% 88%, rgba(2, 132, 199, 0.25) 0%, transparent 45%),
    linear-gradient(145deg, #02131d 0%, #062c41 55%, #0b504b 100%);
}

.brand-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 90%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 90%);
  pointer-events: none;
}

.brand-header,
.brand-copy,
.brand-footer {
  position: relative;
  z-index: 2;
}

.brand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand-logo-img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: contain;
  background: #ffffff;
  padding: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  font-size: 17px;
  backdrop-filter: blur(8px);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
}

.text-emerald { color: #34d399; font-size: 8px; }

.brand-copy {
  margin: auto 0;
  padding: 16px 0;
}

.eyebrow-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #5eead4;
  background: rgba(20, 184, 166, 0.16);
  border: 1px solid rgba(94, 234, 212, 0.28);
  margin-bottom: 14px;
}

.brand-copy h2 {
  margin: 0 0 10px;
  max-width: 500px;
  font-size: 29px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.brand-copy p {
  margin: 0 0 22px;
  max-width: 470px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 14.5px;
}

.feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  max-width: 490px;
}

.feature-card {
  display: flex;
  gap: 13px;
  align-items: center;
  padding: 12px 15px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  transition: transform 0.2s ease, background 0.2s ease;
}

.feature-card:hover {
  transform: translateX(4px);
  background: rgba(255, 255, 255, 0.10);
}

.feature-icon {
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(20, 184, 166, 0.22);
  color: #5eead4;
  font-size: 14px;
}

.feature-list strong { display: block; font-size: 14px; font-weight: 700; margin-bottom: 1px; }
.feature-list span.desc { color: rgba(255, 255, 255, 0.72); font-size: 12.5px; line-height: 1.35; display: block; }

.brand-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.62);
}

/* ---------- Panel Derecho del Formulario ---------- */
.form-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px 24px;
  min-height: 100vh;
}

.auth-topbar {
  position: absolute;
  top: 20px;
  right: 24px;
  z-index: 10;
}

.theme-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
  transition: all 0.15s ease;
}

.theme-switch-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.login-box {
  width: 100%;
  max-width: 425px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 32px;
  box-shadow: var(--shadow-card);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.login-box.flipped .login-form { display: none; }
.login-box:not(.flipped) .forget-form { display: none; }

.login-form, .forget-form { animation: fadeUp 0.28s cubic-bezier(0.16, 1, 0.3, 1) both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

@keyframes authShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.login-box.shake { animation: authShake 0.35s ease; }

.form-eyebrow {
  display: none;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-weight: 800;
  font-size: 16px;
}

.brand-logo-img-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
}

.brand-mark-sm {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
}

.form-header { margin-bottom: 20px; }
.form-title { margin: 0 0 5px; font-size: 23px; line-height: 1.2; font-weight: 800; letter-spacing: -0.025em; }
.form-sub { margin: 0; color: var(--muted); font-size: 13.5px; }

.field { margin-bottom: 15px; }

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 12.8px;
  font-weight: 600;
  color: var(--text);
}

.label-row label { margin-bottom: 0; }

.forgot-link {
  font-size: 12.5px;
  font-weight: 600;
}

.input-wrap { position: relative; }

.input-wrap .lead-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 13.5px;
  pointer-events: none;
  transition: color 0.15s ease;
}

.input {
  width: 100%;
  height: 44px;
  padding: 0 42px 0 40px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder { color: var(--muted); opacity: 0.7; }
.input:hover { border-color: var(--muted); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.input-wrap:focus-within .lead-icon { color: var(--accent); }
.input.is-invalid { border-color: var(--danger); }

.pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.pw-toggle:hover { color: var(--text); background: var(--accent-soft); }
.pw-toggle[aria-pressed="true"] .icon-show { display: none; }
.pw-toggle[aria-pressed="false"] .icon-hide { display: none; }

.hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--warn);
  display: flex;
  gap: 6px;
  align-items: center;
}

.remember-row {
  margin: 2px 0 18px;
}

.custom-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.custom-check input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  height: 45px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 700;
  color: #ffffff;
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: 0 8px 18px -4px var(--accent-ring);
  transition: background 0.15s ease, transform 0.08s ease;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.8; cursor: wait; }

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.link-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 8px;
  margin-top: 16px;
  font-size: 13.5px;
  font-weight: 600;
}

#alertLogin, #alertReset { margin-bottom: 14px; }
#alertLogin:empty, #alertReset:empty { margin: 0; }

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  text-align: left;
}

.alert-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.alert-success { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.alert-warning { color: var(--warn); background: var(--warn-bg); border-color: currentColor; }

.security-note {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 20px;
  padding: 10px 13px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11.8px;
  color: var(--muted);
}

.security-note-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 13px;
  flex-shrink: 0;
}

.security-note strong {
  display: block;
  color: var(--text);
  font-size: 12px;
}

/* ---------- Componentes de Cambio de Contraseña ---------- */
.reset-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  word-break: break-all;
}
.reset-user strong { color: var(--text); font-weight: 600; }

.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.strength span { height: 4px; border-radius: 4px; background: var(--border-strong); transition: background 0.2s; }
.strength[data-level="1"] span:nth-child(-n+1) { background: var(--danger); }
.strength[data-level="2"] span:nth-child(-n+2) { background: #e08a00; }
.strength[data-level="3"] span:nth-child(-n+3) { background: #7cb342; }
.strength[data-level="4"] span:nth-child(-n+4) { background: var(--ok); }

.field-note { margin: 5px 0 0; font-size: 12px; color: var(--muted); min-height: 16px; }
.field-note.ok { color: var(--ok); }
.field-note.bad { color: var(--danger); }

/* ---------- Loading Overlay ---------- */
#divLoading { position: fixed; inset: 0; z-index: 9999; }
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 17, 29, 0.55);
  backdrop-filter: blur(2px);
}
.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .auth { grid-template-columns: 1fr; }
  .brand-panel { display: none; }
  .form-eyebrow { display: flex; }
  .form-panel {
    justify-content: flex-start;
    padding: 72px 14px 28px 14px;
    min-height: 100vh;
  }
  .auth-topbar {
    top: 14px;
    right: 14px;
    left: 14px;
    justify-content: space-between !important;
  }
}

@media (max-width: 480px) {
  .login-box {
    padding: 22px 16px;
    border-radius: 16px;
  }
  .form-title {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .login-box { padding: 26px 20px; border-radius: 16px; }
}

/* ---------- SweetAlert 1.x Ajustado al Tema ---------- */
.sweet-overlay {
  background-color: rgba(7, 13, 25, 0.6);
  backdrop-filter: blur(2px);
  position: fixed;
  inset: 0;
  display: none;
  z-index: 10000;
}
.sweet-alert {
  background-color: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-family: inherit;
  width: 430px;
  max-width: calc(100vw - 32px);
  padding: 24px;
  border-radius: 16px;
  text-align: center;
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0 !important;
  box-shadow: var(--shadow-card);
  display: none;
  z-index: 99999;
}
.sweet-alert h2 { color: var(--text); font-size: 21px; font-weight: 800; margin: 12px 0 8px; }
.sweet-alert p { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.sweet-alert button {
  background-color: var(--accent) !important;
  color: #fff;
  border: 0;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  padding: 10px 24px;
  margin: 10px 5px 0;
  cursor: pointer;
}
.sweet-alert button.cancel { background-color: #64748b !important; }

.sweet-alert fieldset,
.sweet-alert .sa-error-container,
.sweet-alert .sa-input-error {
  display: none !important;
}