/**
 * ESTILOS DEL PANEL DE CASETEROS
 * Contiene el diseño, colores y responsividad para las vistas de login y panel.
 */

/* =========================================================
   1. VARIABLES DE COLORES (Ayuntamiento)
   ========================================================= */
:root {
    --primary: #0B63A5;      /* Azul Oficial */
    --primary-hover: #0A5A99;
    --dark: #042A4A;         /* Azul Oscuro */
    --active: #FFB500;       /* Amarillo Oficial */
    --bg: #F5F7FA;           /* Fondo gris claro */
    --surface: #FFFFFF;      /* Blanco para tarjetas */
    --text: #1F2937;         /* Texto general */
    --text-mut: #6B7280;     /* Texto secundario */
    --border: #E5E7EB;       /* Bordes */
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

/* =========================================================
   2. REGLAS BASE Y VISTAS
   ========================================================= */
body { background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; margin: 0; font-family: 'Inter', sans-serif; overflow: hidden; }

/* Vistas Ocultas/Visibles */
.view-section, #panelView, #loginView { display: none; opacity: 0; transition: opacity 0.4s; flex-direction: column; height: 100vh; width: 100%; overflow: hidden; }
.view-section.active, #panelView.active, #loginView.active { display: flex; opacity: 1; }

/* Contenedor central (Login) y Panel principal */
.authBody { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: hidden; }

.panelMain { 
    padding: 20px 4%; 
    max-width: 800px; 
    margin: 0 auto; 
    width: 100%; 
    flex: 1; 
    box-sizing: border-box; 
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panelContainer {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 100%;
}

.panelBody {
    flex: 1;
    overflow-y: auto;
    padding: 25px 35px;
}

/* =========================================================
   3. CABECERA Y PIE (Diseño Institucional)
   ========================================================= */
.adminHeader, .adminFooter { background: var(--primary); color: var(--surface); padding: 10px 4%; display: flex; justify-content: space-between; align-items: center; }
.adminHeader { box-shadow: var(--shadow); min-height: 60px; }
.adminFooter { padding: 15px 0; margin-top: auto; }

.adminHeaderLogo img { height: 75px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)); transition: 0.3s; }
.adminHeaderLogo img:hover { transform: scale(1.02); }
.adminHeaderTitle h1 { font-family: 'Inter', sans-serif; font-size: 1.5rem; font-weight: 500; text-transform: uppercase; margin: 0; color: var(--surface); }

.footerContent { width: 100%; padding: 0 2%; display: flex; justify-content: space-between; align-items: center; }
.footerLeft { display: flex; align-items: center; gap: 10px; }
.footerIcon { height: 24px; opacity: 0.9; }
.footerHandle { font-size: 0.85rem; font-weight: 500; }
.copyrightText { font-size: 0.8rem; opacity: 0.8; }

/* =========================================================
   4. TARJETAS Y CONTENEDORES
   ========================================================= */
.privateCard { width: 100%; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); box-sizing: border-box; overflow: hidden; }
.loginContainer {
    max-width: 460px;
    padding: 40px 44px;
    width: 100%;
    box-sizing: border-box;
    border-radius: 16px !important;
    border: 1px solid rgba(0,0,0,.04) !important;
    box-shadow: 0 8px 30px rgba(0,0,0,.07) !important;
    background: #FFFFFF !important;
    text-align: center;
}

.authLogo {
    max-width: 100px;
    width: 100%;
    height: auto;
    margin: 0 auto 18px;
    display: block;
    object-fit: contain;
}

/* Textos de Login */
.loginHeader { text-align: center; margin-bottom: 0; }
.loginTitle { color: #186daf !important; font-size: 1.6rem !important; font-weight: 800 !important; margin-top: 0; margin-bottom: 4px !important; letter-spacing: -.5px !important; }
.loginSubtitle { color: #64748B !important; font-size: 0.9rem !important; font-weight: 500 !important; margin-bottom: 24px !important; opacity: 1 !important; }

/* Ajustes premium y compactos para el formulario de login */
.loginContainer .formGroup { margin-bottom: 16px; text-align: left; }

.loginContainer .formGroup label {
    display: block !important;
    margin-bottom: 4px !important;
    font-weight: 600 !important;
    font-size: .78rem !important;
    text-transform: uppercase !important;
    letter-spacing: .4px !important;
    color: #186daf !important;
    opacity: 1 !important;
}

.loginContainer .inputControl {
    width: 100% !important;
    padding: 13px 15px !important;
    background: #f8fafc !important;
    border: 2px solid transparent !important;
    border-radius: 8px !important;
    outline: 0 !important;
    font-family: 'Inter', sans-serif !important;
    font-size: .95rem !important;
    font-weight: 500 !important;
    color: #333 !important;
    transition: .3s cubic-bezier(.4,0,.2,1) !important;
    box-sizing: border-box !important;
}

.loginContainer .inputControl:focus {
    background: #FFFFFF !important;
    border-color: #0B63A5 !important;
    box-shadow: 0 0 0 3px rgba(11,99,165,.1) !important;
}

.loginContainer .inputControl:disabled {
    background: #f1f5f9 !important;
    color: #64748B !important;
    cursor: not-allowed !important;
    border-color: #E2E8F0 !important;
}

.loginContainer .submitBtn {
    width: 100% !important;
    background: #0B63A5 !important;
    color: #FFFFFF !important;
    border: none !important;
    padding: 12px !important;
    border-radius: 8px !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: .3s cubic-bezier(.4,0,.2,1) !important;
    font-family: 'Inter', sans-serif !important;
    margin-top: 8px !important;
    box-shadow: 0 4px 15px rgba(11,99,165,.25) !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    text-transform: uppercase !important;
}

.loginContainer .submitBtn:hover {
    background: #0A5A99 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 20px rgba(11,99,165,.35) !important;
}

.loginContainer .submitBtn:active {
    background: #FFB500 !important;
    color: #042A4A !important;
    transform: scale(.98) !important;
    box-shadow: 0 4px 12px rgba(255,181,0,.4) !important;
}

.loginContainer .statusMsg { margin-top: 15px; padding: 12px 15px; }

/* Textos del Panel */
.panelTitle { color: var(--dark); font-size: 1.5rem; font-weight: 700; display: flex; align-items: center; gap: 12px; margin: 0 0 25px; border-bottom: 1px solid var(--border); padding-bottom: 15px; }
.panelTitle i { color: var(--primary); }

/* Tarjeta informativa azul clara */
.infoCard { background: #f8fafc; border-radius: 12px; padding: 20px 25px; margin-bottom: 30px; display: flex; align-items: center; gap: 18px; border: 1px solid var(--border); }
.infoCardIcon { background: var(--surface); width: 55px; height: 55px; border-radius: 12px; display: flex; justify-content: center; align-items: center; color: var(--primary); font-size: 1.6rem; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.infoCardText h3 { color: var(--dark); font-size: 1.15rem; margin-bottom: 6px; font-weight: 700; }
.infoCardText p { color: var(--text-mut); font-size: 0.95rem; margin: 0; }

/* =========================================================
   5. FORMULARIOS E INPUTS
   ========================================================= */
.formGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.formGroup { margin-bottom: 22px; text-align: left; }
.formGroup.full-width { grid-column: 1 / -1; }
.formGroup label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 0.9rem; text-transform: uppercase; color: var(--dark); }
.loginContainer .formGroup label { color: #2F80C1; } /* Color especial para login */

/* Contenedor del Input con Icono */
.inputWrapper { position: relative; }
.inputWrapper i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 1.1rem; transition: 0.3s; }
.loginContainer .inputWrapper i { color: #2F80C1; opacity: 0.7; }

/* Campos de texto */
.inputControl { width: 100%; padding: 14px 15px 14px 45px; background: #f8fafc; border: 2px solid transparent; border-radius: 10px; font-family: 'Inter', sans-serif; font-size: 1rem; color: var(--text); box-sizing: border-box; transition: 0.3s; }
.inputControl:focus { background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 4px rgba(11,99,165,0.1); outline: none; }
.inputControl:focus + i { color: var(--primary); }
.inputControl:disabled { background: #f1f5f9; color: var(--text-mut); cursor: not-allowed; border-color: var(--border); }

/* =========================================================
   6. BOTONES
   ========================================================= */
.submitBtn { width: 100%; padding: 16px; background: var(--primary); color: var(--surface); border: none; border-radius: 10px; font-size: 1.1rem; font-weight: 700; cursor: pointer; transition: 0.3s; display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 15px; box-shadow: 0 4px 15px rgba(11,99,165,0.25); box-sizing: border-box; font-family: 'Inter', sans-serif; }
.submitBtn:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(11,99,165,0.35); }
.submitBtn:active { background: var(--active); color: var(--dark); transform: scale(0.98); }
.submitBtn:disabled { background: #94a3b8; cursor: not-allowed; transform: none; box-shadow: none; }

.logoutBtn { background: #D93025; color: var(--surface); border: none; padding: 10px 18px; border-radius: 8px; cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; font-size: 0.95rem; box-shadow: 0 4px 15px rgba(217,48,37,0.25); font-family: 'Inter', sans-serif; }
.logoutBtn:hover { background: #B3261E; transform: translateY(-2px); }

/* =========================================================
   7. MENSAJES Y ANIMACIONES
   ========================================================= */
.statusMsg { padding: 14px 20px; border-radius: 10px; margin-top: 20px; display: none; text-align: center; font-weight: 600; font-size: 0.95rem; animation: slideUp 0.3s ease; box-sizing: border-box; width: 100%; }
.statusMsg.success { color: #0f5132; background: #d1e7dd; border: 1px solid #badbcc; }
.statusMsg.error { color: #842029; background: #f8d7da; border: 1px solid #f5c2c7; }
.statusMsg.cors-warning { background: #fff3cd; color: #856404; border-color: #ffeeba; text-align: left; padding: 15px; }

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

/* Efecto de carga (Gris Parpadeante) */
.skeleton { background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%; color: transparent!important; animation: shimmer 1.5s infinite; }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* =========================================================
   8. RESPONSIVIDAD MÓVIL
   ========================================================= */
@media (max-width: 992px) {
    .adminHeader { min-height: 60px; padding: 10px 4%; }
    .adminHeaderLogo img { height: 75px; }
}

@media (max-width: 650px) {
    /* Ajustes generales del scroll en móvil (Bloqueado a 100vh/100dvh para scroll interno) */
    body.view-panel, body.view-login {
        overflow: hidden !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
    }

    /* Diseño a 1 columna en móviles */
    .formGrid { grid-template-columns: 1fr; gap: 0; }
    
    /* Login Ajustado sin Scroll en móvil */
    #loginView.active {
        height: 100vh !important;
        max-height: 100vh !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        opacity: 1 !important;
    }
    #loginView.active .authBody {
        padding: 10px !important;
        flex: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        overflow: hidden !important;
    }
    .loginContainer {
        padding: 20px 18px !important;
        border-radius: 12px !important;
        max-height: 80vh !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        box-sizing: border-box !important;
        margin: 0 auto !important;
        box-shadow: 0 8px 30px rgba(0,0,0,.07) !important;
        border: 1px solid rgba(0,0,0,.04) !important;
    }
    .loginHeader {
        margin-bottom: 0 !important;
    }
    .loginHeader .authLogo {
        max-width: 50px !important;
        margin-bottom: 8px !important;
    }
    .loginTitle {
        font-size: 1.15rem !important;
        margin-bottom: 2px !important;
        margin-top: 0 !important;
    }
    .loginSubtitle {
        font-size: 0.78rem !important;
        margin-bottom: 12px !important;
    }
    #loginView .formGroup {
        margin-bottom: 10px !important;
    }
    .loginContainer .formGroup label {
        font-size: 0.72rem !important;
        margin-bottom: 3px !important;
    }
    .loginContainer .inputControl {
        padding: 9px 10px !important;
        font-size: 0.85rem !important;
        border-radius: 7px !important;
    }
    .loginContainer .submitBtn {
        padding: 10px !important;
        font-size: 0.9rem !important;
        margin-top: 6px !important;
    }
    
    /* Panel con Scroll interno igual que en escritorio */
    #panelView.active {
        display: flex !important;
        opacity: 1 !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        overflow: hidden !important;
    }
    #panelView .panelMain {
        padding: 10px !important;
        height: 100% !important;
        max-height: 100% !important;
        overflow: hidden !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    #panelView .panelContainer {
        height: 100% !important;
        max-height: 100% !important;
        overflow: hidden !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    #panelView .panelBody {
        padding: 20px 15px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        flex: 1 !important;
    }
    
    /* Cabecera compacta */
    .adminHeader { height: auto; min-height: 60px; }
    .adminHeaderLogo img { height: 62px; }
    .adminHeaderTitle h1 { font-size: 1.15rem; flex-direction: column; text-align: center; }
    .title-sep { display: none !important; }
    .title-part2 { font-size: 0.8rem; opacity: 0.9; }
    
    /* Botón salir móvil (solo icono) */
    .logoutText { display: none !important; }
    .logoutBtn { width: 44px; height: 44px; padding: 0; justify-content: center; }

    /* Footer responsivo y centrado */
    .footerContent {
        flex-direction: column !important;
        gap: 12px !important;
        text-align: center !important;
    }
    .footerLeft {
        justify-content: center !important;
        width: 100% !important;
    }
}

/* =========================================================
   9. ETIQUETAS PREDEFINIDAS (Premium Interactive Badges)
   ========================================================= */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
    padding: 6px 0;
    transition: all 0.3s ease;
}

.tags-container.skeleton {
    pointer-events: none;
    opacity: 0.6;
}

/* Badge táctil e interactivo */
.tag-badge {
    padding: 10px 18px;
    background: #f8fafc;
    border: 2px solid var(--border);
    color: var(--dark);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    user-select: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

/* Efectos de Hover */
.tag-badge:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(11,99,165,0.08);
}

/* Estado Seleccionado / Activo */
.tag-badge.selected {
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    border-color: var(--primary);
    color: var(--surface);
    box-shadow: 0 4px 14px rgba(11,99,165,0.3);
}

.tag-badge.selected:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #1e40af 100%);
    box-shadow: 0 6px 18px rgba(11,99,165,0.4);
    transform: translateY(-2px);
}

.tag-badge:active {
    transform: translateY(0) scale(0.96);
    transition: duration 0.05s;
}
