/* ==========================================================================
   VARIABLES DE DISEÑO - TEMA OSCURO PREMIUM (GLASSMORPHISM)
   ========================================================================== */
:root {
    --bg-main: #0b0f19;
    --bg-card: rgba(20, 26, 45, 0.6);
    --bg-sidebar: #060911;
    --border-glass: rgba(255, 255, 255, 0.06);
    --border-glass-hover: rgba(255, 255, 255, 0.12);
    
    /* Colores HSL para Acabado Vibrante */
    --primary: hsl(217, 91%, 60%);       /* Azul eléctrico */
    --primary-glow: rgba(59, 130, 246, 0.25);
    
    --success: #10b981;                  /* Esmeralda */
    --success-glow: rgba(16, 185, 129, 0.2);
    
    --warning: #f59e0b;                  /* Ámbar */
    --warning-glow: rgba(245, 158, 11, 0.2);
    
    --danger: #f43f5e;                   /* Carmesí */
    --danger-glow: rgba(244, 63, 94, 0.2);
    
    --accent: #a855f7;                   /* Púrpura */
    --accent-glow: rgba(168, 85, 247, 0.2);

    /* Textos */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #0f172a;

    /* Transiciones */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Layout */
    --sidebar-width: 260px;
    --header-height: 70px;
}

/* ==========================================================================
   ESTILOS GENERALES
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Outfit', 'Inter', sans-serif;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 10% 20%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(168, 85, 247, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Scrollbars Personalizados */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-glass);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    padding: 24px 16px;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 24px 12px;
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 24px;
}

.logo-icon {
    font-size: 24px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

.logo-text {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff, var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.menu-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition-fast);
    cursor: pointer;
}

.menu-item a i {
    font-size: 18px;
}

.menu-item a:hover, .menu-item.active a {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.menu-item.active a {
    background: linear-gradient(90deg, var(--primary-glow), rgba(255, 255, 255, 0.02));
    border-left: 3px solid var(--primary);
    box-shadow: inset 5px 0 10px rgba(59, 130, 246, 0.05);
}

.user-info-sidebar {
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-info-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info-role {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--accent-glow);
    color: var(--accent);
    align-self: flex-start;
    font-weight: 600;
    text-transform: uppercase;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    background: rgba(244, 63, 94, 0.1);
    color: var(--danger);
    font-weight: 600;
    font-size: 13px;
    border: 1px solid rgba(244, 63, 94, 0.15);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-logout:hover {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 15px var(--danger-glow);
}

/* Contenido Principal */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    min-height: 100vh;
    padding: 30px 40px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Cabecera Principal */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-glass);
}

.header-title h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.header-title p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

/* ==========================================================================
   TARJETAS Y CONTENEDORES (GLASSMORPHISM)
   ========================================================================== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: border-color var(--transition-fast), transform var(--transition-normal);
}

.card:hover {
    border-color: var(--border-glass-hover);
}

/* ==========================================================================
   PANEL DE CONTROL (DASHBOARD)
   ========================================================================== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.metric-icon {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.metric-icon.blue { background: rgba(59, 130, 246, 0.1); color: var(--primary); border: 1px solid rgba(59, 130, 246, 0.2); }
.metric-icon.green { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.metric-icon.amber { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.metric-icon.red { background: rgba(244, 63, 94, 0.1); color: var(--danger); border: 1px solid rgba(244, 63, 94, 0.2); }

.metric-info h3 {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-info p {
    font-size: 24px;
    font-weight: 800;
    margin-top: 4px;
}

/* Gráficos Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    min-height: 320px;
    display: flex;
    flex-direction: column;
}

.chart-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-container {
    flex-grow: 1;
    position: relative;
    height: 250px;
}

/* ==========================================================================
   TABLAS PREMIUM
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
}

.table-premium {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.table-premium th {
    background: rgba(255, 255, 255, 0.02);
    padding: 16px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-glass);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.table-premium td {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-main);
    vertical-align: middle;
}

.table-premium tr:hover td {
    background: rgba(255, 255, 255, 0.015);
}

/* Insignias de Estado (Badges) */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-urgent { background: rgba(244, 63, 94, 0.1); color: var(--danger); border: 1px solid rgba(244, 63, 94, 0.2); box-shadow: 0 0 10px var(--danger-glow); }
.badge-priority { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); box-shadow: 0 0 10px var(--warning-glow); }
.badge-secondary { background: rgba(59, 130, 246, 0.1); color: var(--primary); border: 1px solid rgba(59, 130, 246, 0.2); }

.badge-pending { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-authorized { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-rejected { background: rgba(244, 63, 94, 0.1); color: var(--danger); border: 1px solid rgba(244, 63, 94, 0.2); }
.badge-acquired { background: rgba(168, 85, 247, 0.1); color: var(--accent); border: 1px solid rgba(168, 85, 247, 0.2); }

/* ==========================================================================
   FORMULARIOS MODERNOS
   ========================================================================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

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

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition-fast);
    outline: none;
    width: 100%;
}

.form-control:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: 0 0 10px var(--primary-glow);
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

select.form-control option {
    background: #0f172a;
    color: #ffffff;
}

/* ==========================================================================
   BOTONES E INTERACCIONES
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
    outline: none;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 15px var(--primary-glow);
}
.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-success {
    background: var(--success);
    color: #ffffff;
    box-shadow: 0 4px 15px var(--success-glow);
}
.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
    box-shadow: 0 4px 15px var(--danger-glow);
}
.btn-danger:hover {
    background: #e11d48;
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-glass);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

.btn-action-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 14px;
    border: none;
    background: transparent;
}
.btn-action-icon.edit { color: var(--primary); background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.15); }
.btn-action-icon.edit:hover { background: var(--primary); color: white; }
.btn-action-icon.delete { color: var(--danger); background: rgba(244, 63, 94, 0.1); border: 1px solid rgba(244, 63, 94, 0.15); }
.btn-action-icon.delete:hover { background: var(--danger); color: white; }
.btn-action-icon.print { color: var(--accent); background: rgba(168, 85, 247, 0.1); border: 1px solid rgba(168, 85, 247, 0.15); }
.btn-action-icon.print:hover { background: var(--accent); color: white; }

/* ==========================================================================
   ALERTAS Y BANNER DE NOTIFICACIÓN (TOASTS)
   ========================================================================== */
.alert {
    padding: 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-danger {
    background: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.15);
    color: #fca5a5;
}

.alert-success {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.15);
    color: #a7f3d0;
}

/* ==========================================================================
   DISEÑO DINÁMICO DE NÚMEROS DE SERIE (COMPRAS DETALLE)
   ========================================================================== */
.serial-inputs-container {
    background: rgba(0, 0, 0, 0.15);
    border: 1px dashed var(--border-glass-hover);
    border-radius: 12px;
    padding: 20px;
    margin-top: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.serial-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Autorelleno Visual Alert */
.autofill-highlight {
    animation: flashSuccess 1.5s ease;
}
@keyframes flashSuccess {
    0% { background-color: rgba(16, 185, 129, 0.2); }
    100% { background-color: rgba(255, 255, 255, 0.02); }
}

/* ==========================================================================
   PANTALLA DE ACCESO (LOGIN)
   ========================================================================== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100vw;
    background: radial-gradient(circle at center, #131b31 0%, #060911 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    text-align: center;
}

.login-header {
    margin-bottom: 30px;
}

.login-header h2 {
    font-size: 24px;
    font-weight: 800;
    margin-top: 12px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 6px;
}

/* ==========================================================================
   MANTENEDORES (TABS INTERNAS)
   ========================================================================== */
.tabs-header {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 12px;
}

.tab-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
    color: var(--text-main);
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

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

/* ==========================================================================
   ESTILOS DE IMPRESIÓN EXCLUSIVOS PARA ACTAS EN PDF
   ========================================================================== */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-family: 'Inter', sans-serif !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .sidebar, .header, .btn, .btn-action-icon, .actions-cell, th:last-child, td:last-child {
        display: none !important; /* Ocultar controles interactivos y barra lateral */
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .print-only {
        display: block !important;
    }

    /* Estilo del Acta física en PDF */
    .acta-container {
        padding: 40px !important;
        max-width: 800px !important;
        margin: 0 auto !important;
        background: white !important;
        color: black !important;
    }

    .acta-header {
        border-bottom: 2px solid #333 !important;
        padding-bottom: 20px !important;
        margin-bottom: 30px !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .acta-header-title h2 {
        font-size: 22px !important;
        font-weight: 800 !important;
        color: #000 !important;
        margin: 0 !important;
    }

    .acta-section {
        margin-bottom: 25px !important;
    }

    .acta-section h3 {
        font-size: 14px !important;
        font-weight: 700 !important;
        border-bottom: 1px solid #ddd !important;
        padding-bottom: 6px !important;
        margin-bottom: 12px !important;
        text-transform: uppercase !important;
        color: #444 !important;
    }

    .acta-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 15px !important;
        font-size: 13px !important;
        margin-bottom: 20px !important;
    }

    .acta-grid-item {
        margin-bottom: 8px !important;
    }

    .acta-grid-item strong {
        color: #333 !important;
    }

    .acta-table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin-top: 15px !important;
        font-size: 13px !important;
    }

    .acta-table th, .acta-table td {
        border: 1px solid #ddd !important;
        padding: 10px !important;
        text-align: left !important;
    }

    .acta-table th {
        background: #f5f5f5 !important;
        color: black !important;
    }

    .acta-signatures {
        display: flex !important;
        justify-content: space-between !important;
        margin-top: 80px !important;
    }

    .signature-box {
        width: 45% !important;
        text-align: center !important;
        border-top: 1px solid #000 !important;
        padding-top: 10px !important;
        font-size: 13px !important;
    }
}
