/* ==========================================================================
   ESTILOS GENERALES Y DISEÑO DE INTERFAZ (CSS)
   Sistema: Atención Ventanilla Virtual
   Municipalidad de Villa Nueva, Guatemala
   ========================================================================== */

/* 1. CONFIGURACIÓN DEL SISTEMA DE DISEÑO */
:root {
    --primary: #0d39b8;
    --primary-dark: #072685;
    --secondary: #ffb300;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #001b4d;
    --light: #f8fafc;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 64px;
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Estilos de Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--light);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* 2. PÁGINAS DE AUTENTICACIÓN (GLASSMORPHISM) */
.auth-body {
    background: linear-gradient(135deg, #001b4d 0%, #0d39b8 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
}

/* Decoraciones de fondo */
.auth-body::before, .auth-body::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    z-index: 0;
}
.auth-body::before {
    background: radial-gradient(circle, rgba(255, 179, 0, 0.15) 0%, transparent 70%);
    top: 10%;
    left: 10%;
}
.auth-body::after {
    background: radial-gradient(circle, rgba(13, 57, 184, 0.15) 0%, transparent 70%);
    bottom: 10%;
    right: 10%;
}

.auth-wrapper {
    width: 100%;
    max-width: 440px;
    z-index: 1;
}

.auth-card {
    background: rgba(30, 41, 59, 0.45);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: var(--shadow-lg);
    color: #ffffff;
}

.auth-title {
    font-size: 26px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 5px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--secondary);
    font-weight: 500;
    margin-bottom: 20px;
}

.auth-link {
    color: var(--secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.auth-link:hover {
    color: #ffffff;
    text-shadow: 0 0 8px rgba(6, 182, 212, 0.5);
}

.logo-box {
    margin: 0 auto 20px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 65%;
    max-width: 280px;
    height: auto;
}

.logo-img {
    width: 100%;
    height: auto;
    max-height: 120px;
    object-fit: contain;
}

.logo-fallback {
    font-size: 48px;
    color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90px;
    height: 90px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    box-shadow: var(--shadow);
}

/* 3. LAYOUT DEL PANEL DE CONTROL (DASHBOARD) */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar Fijo */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--dark);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: var(--transition);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

/* Logo de Sidebar */
.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #ffffff;
}

.sidebar-brand i {
    font-size: 24px;
    color: var(--secondary);
}

.sidebar-brand span {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.5px;
}

/* Menú de Navegación */
.sidebar-menu {
    flex: 1;
    list-style: none;
    padding: 20px 0;
    margin: 0;
    overflow-y: auto;
}

.menu-item {
    margin-bottom: 5px;
    padding: 0 15px;
    position: relative;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 8px;
    transition: var(--transition);
    white-space: nowrap;
    overflow: hidden;
}

.menu-link i {
    font-size: 18px;
    width: 24px;
    margin-right: 12px;
    transition: var(--transition);
}

.menu-link span {
    font-size: 14px;
    font-weight: 500;
}

/* Estados Hover y Activo */
.menu-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.05);
}

.menu-item.active .menu-link {
    color: var(--dark) !important;
    background: var(--secondary) !important;
    box-shadow: 0 4px 12px rgba(255, 179, 0, 0.25);
    font-weight: 600;
}

.menu-item.active .menu-link i {
    color: var(--dark) !important;
}

/* Sidebar Footer (Usuario activo) */
.sidebar-footer {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background-color: rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    white-space: nowrap;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
}

.user-role-badge {
    font-size: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--secondary);
    padding: 2px 6px;
    border-radius: 4px;
    width: fit-content;
    font-weight: 700;
    text-transform: uppercase;
}

/* Contenedor de Contenido Principal */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: var(--transition);
}

/* Header Horizontal */
.header-bar {
    height: var(--header-height);
    background-color: #ffffff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: justify;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.toggle-sidebar-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-sidebar-btn:hover {
    background-color: var(--light);
}

.header-clock {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Área de Trabajo Principal */
.content-wrapper {
    padding: 24px;
    flex: 1;
    background-color: var(--light);
}

.breadcrumb-container {
    margin-bottom: 20px;
}

.breadcrumb-item a {
    color: var(--primary);
    text-decoration: none;
}

/* 4. COMPONENTES DEL SISTEMA DE DISEÑO */

/* Tarjetas (Cards) */
.card-custom {
    background-color: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
    transition: var(--transition);
}

.card-custom:hover {
    box-shadow: var(--shadow-lg);
}

.card-title-custom {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title-custom i {
    color: var(--primary);
}

/* Botones con ripple y gradientes */
.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    color: #ffffff;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 8px;
    transition: var(--transition);
}

.btn-primary-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 57, 184, 0.3);
}

.btn-primary-custom:active {
    transform: translateY(0);
}

.btn-secondary-custom {
    background: linear-gradient(135deg, var(--secondary) 0%, #ff8f00 100%);
    border: none;
    color: var(--dark);
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 8px;
    transition: var(--transition);
}

.btn-secondary-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 179, 0, 0.3);
}

/* Inputs de Formulario (Validaciones) */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 10px 14px;
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

/* Estados de Validación Avanzados */
.form-control.is-valid, .form-select.is-valid {
    border-color: var(--success) !important;
    background-image: none !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15) !important;
}

.form-control.is-invalid, .form-select.is-invalid {
    border-color: var(--danger) !important;
    background-image: none !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
    animation: shake 0.4s ease;
}

.feedback-message {
    font-size: 12px;
    color: var(--danger);
    margin-top: 5px;
    font-weight: 500;
}

/* Iconos integrados en inputs de login */
.input-group-text {
    background-color: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    color: #94a3b8;
    border-radius: 8px 0 0 8px;
}

.auth-card .input-group-text {
    background-color: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255,255,255,0.6);
}

.auth-card .form-control {
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border-radius: 0 8px 8px 0;
}

.auth-card .form-control:focus {
    background-color: rgba(0, 0, 0, 0.3);
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.25);
    color: #ffffff;
}

.auth-card .btn-toggle-pwd {
    border: 1px solid rgba(255, 255, 255, 0.15);
    background-color: rgba(255, 255, 255, 0.07);
    color: rgba(255,255,255,0.6);
    border-radius: 0 8px 8px 0;
}

.auth-card .form-control + .btn-toggle-pwd {
    border-left: none;
}

/* Badges Semánticos */
.badge-custom {
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
}

.badge-admin {
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.badge-operador {
    background-color: rgba(6, 182, 212, 0.1);
    color: var(--secondary);
}

.badge-active {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-inactive {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Tablas Modernas */
.table-custom {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.table-custom th {
    background-color: var(--dark) !important;
    color: #ffffff !important;
    font-weight: 600;
    font-size: 13px;
    padding: 14px 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
}

.table-custom th:first-child {
    border-radius: 8px 0 0 0;
}

.table-custom th:last-child {
    border-radius: 0 8px 0 0;
}

.table-custom td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    background-color: #ffffff;
    vertical-align: middle;
}

.table-custom tbody tr:last-child td {
    border-bottom: none;
}

.table-custom tbody tr {
    transition: var(--transition);
}

.table-custom tbody tr:hover td {
    background-color: rgba(37, 99, 235, 0.02);
    cursor: default;
}

/* 5. KPI CARDS DEL DASHBOARD */
.kpi-card {
    background: #ffffff;
    border-radius: var(--border-radius);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.kpi-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background-color: rgba(37, 99, 235, 0.08);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.kpi-data {
    text-align: right;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.kpi-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 6. MICRO-ANIMACIONES */

/* Animación Fade In */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Animación Shake para Inputs Inválidos */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* Skeleton Loader para Cargas Asíncronas */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: loadingSkeleton 1.5s infinite;
    border-radius: 4px;
}

@keyframes loadingSkeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Inputs de Código 2FA */
.pin-input {
    width: 45px;
    height: 55px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    background-color: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 8px !important;
    transition: var(--transition);
}

.pin-input:focus {
    background-color: rgba(0, 0, 0, 0.3) !important;
    border-color: var(--secondary) !important;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.25) !important;
}

/* 7. ADAPTACIÓN RESPONSIVA (COLLAPSED SIDEBAR & MOBILE) */

/* Estado Colapsado en Escritorio */
@media (min-width: 768px) {
    .app-container.sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed);
    }
    
    .app-container.sidebar-collapsed .sidebar-brand span,
    .app-container.sidebar-collapsed .menu-link span,
    .app-container.sidebar-collapsed .sidebar-footer .user-info {
        display: none;
    }
    
    .app-container.sidebar-collapsed .sidebar-header {
        justify-content: center;
        padding: 0;
    }
    
    .app-container.sidebar-collapsed .menu-link {
        justify-content: center;
        padding: 12px;
    }
    
    .app-container.sidebar-collapsed .menu-link i {
        margin-right: 0;
        font-size: 20px;
    }
    
    .app-container.sidebar-collapsed .main-content {
        margin-left: var(--sidebar-collapsed);
    }
    
    .app-container.sidebar-collapsed .sidebar-footer {
        justify-content: center;
        padding: 15px 5px;
    }
}

/* Estilos de Tooltip en Sidebar Colapsado */
.app-container.sidebar-collapsed .menu-link {
    position: relative;
}

/* Adaptación para Pantallas Móviles (< 768px) */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    /* Mostrar Sidebar como cajón (Drawer) al activar clase */
    .app-container.mobile-sidebar-active .sidebar {
        transform: translateX(0);
        box-shadow: 10px 0 25px rgba(0, 0, 0, 0.3);
    }
    
    /* Overlay para oscurecer el fondo en móvil */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0,0,0,0.5);
        z-index: 998;
        display: none;
        backdrop-filter: blur(4px);
    }
    
    .app-container.mobile-sidebar-active .sidebar-overlay {
        display: block;
    }
    
    .pin-input {
        width: 40px;
        height: 50px;
        font-size: 20px;
    }
}

/* Textarea caracteres */
.textarea-counter {
    text-align: right;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Password requirements item color checkmarks */
.requirement-item.valid {
    color: #34d399 !important;
}

.requirement-item.valid i {
    color: #34d399 !important;
}

/* Heatmap de estadística en CSS Grid */
.heatmap-container {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-top: 15px;
}

.heatmap-day-header {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    padding-bottom: 8px;
}

.heatmap-cell {
    height: 40px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #ffffff;
    transition: var(--transition);
}

.heatmap-cell.level-0 { background-color: #f1f5f9; color: var(--text-secondary); }
.heatmap-cell.level-1 { background-color: #dbeafe; color: #1e40af; }
.heatmap-cell.level-2 { background-color: #93c5fd; color: #1e3a8a; }
.heatmap-cell.level-3 { background-color: #3b82f6; color: #ffffff; }
.heatmap-cell.level-4 { background-color: #1d4ed8; color: #ffffff; }

/* 8. ZONAS DE ARRASTRE Y SOLTADO DE ARCHIVOS (DROPZONES) */
.dropzone-container {
    background-color: #ffffff;
    border: 2px dashed var(--border);
    border-radius: var(--border-radius);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.dropzone-container:hover, .dropzone-container.dragover {
    border-color: var(--primary);
    background-color: rgba(37, 99, 235, 0.02);
}

.dropzone-container i {
    color: var(--text-secondary);
    transition: var(--transition);
}

.dropzone-container:hover i, .dropzone-container.dragover i {
    color: var(--primary);
    transform: translateY(-4px);
}

.upload-preview-img {
    max-height: 80px;
    max-width: 100%;
    object-fit: contain;
    border-radius: 6px;
    border: 1px dashed var(--border);
    padding: 5px;
    background-color: #f8fafc;
}

/* 9. CLASES DE UTILIDAD PARA TAMAÑOS DE FUENTE PEQUEÑOS */
.fs-sm { font-size: 0.875rem !important; }
.fs-xs { font-size: 0.75rem !important; }
.fs-xxs { font-size: 0.65rem !important; }

/* 10. SOBREESCRITURAS DE BOOTSTRAP PARA LA PALETA MUNICIPAL */
.btn-primary {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #ffffff !important;
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
    box-shadow: 0 0 0 3px rgba(13, 57, 184, 0.25) !important;
}

.btn-outline-primary {
    color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.btn-outline-primary:hover, .btn-outline-primary:focus, .btn-outline-primary:active {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #ffffff !important;
}

.text-primary {
    color: var(--primary) !important;
}

.bg-primary {
    background-color: var(--primary) !important;
}


