/* ==================== LOGIN — SISTEMA BOMBEROS ==================== */

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

:root {
    --rojo:        #c0392b;
    --rojo-hover:  #a93226;
    --rojo-oscuro: #7b1414;
    --rojo-deep:   #1a0505;
    --dorado:      #c8942a;
    --dorado-claro:#e5b84a;
    --fondo:       #0e0e0e;
    --panel-brand: #120404;
    --panel-form:  #111111;
    --borde:       #252525;
    --texto:       #f0f0f0;
    --texto-sub:   #888888;
    --input-bg:    #1c1c1c;
    --input-foco:  #222222;
    --error:       #ff4545;
    --exito:       #2ecc71;
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--fondo);
    -webkit-font-smoothing: antialiased;
}

/* ===== LAYOUT SPLIT ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
}

.login-split {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* ===== PANEL IZQUIERDO: BRANDING ===== */
.brand-panel {
    width: 420px;
    flex-shrink: 0;
    background: rgba(10, 2, 2, 0.82);
    backdrop-filter: blur(2px);
    border-right: 1px solid rgba(200, 148, 42, 0.15);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.brand-panel-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 60px 40px;
    gap: 32px;
    position: relative;
    z-index: 1;
}

/* Decoración de esquina */
.brand-corner-deco {
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    height: 120px;
    border-bottom-left-radius: 100%;
    background: rgba(200, 148, 42, 0.05);
    border: 1px solid rgba(200, 148, 42, 0.1);
    pointer-events: none;
}

.brand-corner-deco::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: -1px;
    width: 80px;
    height: 80px;
    border-bottom-left-radius: 100%;
    background: rgba(200, 148, 42, 0.04);
    border: 1px solid rgba(200, 148, 42, 0.08);
}

/* ---- Escudo / Logo ---- */
.brand-emblem {
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-shield {
    width: 148px;
    height: auto;
    filter: drop-shadow(0 8px 32px rgba(192, 57, 43, 0.35))
            drop-shadow(0 2px 8px rgba(0,0,0,0.6));
}

/* Logo real de la compañía */
.brand-logo-img {
    width: 148px;
    height: 148px;
    object-fit: contain;
    filter: drop-shadow(0 8px 32px rgba(0,0,0,0.6));
}

.brand-shield-hidden {
    display: none;
}

/* ---- Textos de branding ---- */
.brand-text {
    text-align: center;
}

.brand-tag {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--dorado);
    text-transform: uppercase;
    margin-bottom: 10px;
    opacity: 0.9;
}

.brand-name {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--texto);
    line-height: 1.25;
    margin-bottom: 16px;
    letter-spacing: -0.3px;
}

.brand-motto {
    font-size: 0.85rem;
    color: var(--texto-sub);
    line-height: 1.6;
    font-weight: 400;
}

/* ---- Footer de branding ---- */
.brand-footer-text {
    margin-top: 12px;
    padding-top: 24px;
    border-top: 1px solid rgba(200, 148, 42, 0.15);
    width: 100%;
    text-align: center;
}

.brand-footer-text span {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(200, 148, 42, 0.5);
}

/* ===== PANEL DERECHO: FORMULARIO ===== */
.form-panel {
    flex: 1;
    background: rgba(17, 17, 17, 0.88);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 40px;
}

.form-panel-inner {
    width: 100%;
    max-width: 380px;
}

/* ---- Cabecera del form ---- */
.form-header {
    margin-bottom: 36px;
}

.form-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--texto);
    letter-spacing: -0.4px;
    margin-bottom: 6px;
}

.form-subtitle {
    font-size: 0.875rem;
    color: var(--texto-sub);
}

/* ===== FORMULARIO ===== */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--texto-sub);
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

/* ---- Input con icono ---- */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: #444;
    display: flex;
    pointer-events: none;
    transition: color 0.2s;
}

.input-icon svg {
    width: 16px;
    height: 16px;
}

.form-input {
    width: 100%;
    padding: 13px 16px 13px 44px;
    background: var(--input-bg);
    border: 1.5px solid var(--borde);
    border-radius: 10px;
    color: var(--texto);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.form-input::placeholder {
    color: #3a3a3a;
}

.form-input:focus {
    border-color: var(--rojo);
    background: var(--input-foco);
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12);
}

.form-input:focus ~ .input-icon,
.input-wrapper:focus-within .input-icon {
    color: var(--rojo);
}

/* ---- Toggle contraseña ---- */
.toggle-password {
    position: absolute;
    right: 13px;
    background: none;
    border: none;
    cursor: pointer;
    color: #444;
    padding: 4px;
    line-height: 0;
    transition: color 0.2s;
}

.toggle-password:hover {
    color: var(--texto-sub);
}

.toggle-password svg {
    width: 17px;
    height: 17px;
}

/* Password input tiene padding también a la derecha */
#password {
    padding-right: 44px;
}

/* ---- Alertas ---- */
.form-alert {
    display: none;
    padding: 11px 14px;
    border-radius: 8px;
    font-size: 0.855rem;
    font-weight: 500;
    line-height: 1.4;
}

.form-alert.show {
    display: block;
}

.error-alert {
    background: rgba(255, 69, 58, 0.1);
    color: var(--error);
    border: 1px solid rgba(255, 69, 58, 0.25);
}

/* alias para compatibilidad con auth_django.js */
.error-message { background: rgba(255, 69, 58, 0.1); color: var(--error); border: 1px solid rgba(255, 69, 58, 0.25); }
.success-message { background: rgba(46, 204, 113, 0.1); color: var(--exito); border: 1px solid rgba(46, 204, 113, 0.25); }
.error-message.show, .success-message.show { display: block; }

.success-alert {
    background: rgba(46, 204, 113, 0.1);
    color: var(--exito);
    border: 1px solid rgba(46, 204, 113, 0.25);
}

/* ---- Botón submit ---- */
.submit-btn {
    width: 100%;
    padding: 14px;
    background: var(--rojo);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 0.2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 6px;
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}

.submit-btn:hover:not(:disabled) {
    background: var(--rojo-hover);
    box-shadow: 0 4px 20px rgba(192, 57, 43, 0.35);
}

.submit-btn:active:not(:disabled) {
    transform: scale(0.985);
}

.submit-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-spinner {
    display: none;
    width: 17px;
    height: 17px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

.submit-btn.loading .btn-spinner { display: inline-block; }
.submit-btn.loading .btn-text    { opacity: 0.75; }

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

/* ---- Divisor ---- */
.form-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 0;
}

.form-divider::before,
.form-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--borde);
}

.form-divider span {
    font-size: 0.78rem;
    color: #3a3a3a;
    font-weight: 500;
}

/* ---- Footer del form ---- */
.form-footer {
    margin-top: 16px;
    text-align: center;
}

.portal-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--texto-sub);
    font-size: 0.85rem;
    text-decoration: none;
    padding: 10px 20px;
    border: 1px solid var(--borde);
    border-radius: 8px;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    font-weight: 500;
}

.portal-link svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.portal-link:hover {
    color: var(--dorado);
    border-color: rgba(200, 148, 42, 0.35);
    background: rgba(200, 148, 42, 0.06);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 820px) {
    .login-split {
        flex-direction: column;
    }

    .brand-panel {
        width: 100%;
        flex-shrink: 0;
    }

    .brand-panel-inner {
        flex-direction: row;
        padding: 28px 32px;
        gap: 24px;
        align-items: center;
        justify-content: flex-start;
    }

    .brand-corner-deco { display: none; }

    .brand-shield { width: 80px; }

    .brand-text { text-align: left; }
    .brand-tag  { margin-bottom: 4px; }
    .brand-name { font-size: 1.3rem; margin-bottom: 4px; }
    .brand-motto { font-size: 0.78rem; }

    .brand-footer-text { display: none; }

    .form-panel {
        padding: 36px 24px 48px;
    }
}

@media (max-width: 480px) {
    .brand-panel-inner {
        padding: 22px 20px;
        gap: 16px;
    }

    .brand-shield { width: 64px; }
    .brand-name   { font-size: 1.15rem; }

    .form-panel-inner {
        max-width: 100%;
    }

    .form-title { font-size: 1.5rem; }
}

/* ===== CANVAS FUEGO ===== */
#fireCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 1.2s ease;
}

#fireCanvas.visible {
    opacity: 1;
}

.login-screen {
    position: relative;
    z-index: 1;
}

/* ===== PRELOADER ===== */
#preloader {
    position: fixed;
    inset: 0;
    background: #0a0202;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s ease;
}

#preloader.hidden {
    opacity: 0;
    pointer-events: none;
}

.preloader-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.preloader-logo {
    width: 110px;
    height: 110px;
    object-fit: contain;
    filter: drop-shadow(0 0 24px rgba(192,57,43,0.5));
    animation: preloader-pulse 1.4s ease-in-out infinite;
}

@keyframes preloader-pulse {
    0%, 100% { transform: scale(1);   filter: drop-shadow(0 0 20px rgba(192,57,43,0.4)); }
    50%       { transform: scale(1.06); filter: drop-shadow(0 0 36px rgba(192,57,43,0.7)); }
}

.preloader-bar {
    width: 180px;
    height: 3px;
    background: rgba(255,255,255,0.08);
    border-radius: 99px;
    overflow: hidden;
}

.preloader-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--rojo), var(--dorado));
    border-radius: 99px;
    transition: width 0.15s ease;
}

.preloader-text {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.3);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 0;
}

/* ===== COMPATIBILIDAD auth_django.js ===== */
.login-screen.hidden { display: none; }
.loading { pointer-events: none; }
