/* ===== VARIABLES ===== */
:root {
    --bg-light: #f5e6c8;
    --bg-paper: #fdf6e3;
    --bg-paper-dark: #f0e0c0;
    --text-light: #2c1810;
    --text-light-muted: #6b4e3d;
    --accent-gold: #c9a84c;
    --accent-gold-dark: #a08030;
    --border-light: #d4b896;
    --shadow-light: rgba(139, 90, 43, 0.15);
    
    --bg-dark: #0d0d1a;
    --bg-dark-card: #1a1a2e;
    --bg-dark-elevated: #252540;
    --text-dark: #e8e0d0;
    --text-dark-muted: #a09080;
    --accent-purple: #062863;
    --accent-purple-light: #607ec9;
    --border-dark: #3a3a5c;
    --shadow-dark: rgba(0, 0, 0, 0.4);
    
    --font-title: 'Cinzel', serif;
    --font-body: 'Cormorant Garamond', serif;
    --font-ui: 'Noto Sans JP', sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.5s ease, color 0.5s ease;
}

body.light-mode {
    background: var(--bg-light);
    color: var(--text-light);
}

body.dark-mode {
    background: var(--bg-dark);
    color: var(--text-dark);
}

/* ===== FONDO ESTRELLADO ===== */
.stars-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.star-dot {
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    animation: twinkle 3s ease-in-out infinite;
}

.light-mode .star-dot {
    background: var(--accent-gold);
    opacity: 0.3;
}

.dark-mode .star-dot {
    background: var(--accent-purple-light);
    opacity: 0.4;
}

.star-dot:nth-child(1) { top: 10%; left: 15%; animation-delay: 0s; }
.star-dot:nth-child(2) { top: 20%; left: 80%; animation-delay: 0.5s; width: 3px; height: 3px; }
.star-dot:nth-child(3) { top: 35%; left: 25%; animation-delay: 1s; }
.star-dot:nth-child(4) { top: 45%; left: 70%; animation-delay: 1.5s; width: 3px; height: 3px; }
.star-dot:nth-child(5) { top: 55%; left: 10%; animation-delay: 0.3s; }
.star-dot:nth-child(6) { top: 65%; left: 85%; animation-delay: 0.8s; }
.star-dot:nth-child(7) { top: 75%; left: 40%; animation-delay: 1.2s; width: 3px; height: 3px; }
.star-dot:nth-child(8) { top: 15%; left: 50%; animation-delay: 1.8s; }
.star-dot:nth-child(9) { top: 30%; left: 90%; animation-delay: 0.2s; }
.star-dot:nth-child(10) { top: 50%; left: 5%; animation-delay: 1.1s; width: 3px; height: 3px; }
.star-dot:nth-child(11) { top: 80%; left: 60%; animation-delay: 0.6s; }
.star-dot:nth-child(12) { top: 5%; left: 35%; animation-delay: 1.4s; }
.star-dot:nth-child(13) { top: 60%; left: 30%; animation-delay: 0.9s; width: 3px; height: 3px; }
.star-dot:nth-child(14) { top: 40%; left: 55%; animation-delay: 1.7s; }
.star-dot:nth-child(15) { top: 25%; left: 65%; animation-delay: 0.4s; }
.star-dot:nth-child(16) { top: 70%; left: 15%; animation-delay: 1.3s; width: 3px; height: 3px; }
.star-dot:nth-child(17) { top: 85%; left: 75%; animation-delay: 0.7s; }
.star-dot:nth-child(18) { top: 12%; left: 95%; animation-delay: 1.6s; }
.star-dot:nth-child(19) { top: 90%; left: 45%; animation-delay: 0.1s; width: 3px; height: 3px; }
.star-dot:nth-child(20) { top: 8%; left: 5%; animation-delay: 1.9s; }

@keyframes twinkle {
    0%, 100% { opacity: 0.2; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.5); }
}

/* ===== NAVBAR ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(12px);
    transition: all 0.5s ease;
    border-bottom: 1px solid transparent;
}

.light-mode .navbar {
    background: rgba(253, 246, 227, 0.85);
    border-bottom-color: var(--border-light);
}

.dark-mode .navbar {
    background: rgba(13, 13, 26, 0.85);
    border-bottom-color: var(--border-dark);
}

.logo {
    font-family: var(--font-title);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-decoration: none;
    transition: opacity 0.3s;
}

.light-mode .logo {
    color: var(--accent-gold-dark);
}

.dark-mode .logo {
    color: var(--accent-purple-light);
}

.logo:hover {
    opacity: 0.7;
}

.nav-links {
    display: flex;
    gap: 28px;
    align-items: center;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 1px;
}

.nav-links a {
    text-decoration: none;
    transition: opacity 0.3s;
}

.light-mode .nav-links a {
    color: var(--text-light-muted);
}

.dark-mode .nav-links a {
    color: var(--text-dark-muted);
}

.nav-links a:hover {
    opacity: 0.7;
}

.theme-toggle {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background 0.4s;
    border: none;
}

.light-mode .theme-toggle {
    background: var(--border-light);
}

.dark-mode .theme-toggle {
    background: var(--accent-purple);
}

.theme-toggle::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    top: 2px;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.light-mode .theme-toggle::after {
    background: var(--accent-gold);
    left: 2px;
    box-shadow: 0 0 8px rgba(201, 168, 76, 0.5);
}

.dark-mode .theme-toggle::after {
    background: #e8e0d0;
    left: 22px;
    box-shadow: 0 0 12px rgba(123, 104, 238, 0.6);
}

/* ===== CONTENEDOR PRINCIPAL ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 100px 40px 40px;
    position: relative;
    z-index: 1;
    gap: 0;
    max-width: 1100px;
    margin: 0 auto;
}

/* ===== PANEL LATERAL ===== */
.side-panel {
    flex: 0 0 380px;
    min-height: 520px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 40px;
    text-align: center;
    position: relative;
    border-radius: 12px 0 0 12px;
    transition: all 0.5s ease;
}

.light-mode .side-panel {
    background: linear-gradient(135deg, #3d2317, #5a3525, #3d2317);
    box-shadow: 0 20px 60px var(--shadow-light), inset 0 0 30px rgba(0, 0, 0, 0.3);
    border: 2px solid #6b4423;
    border-right: none;
}

.dark-mode .side-panel {
    background: linear-gradient(135deg, #0a0a1a, #1a1a3a, #0a0a1a);
    box-shadow: 0 20px 60px var(--shadow-dark), inset 0 0 30px rgba(123, 104, 238, 0.1);
    border: 2px solid #3a3a5c;
    border-right: none;
}

.side-ornament {
    width: 80px;
    height: 80px;
    border: 2px solid;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    position: relative;
}

.light-mode .side-ornament {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.dark-mode .side-ornament {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

.side-ornament::before,
.side-ornament::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    border: 1px solid;
}

.light-mode .side-ornament::before,
.light-mode .side-ornament::after {
    border-color: var(--accent-gold);
}

.dark-mode .side-ornament::before,
.dark-mode .side-ornament::after {
    border-color: var(--accent-purple);
}

.side-ornament::before {
    width: 60px;
    height: 60px;
}

.side-ornament::after {
    width: 40px;
    height: 40px;
}

.side-ornament svg {
    width: 24px;
    height: 24px;
    z-index: 2;
}

.side-title {
    font-family: var(--font-title);
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 4px;
    line-height: 1.3;
    margin-bottom: 24px;
}

.light-mode .side-title {
    color: var(--accent-gold);
}

.dark-mode .side-title {
    color: var(--accent-purple-light);
}

.side-quote {
    font-family: var(--font-body);
    font-size: 1rem;
    font-style: italic;
    line-height: 1.6;
    opacity: 0.7;
    max-width: 280px;
}

.light-mode .side-quote {
    color: #d4b896;
}

.dark-mode .side-quote {
    color: #a090c0;
}

.side-line {
    width: 60px;
    height: 1px;
    margin: 24px 0;
}

.light-mode .side-line {
    background: var(--accent-gold);
}

.dark-mode .side-line {
    background: var(--accent-purple);
}

.side-authors {
    font-family: var(--font-body);
    font-size: 0.85rem;
    letter-spacing: 2px;
    opacity: 0.5;
}

.light-mode .side-authors {
    color: #d4b896;
}

.dark-mode .side-authors {
    color: #a090c0;
}

/* ===== FORMULARIOS ===== */
.forms-container {
    flex: 1;
    min-height: 520px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 0 12px 12px 0;
    transition: all 0.5s ease;
}

.light-mode .forms-container {
    background: var(--bg-paper);
    box-shadow: 0 20px 60px var(--shadow-light);
    border: 2px solid var(--border-light);
    border-left: none;
}

.dark-mode .forms-container {
    background: var(--bg-dark-card);
    box-shadow: 0 20px 60px var(--shadow-dark);
    border: 2px solid var(--border-dark);
    border-left: none;
}

.form-box {
    width: 100%;
    max-width: 360px;
    padding: 40px;
    animation: fadeInUp 0.5s ease both;
}

.form-box.hidden {
    display: none;
}

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

.form-title {
    font-family: var(--font-title);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 8px;
    text-align: center;
}

.light-mode .form-title {
    color: var(--text-light);
}

.dark-mode .form-title {
    color: var(--text-dark);
}

.form-subtitle {
    font-family: var(--font-body);
    font-size: 1rem;
    text-align: center;
    margin-bottom: 32px;
    opacity: 0.7;
}

.light-mode .form-subtitle {
    color: var(--text-light-muted);
}

.dark-mode .form-subtitle {
    color: var(--text-dark-muted);
}

/* ===== INPUTS ===== */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.light-mode .input-group label {
    color: var(--text-light-muted);
}

.dark-mode .input-group label {
    color: var(--text-dark-muted);
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 6px;
    border: 1px solid;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    transition: all 0.3s ease;
    outline: none;
    background: transparent;
}

.light-mode .input-group input {
    border-color: var(--border-light);
    color: var(--text-light);
}

.dark-mode .input-group input {
    border-color: var(--border-dark);
    color: var(--text-dark);
}

.light-mode .input-group input::placeholder {
    color: rgba(107, 78, 61, 0.4);
}

.dark-mode .input-group input::placeholder {
    color: rgba(160, 144, 128, 0.4);
}

.light-mode .input-group input:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.15);
}

.dark-mode .input-group input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(123, 104, 238, 0.15);
}

.forgot-link {
    display: inline-block;
    margin-top: 6px;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    text-decoration: none;
    transition: opacity 0.3s;
}

.light-mode .forgot-link {
    color: var(--accent-gold-dark);
}

.dark-mode .forgot-link {
    color: var(--accent-purple-light);
}

.forgot-link:hover {
    opacity: 0.7;
}

/* ===== BOTON SUBMIT ===== */
.btn-submit {
    width: 100%;
    padding: 16px;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
}

.light-mode .btn-submit {
    background: var(--accent-gold-dark);
    color: #fff;
    box-shadow: 0 4px 20px rgba(201, 168, 76, 0.3);
}

.dark-mode .btn-submit {
    background: var(--accent-purple);
    color: #fff;
    box-shadow: 0 4px 20px rgba(123, 104, 238, 0.3);
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

/* ===== DIVIDER ===== */
.form-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    font-family: var(--font-body);
    font-size: 0.85rem;
    opacity: 0.5;
}

.light-mode .form-divider {
    color: var(--text-light-muted);
}

.dark-mode .form-divider {
    color: var(--text-dark-muted);
}

.form-divider::before,
.form-divider::after {
    content: '';
    flex: 1;
    height: 1px;
}

.light-mode .form-divider::before,
.light-mode .form-divider::after {
    background: var(--border-light);
}

.dark-mode .form-divider::before,
.dark-mode .form-divider::after {
    background: var(--border-dark);
}

.form-divider span {
    padding: 0 16px;
}

/* ===== SWITCH ===== */
.switch-text {
    text-align: center;
    font-family: var(--font-body);
    font-size: 0.95rem;
}

.light-mode .switch-text {
    color: var(--text-light-muted);
}

.dark-mode .switch-text {
    color: var(--text-dark-muted);
}

.switch-btn {
    background: none;
    border: none;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    padding: 0;
    transition: opacity 0.3s;
}

.light-mode .switch-btn {
    color: var(--accent-gold-dark);
}

.dark-mode .switch-btn {
    color: var(--accent-purple-light);
}

.switch-btn:hover {
    opacity: 0.7;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .login-wrapper {
        flex-direction: column;
        padding: 100px 20px 40px;
    }

    .side-panel {
        flex: none;
        width: 100%;
        min-height: auto;
        padding: 40px 30px;
        border-radius: 12px 12px 0 0;
        border-right: 2px solid;
    }

    .light-mode .side-panel {
        border-right-color: #6b4423;
    }

    .dark-mode .side-panel {
        border-right-color: #3a3a5c;
    }

    .forms-container {
        flex: none;
        width: 100%;
        min-height: auto;
        border-radius: 0 0 12px 12px;
        border-left: 2px solid;
        border-top: none;
    }

    .light-mode .forms-container {
        border-left-color: var(--border-light);
    }

    .dark-mode .forms-container {
        border-left-color: var(--border-dark);
    }

    .side-title {
        font-size: 1.4rem;
    }

    .side-quote {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .navbar {
        padding: 12px 16px;
    }

    .logo {
        font-size: 1.1rem;
    }

    .nav-links {
        gap: 16px;
    }

    .form-box {
        padding: 30px 20px;
    }

    .side-panel {
        padding: 30px 20px;
    }

    .side-title {
        font-size: 1.2rem;
    }
}

/* ===== BOTON GOOGLE ===== */
.social-login {
    margin-top: 8px;
}

.btn-google {
    width: 100%;
    padding: 14px 16px;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: transparent;
}

.light-mode .btn-google {
    border-color: var(--border-light);
    color: var(--text-light);
}

.dark-mode .btn-google {
    border-color: var(--border-dark);
    color: var(--text-dark);
}

.light-mode .btn-google:hover {
    background: rgba(201, 168, 76, 0.05);
    border-color: var(--accent-gold);
}

.dark-mode .btn-google:hover {
    background: rgba(123, 104, 238, 0.05);
    border-color: var(--accent-purple);
}

.google-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.error-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 24px;
    border-radius: 8px;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 16px;
    animation: slideDown 0.3s ease;
}

.light-mode .error-toast {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.dark-mode .error-toast {
    background: #2d1f1f;
    color: #ef9a9a;
    border: 1px solid #5c3a3a;
}

.error-toast button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.6;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== PREVENT FLASH: Tema oscuro aplicado en <html> antes de que body cargue ===== */
html.theme-dark {
  background: #0d0d1a; /* color de fondo oscuro */
}

html.theme-dark body {
  background: #0d0d1a;
  color: #607ec9;
}

/* ===== CAMPOS DE USERNAME ===== */
.field-hint {
    font-size: 0.75rem;
    opacity: 0.6;
    font-weight: 400;
    display: block;
    margin-top: 2px;
}

.field-hint span {
    color: var(--accent-gold-dark, #8b5a2b);
    font-weight: 600;
}

.dark-mode .field-hint span {
    color: var(--accent-purple, #7b68ee);
}

.input-hint {
    font-size: 0.75rem;
    margin-top: 4px;
    display: block;
    min-height: 18px;
    transition: all 0.2s;
}

.input-hint.error {
    color: #c62828;
}

.input-hint.success {
    color: #2e7d32;
}

.dark-mode .input-hint.success {
    color: #4caf50;
}

/* ===== RESPONSIVE MÓVIL OPTIMIZADO ===== */
@media(max-width:900px){
    .login-wrapper{flex-direction:column;padding:80px 16px 24px;gap:0}
    .side-panel{flex:none;width:100%;min-height:auto;padding:32px 24px;border-radius:12px 12px 0 0;border-right:none !important}
    .forms-container{flex:none;width:100%;min-height:auto;border-radius:0 0 12px 12px;border-left:none !important;border-top:none !important;padding:24px 16px}
    .side-title{font-size:1.3rem}
    .side-quote{font-size:.85rem}
    .form-box{padding:24px 16px}
    .form-title{font-size:1.2rem}
}

@media(max-width:480px){
    .navbar{padding:10px 16px}
    .logo{font-size:1.1rem}
    .nav-links{gap:12px;font-size:.7rem}
    .side-panel{padding:24px 16px}
    .side-ornament{width:60px;height:60px}
    .side-title{font-size:1.1rem}
    .form-box{padding:20px 12px}
    .input-group input{padding:12px 14px;font-size:.85rem}
    .btn-submit{padding:14px;font-size:.8rem}
    .btn-google{padding:12px;font-size:.8rem}
    .switch-text{font-size:.85rem}
}