/* =============================================================
   auth.css — Sistema de autenticación UPeU 2026
   Color base: #003264 (azul institucional)
   ============================================================= */

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

:root {
    --navy:        #003264;
    --navy-dark:   #001d3d;
    --navy-mid:    #00458a;
    --navy-light:  #e8f0fa;
    --yellow:      #f5c518;
    --surface:     #ffffff;
    --text:        #0a1628;
    --text-muted:  #6b7a8d;
    --border:      #d1dce8;
    --error-bg:    #fef2f2;
    --error-bd:    #fca5a5;
    --error-text:  #b91c1c;
    --radius:      10px;
}

html, body { height: 100%; font-family: 'Inter', system-ui, -apple-system, sans-serif; background: #fff; }

/* ── Layout ──────────────────────────────────────────────── */
.auth-layout {
    display: flex;
    height: 100vh;
    min-height: 500px;
    overflow: hidden;
}

/* ── Panel izquierdo: polaroids ──────────────────────────── */
.auth-panel-left {
    flex: 0 0 50%;
    background: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    overflow: hidden;
    position: relative;
}

.auth-panel-left::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 50%, rgba(255,255,255,0.03) 0%, transparent 70%);
    pointer-events: none;
}

/* Pirámide: 1 arriba centrada + 2 abajo — las 3 con el mismo tamaño */
.auth-polaroids {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    width: 100%;
    max-width: clamp(260px, 88%, 600px);
    position: relative;
    z-index: 1;
}

.auth-polaroid {
    background: #fff;
    padding: 8px 8px 58px;
    box-shadow:
        0 4px 8px rgba(0,0,0,0.25),
        0 14px 40px rgba(0,0,0,0.35);
    position: relative;
    transition: transform 0.3s cubic-bezier(.34,1.56,.64,1), box-shadow 0.3s ease;
    will-change: transform;
}

.auth-polaroid:hover {
    box-shadow:
        0 6px 12px rgba(0,0,0,0.30),
        0 22px 56px rgba(0,0,0,0.45);
    z-index: 10;
}

/* Pirámide: foto 1 centrada con el mismo ancho que cada columna inferior */
.auth-polaroid--1 {
    grid-column: 1 / -1;
    width: calc(50% - 8px);
    margin: 0 auto 2px;
    transform: rotate(-2deg);
}
.auth-polaroid--1:hover { transform: rotate(0deg) scale(1.04); }

.auth-polaroid--2 { transform: rotate(1.8deg); }
.auth-polaroid--2:hover { transform: rotate(0deg) scale(1.04); }

.auth-polaroid--3 { transform: rotate(-1.5deg); }
.auth-polaroid--3:hover { transform: rotate(0deg) scale(1.04); }

/* Las 3 fotos: aspect ratio cuadrado para tamaño visual idéntico */
.auth-polaroid img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}

.auth-polaroid span {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    text-align: center;
    font-size: 11px;
    font-style: italic;
    font-weight: 600;
    color: #7a6e62;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    line-height: 1.3;
}

.auth-polaroid span em {
    font-style: normal;
    font-weight: 400;
    font-size: 9px;
    color: #a89e94;
    letter-spacing: 0.08em;
    text-transform: none;
}

/* ── Panel derecho: formulario ───────────────────────────── */
.auth-panel-form {
    flex: 1;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 40px 40px 32px;
    overflow-y: auto;
}

.auth-form-wrapper {
    width: 100%;
    max-width: clamp(280px, 90%, 380px);
}

/* ── Cabecera: logo + nombre (panel derecho, desktop) ─────── */
.auth-form-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 64px;
}

.auth-form-logo-badge {
    background: transparent;
    flex-shrink: 0;
    line-height: 0;
}

.auth-form-logo-badge img {
    width: 160px;
}

.auth-form-uni-name { display: none; }

/* Badge móvil — oculto en desktop */
.auth-mobile-brand { display: none; }
.auth-mobile-logo  { display: none; }

/* ── Encabezado del formulario ───────────────────────────── */
.auth-heading {
    font-size: 30px;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.15;
    margin-bottom: 10px;
}

.auth-accent-bar {
    width: 36px;
    height: 3px;
    background: var(--yellow);
    border-radius: 2px;
    margin-bottom: 18px;
    animation: bar-grow 0.45s ease-out forwards;
}
@keyframes bar-grow {
    from { width: 0; opacity: 0; }
    to   { width: 36px; opacity: 1; }
}

.auth-subtext {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 22px;
}

/* ── Campos ──────────────────────────────────────────────── */
.auth-field { margin-bottom: 16px; }

.auth-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.auth-field-wrap { position: relative; }

.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="password"] {
    width: 100%;
    height: 50px;
    padding: 0 48px 0 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color 0.18s, box-shadow 0.18s;
    outline: none;
    -webkit-appearance: none;
}

.auth-field input::placeholder { color: #b0bac5; opacity: 1; }

.auth-field input:focus {
    border-color: var(--navy-mid);
    box-shadow: 0 0 0 3px rgba(0, 69, 138, 0.12);
}

.pwd-toggle {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: color 0.18s;
    line-height: 0;
}
.pwd-toggle:hover { color: var(--navy); }
.pwd-toggle .ico-eye-off { display: none; }
.pwd-toggle.visible .ico-eye { display: none; }
.pwd-toggle.visible .ico-eye-off { display: block; }

.auth-field input.no-toggle { padding-right: 16px; }

/* ── Errores ─────────────────────────────────────────────── */
.auth-errors {
    background: var(--error-bg);
    border: 1px solid var(--error-bd);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 16px;
}
.auth-errors p, .auth-errors ul { list-style: none; }
.auth-errors p, .auth-errors li { color: var(--error-text); font-size: 13px; line-height: 1.45; }
.field-error { color: var(--error-text); font-size: 12px; margin-top: 4px; }

/* ── Botones ─────────────────────────────────────────────── */
.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 52px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.18s, transform 0.1s;
    margin-bottom: 10px;
}
.auth-btn:active { transform: scale(0.98); }

.auth-btn-primary { background: var(--navy); color: #fff; }
.auth-btn-primary:hover { background: var(--navy-mid); }

.auth-btn-ghost { background: var(--navy-light); color: var(--navy); font-weight: 500; }
.auth-btn-ghost:hover { background: #d5e5f8; }

.auth-btn-ms {
    gap: 10px;
    border: 1.5px solid var(--border);
    background: #fff;
    color: var(--text);
    font-weight: 500;
}
.auth-btn-ms:hover { background: #f8fafc; border-color: #aabdd4; }
.auth-btn-ms img { width: 18px; height: 18px; }

/* ── Separador ───────────────────────────────────────────── */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0;
    font-size: 12px;
    color: var(--text-muted);
}
.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ── Links ───────────────────────────────────────────────── */
.auth-link-row {
    text-align: center;
    margin-top: 18px;
    font-size: 13px;
    color: var(--text-muted);
}
.auth-link-row a { color: var(--navy-mid); font-weight: 500; text-decoration: none; }
.auth-link-row a:hover { color: var(--navy); text-decoration: underline; }

.auth-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 24px;
    transition: color 0.18s;
}
.auth-back:hover { color: var(--navy); }

/* ── Validación de contraseña en tiempo real ─────────────── */
.pwd-requirements {
    background: var(--navy-light);
    border-radius: 8px;
    padding: 10px 13px 9px;
    margin-top: 8px;
}

.pwd-req-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 9px;
}

.pwd-req-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    transition: color 0.18s;
}

.req-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    transition: background 0.18s, border-color 0.18s, color 0.18s;
}

.pwd-req-item.met {
    color: #16a34a;
}
.pwd-req-item.met .req-icon {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}
.pwd-req-item.met .req-icon::before { content: '✓'; }

.pwd-req-item.unmet {
    color: var(--error-text);
}
.pwd-req-item.unmet .req-icon {
    background: var(--error-bg);
    border-color: var(--error-bd);
    color: var(--error-text);
}
.pwd-req-item.unmet .req-icon::before { content: '✗'; }

.pwd-example {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 2px;
}

.pwd-example-label { font-weight: 500; }
.pwd-example-sep   { opacity: 0.4; }

.pwd-example code {
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;
    font-size: 12px;
    background: rgba(0, 50, 100, 0.10);
    color: var(--navy);
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
}

/* Match indicator */
.pwd-match-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    margin-top: 5px;
    min-height: 18px;
    font-weight: 500;
    transition: color 0.18s;
}
.pwd-match-status.match    { color: #16a34a; }
.pwd-match-status.no-match { color: var(--error-text); }

/* Botón deshabilitado mientras no se cumplen requisitos */
.auth-btn-primary:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}
.auth-btn-primary:disabled:hover { background: var(--border); }

/* ── Info / éxito ────────────────────────────────────────── */
.auth-info {
    background: var(--navy-light);
    border-left: 4px solid var(--navy);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 20px;
}
.auth-info p { font-size: 14px; color: var(--text); line-height: 1.55; }

.auth-success-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--navy-light);
    border-radius: 50%;
    margin: 0 auto 18px;
    color: var(--navy);
}

/* ─────────────────────────────────────────────────────────────
   BREAKPOINTS
   ≥ 1280px   Monitor regular (base)
   1024–1279  Monitor pequeño
    720–1023  Tablet / Fold abierto
    400–719   Móvil
    < 400     Fold cerrado / teléfono muy pequeño
───────────────────────────────────────────────────────────── */

/* ── Monitor pequeño (1024–1279px) ─────────────────────────── */
@media (max-width: 1279px) {
    .auth-panel-left    { flex: 0 0 44%; padding: 20px 16px; }
    .auth-polaroids     { gap: 14px; }
    .auth-polaroid      { padding: 7px 7px 52px; }
    .auth-polaroid--1   { width: calc(50% - 7px); }
}

/* ── Tablet / Fold abierto (720–1023px) — solo formulario ─── */
@media (max-width: 1023px) {
    html, body { height: auto; }

    .auth-layout {
        height: auto;
        min-height: 100vh;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 32px 24px 48px;
        background: var(--navy-dark);
        overflow: visible;
    }

    .auth-panel-left { display: none; }

    .auth-panel-form {
        flex: none;
        width: 100%;
        max-width: 520px;
        background: rgba(255, 255, 255, 0.97);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-radius: 28px;
        border: 1px solid rgba(255, 255, 255, 0.8);
        box-shadow: 0 16px 56px rgba(0, 29, 61, 0.45);
        padding: 44px 40px 48px;
        align-items: flex-start;
        justify-content: flex-start;
        border-left: none;
        overflow-y: visible;
    }

    .auth-form-header { display: none; }

    .auth-mobile-brand {
        display: flex;
        justify-content: center;
        margin-bottom: 40px;
    }
    .auth-mobile-logo {
        display: block;
        width: 150px;
        background: transparent;
    }

    .auth-form-wrapper { max-width: 100%; }
}

/* ── Móvil (400–719px) ───────────────────────────────────── */
@media (max-width: 719px) {
    .auth-layout        { padding: 24px 16px 40px; }
    .auth-panel-form    { max-width: 420px; padding: 36px 28px 40px; border-radius: 24px; }
    .auth-mobile-logo   { width: 130px; }
    .auth-heading       { font-size: 26px; }
    .auth-subtext       { font-size: 14px; margin-bottom: 20px; }
}

/* ── Fold cerrado / muy pequeño (< 400px) ─────────────────── */
@media (max-width: 399px) {
    .auth-layout        { padding: 16px 10px 32px; }
    .auth-panel-form    { padding: 24px 16px 32px; border-radius: 18px; }
    .auth-mobile-logo   { width: 110px; }
    .auth-mobile-brand  { margin-bottom: 28px; }
    .auth-heading       { font-size: 22px; }
    .auth-subtext       { font-size: 13px; }
    .auth-btn           { height: 46px; font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-accent-bar { animation: none; width: 36px; }
    .auth-polaroid   { transform: none !important; }
}

/* =============================================================
   LOGO: light / dark switch
   ============================================================= */
/* Badge desktop */
.auth-form-logo-badge .logo-light { display: block; }
.auth-form-logo-badge .logo-dark  { display: none;  }
[data-theme="dark"] .auth-form-logo-badge .logo-light { display: none;  }
[data-theme="dark"] .auth-form-logo-badge .logo-dark  { display: block; }

/* Badge móvil */
.auth-mobile-brand .logo-light { display: block; }
.auth-mobile-brand .logo-dark  { display: none;  }
[data-theme="dark"] .auth-mobile-brand .logo-light { display: none;  }
[data-theme="dark"] .auth-mobile-brand .logo-dark  { display: block; }

/* =============================================================
   TOGGLE DE TEMA
   ============================================================= */
.theme-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.2s;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}
.theme-toggle:hover {
    color: var(--navy);
    border-color: var(--navy);
    transform: scale(1.08);
}

/* En modo oscuro se muestran los iconos al revés */
.ico-sun  { display: none;  }
.ico-moon { display: block; }
[data-theme="dark"] .ico-sun  { display: block; }
[data-theme="dark"] .ico-moon { display: none;  }

/* =============================================================
   DARK MODE
   Variables de sobreescritura
   ============================================================= */
[data-theme="dark"] {
    --text:       #e6edf3;
    --text-muted: #7d8590;
    --border:     #30363d;
    --navy-light: #1c2e4a;
    --error-bg:   #2d1515;
    --error-bd:   #6b2020;
    --error-text: #f87171;
}

/* ── Estructura ──────────────────────────────────────────── */
[data-theme="dark"] html,
[data-theme="dark"] body            { background: #0d1117; }

[data-theme="dark"] .auth-panel-left { background: #001530; }

[data-theme="dark"] .auth-panel-form { background: #111827; }

/* ── Encabezados y textos ────────────────────────────────── */
[data-theme="dark"] .auth-heading   { color: #e6edf3; }
[data-theme="dark"] .auth-subtext   { color: #7d8590; }

/* ── Campos ──────────────────────────────────────────────── */
[data-theme="dark"] .auth-field label { color: #cdd9e5; }

[data-theme="dark"] .auth-field input[type="text"],
[data-theme="dark"] .auth-field input[type="email"],
[data-theme="dark"] .auth-field input[type="password"] {
    background:   #0d1117;
    border-color: #30363d;
    color:        #e6edf3;
}
[data-theme="dark"] .auth-field input::placeholder { color: #484f58; }
[data-theme="dark"] .auth-field input:focus {
    border-color: var(--navy-mid);
    box-shadow:   0 0 0 3px rgba(0,69,138,0.28);
}

[data-theme="dark"] .pwd-toggle       { color: #484f58; }
[data-theme="dark"] .pwd-toggle:hover { color: #e6edf3; }

/* ── Botones ─────────────────────────────────────────────── */
[data-theme="dark"] .auth-btn-primary       { background: #1a4d8a; }
[data-theme="dark"] .auth-btn-primary:hover { background: #1f5ca3; }

[data-theme="dark"] .auth-btn-ghost       { background: #1c2e4a; color: #7db3f0; }
[data-theme="dark"] .auth-btn-ghost:hover { background: #24395e; }

[data-theme="dark"] .auth-btn-ms {
    background:   #161b22;
    border-color: #30363d;
    color:        #e6edf3;
}
[data-theme="dark"] .auth-btn-ms:hover {
    background:   #1c2128;
    border-color: #484f58;
}

/* ── Separador ───────────────────────────────────────────── */
[data-theme="dark"] .auth-divider { color: #484f58; }
[data-theme="dark"] .auth-divider::before,
[data-theme="dark"] .auth-divider::after { background: #30363d; }

/* ── Links ───────────────────────────────────────────────── */
[data-theme="dark"] .auth-link-row         { color: #7d8590; }
[data-theme="dark"] .auth-link-row a       { color: #7db3f0; }
[data-theme="dark"] .auth-link-row a:hover { color: #a5c8f5; }
[data-theme="dark"] .auth-back             { color: #7d8590; }
[data-theme="dark"] .auth-back:hover       { color: #e6edf3; }

/* ── Dark mode: validación ───────────────────────────────── */
[data-theme="dark"] .pwd-requirements {
    background: rgba(255, 255, 255, 0.04);
}
[data-theme="dark"] .req-icon {
    border-color: #30363d;
}
[data-theme="dark"] .pwd-example {
    border-top-color: #30363d;
}
[data-theme="dark"] .pwd-example code {
    background: rgba(125, 179, 240, 0.12);
    color: #7db3f0;
}
[data-theme="dark"] .auth-btn-primary:disabled {
    background: #1e2535;
    color: #484f58;
}

/* ── Info / éxito ────────────────────────────────────────── */
[data-theme="dark"] .auth-info {
    background:  #1c2e4a;
    border-color: #4a87c8;
}
[data-theme="dark"] .auth-info p { color: #cdd9e5; }

[data-theme="dark"] .auth-success-icon {
    background: #1c2e4a;
    color:      #7db3f0;
}

/* ── Toggle de tema en oscuro ────────────────────────────── */
[data-theme="dark"] .theme-toggle {
    background:   #1e2535;
    border-color: #30363d;
    color:        #7d8590;
}
[data-theme="dark"] .theme-toggle:hover {
    color:        #e6edf3;
    border-color: #7d8590;
}

/* ── Tablet / móvil en oscuro — card dark glass ──────────── */
@media (max-width: 1023px) {
    [data-theme="dark"] .auth-layout {
        background: #080d16;
    }
    [data-theme="dark"] .auth-panel-form {
        background:   rgba(17, 24, 39, 0.97);
        border-color: rgba(255, 255, 255, 0.06);
        box-shadow:   0 16px 56px rgba(0, 0, 0, 0.65);
    }
}
