/* 
==================================================
   SISTEMA UCH - DISEÑO PREMIUM (UI/UX)
   VERSION 2026 - RESPONSIVO & GLASSMORPHISM
==================================================
*/

:root {
    /* Paleta UCH Premium v2 */
    --uch-primary: #0a2540;
    --uch-secondary: #0061ff;
    --uch-accent: #10b981;
    --uch-danger: #ef4444;
    --uch-warning: #f59e0b;
    --uch-info: #3b82f6;

    /* Grises / Fondos Premium */
    --bg-body: #f1f5f9;
    --bg-surface: rgba(255, 255, 255, 0.85);
    /* Glass base */
    --bg-surface-solid: #ffffff;
    --border-color: rgba(226, 232, 240, 0.6);
    --glass-border: rgba(255, 255, 255, 0.4);

    /* Tipografía */
    --text-main: #1e293b;
    --text-muted: #64748b;
    --font-heading: 'Inter', sans-serif;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 72px;
    --border-radius: 20px;
    --border-radius-sm: 10px;

    /* Sombras Elevadas */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 8px 16px -4px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 10px 10px -5px rgba(15, 23, 42, 0.04);
}

/* ================== THEME DARK MODE ================== */
body.dark-mode {
    --bg-body: #0b1120;
    --bg-surface: rgba(30, 41, 59, 0.7);
    --bg-surface-solid: #1e293b;
    --border-color: rgba(51, 65, 85, 0.5);
    --glass-border: rgba(255, 255, 255, 0.05);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --shadow-md: 0 8px 16px -4px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

/* Base Overrides */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    transition: background-color 0.3s ease;
}

/* Glassmorphism Effect */
.glass-effect {
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    background-color: var(--bg-surface);
    border: 1px solid var(--glass-border);
}

.glass-card {
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-md);
    padding: 24px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

/* Sidebar Responsive Logic */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface-solid);
    border-right: 1px solid var(--border-color);
    position: fixed;
    left: 0;
    /* Default for desktop */
    height: 100vh;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), left 0.4s ease;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

@media (max-width: 991px) {
    aside#mainSidebar.sidebar {
        left: -280px;
        width: 280px;
        display: flex !important;
        visibility: visible !important;
        transition: left 0.4s ease !important;
    }

    aside#mainSidebar.sidebar.show,
    aside#mainSidebar.sidebar.active {
        left: 0 !important;
        transform: none !important;
        box-shadow: var(--shadow-lg);
    }

    .main-content {
        margin-left: 0 !important;
    }

    .topbar {
        padding: 0 16px !important;
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    #mobileToggleBtn {
        z-index: 2000 !important;
        position: relative;
    }
}

/* Sidebar Components (Restored) */
.sidebar-header {
    height: var(--header-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--uch-primary);
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--uch-secondary), #00a3ff);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.brand-text {
    font-weight: 800;
    font-size: 1.2rem;
    line-height: 1;
}

.brand-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 12px;
    margin-top: 24px;
    padding: 0 8px;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 14px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    margin-bottom: 4px;
}

.menu-item .icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    margin-right: 12px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.menu-item:hover {
    background: rgba(0, 97, 255, 0.05);
    color: var(--uch-secondary);
}

.menu-item:hover .icon {
    background: white;
    box-shadow: var(--shadow-sm);
}

.menu-item.active {
    background: linear-gradient(135deg, var(--uch-primary) 0%, #004ecc 100%);
    color: white;
    box-shadow: 0 6px 14px -3px rgba(10, 37, 64, 0.35);
}

.menu-item.active .icon {
    background: rgba(255, 255, 255, 0.18);
    color: white;
}

/* Botón Salir en Topbar */
.btn-topbar-exit {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #475569;
    padding: 0.38rem 0.95rem;
    font-size: 0.85rem;
    transition: all 0.22s ease;
}

.btn-topbar-exit:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.12);
}

.btn-topbar-exit:hover .text-secondary {
    color: #dc2626 !important;
}

body.dark-mode .btn-topbar-exit {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

body.dark-mode .btn-topbar-exit:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #f87171;
}

body.dark-mode .btn-topbar-exit:hover .text-secondary {
    color: #f87171 !important;
}

/* Sidebar Categories & Compact View */
.menu-category {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 14px 16px 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0.8;
}

.menu-category::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
    opacity: 0.5;
}

.sidebar-group-content .menu-item {
    padding: 8px 16px;
    margin-bottom: 2px;
    border-radius: 10px;
}

.sidebar-group-content .menu-item .icon {
    width: 30px;
    height: 30px;
    font-size: 0.95rem;
    margin-right: 10px;
}

.sidebar-group-content .menu-item span {
    font-size: 0.88rem;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(248, 250, 252, 0.5);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--uch-secondary);
}

.user-info .name {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0;
    color: var(--text-main);
}

.user-info .role {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

.main-content {
    margin-left: var(--sidebar-width);
    transition: margin 0.4s ease;
}

/* Topbar Premium */
.topbar {
    height: var(--header-height);
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Stats Cards */
.stat-card {
    background: var(--bg-surface-solid);
    border-radius: var(--border-radius);
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: var(--bg-body);
}

/* Animations */
.fade-in-up {
    animation: fadeInUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Table Responsive Stack */
@media (max-width: 767px) {
    .responsive-table-stack thead {
        display: none;
    }

    .responsive-table-stack tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        background: var(--bg-surface-solid);
        padding: 8px;
    }

    .responsive-table-stack td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 12px;
        border: none !important;
        font-size: 0.85rem;
    }

    .responsive-table-stack td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
    }
}

/* Sidebar Toggle Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1060;
    display: none;
    pointer-events: none;
    /* Block interactions only when show is added */
}

.sidebar-overlay.show {
    display: block;
    pointer-events: auto;
}

/* Custom Buttons */
.btn-premium {
    background: linear-gradient(135deg, var(--uch-secondary), #00a3ff);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 97, 255, 0.25);
    transition: all 0.3s ease;
}

.btn-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 97, 255, 0.35);
    color: white;
}

/* ================== RESTORED COMPONENT STYLES ================== */

/* Primary Action Buttons */
.btn-primary-custom {
    background: linear-gradient(135deg, var(--uch-secondary), #00a3ff);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0, 97, 255, 0.25);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 97, 255, 0.35);
    color: white;
}

/* Dark Button */
.btn-dark-custom {
    background: var(--uch-primary);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(10, 37, 64, 0.2);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    text-decoration: none;
}

.btn-dark-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(10, 37, 64, 0.3);
    color: white;
    background: #0d2e4a;
}

/* Outline Action Buttons (Premium) */
.btn-outline-primary {
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-outline-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 97, 255, 0.2);
}

.btn-outline-danger {
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-outline-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.2);
}

/* Content Wrapper */
.content-wrapper {
    padding: 32px;
    min-height: calc(100vh - var(--header-height));
}

@media (max-width: 767px) {
    .content-wrapper {
        padding: 16px;
    }
}

/* Page Title */
.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--uch-primary);
    margin-bottom: 0;
    letter-spacing: -0.5px;
}

/* Topbar Actions */
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Date Widget */
.date-widget {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

/* Avatar Image */
.avatar-img {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

/* Badge Lote */
.badge-lote {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(0, 97, 255, 0.08);
    color: var(--uch-secondary);
    border: 1px solid rgba(0, 97, 255, 0.12);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-badge.success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.status-badge.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.status-badge.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

/* Custom Nav Pills */
.custom-nav-pills {
    display: flex;
    gap: 8px;
    background: var(--bg-body);
    padding: 6px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
}

.custom-nav-pills .nav-link {
    border-radius: 10px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    border: none;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.custom-nav-pills .nav-link.active {
    background: linear-gradient(135deg, var(--uch-secondary), #00a3ff);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 97, 255, 0.25);
}

.custom-nav-pills .nav-link:hover:not(.active) {
    background: rgba(0, 97, 255, 0.05);
    color: var(--uch-secondary);
}

/* Upload Grid + Cards */
.upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.upload-card {
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.upload-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 16px;
    background: rgba(241, 245, 249, 0.5);
}

.drop-zone:hover {
    border-color: var(--uch-secondary);
    background: rgba(0, 97, 255, 0.03);
}

.icon-container {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 16px;
}

.icon-container.excel {
    background: rgba(16, 185, 129, 0.1);
    color: var(--uch-accent);
}

.icon-container.zip {
    background: rgba(0, 97, 255, 0.1);
    color: var(--uch-secondary);
}

/* Table Wrapper */
.table-wrapper {
    border-radius: 12px;
    overflow: hidden;
}

/* Premium Table Enhancements */
.table thead th {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
    padding: 14px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-color: var(--border-color);
}

.table-hover tbody tr:hover {
    background: rgba(0, 97, 255, 0.02);
}

/* Light Background Utilities */
.bg-light-primary {
    background: rgba(0, 97, 255, 0.08) !important;
}

.bg-light-success {
    background: rgba(16, 185, 129, 0.08) !important;
}

.bg-light-warning {
    background: rgba(245, 158, 11, 0.08) !important;
}

.bg-light-danger {
    background: rgba(239, 68, 68, 0.08) !important;
}

.bg-light-info {
    background: rgba(59, 130, 246, 0.08) !important;
}

/* Select2 Premium Theme */
.select2-container--default .select2-selection--single {
    height: 42px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 6px 12px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.select2-container--default .select2-selection--single:focus,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--uch-secondary);
    box-shadow: 0 0 0 3px rgba(0, 97, 255, 0.1);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 28px;
    color: var(--text-main);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px;
}

.select2-dropdown {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.select2-results__option--highlighted[aria-selected] {
    background: var(--uch-secondary) !important;
}

.select2-search--dropdown .select2-search__field {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 8px 12px;
}

/* Form Controls Premium */
.form-control,
.form-select {
    border-radius: 10px;
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--uch-secondary);
    box-shadow: 0 0 0 3px rgba(0, 97, 255, 0.1);
}

/* Custom Sidebar Groups (replaces Bootstrap accordion) */
.sidebar-group-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 12px;
    margin-top: 16px;
    margin-bottom: 4px;
    background: transparent;
    border: none;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s ease;
}

.sidebar-group-btn:hover {
    color: var(--uch-secondary);
}

.sidebar-chevron {
    font-size: 0.6rem;
    transition: transform 0.3s ease;
    color: var(--text-muted);
}

.sidebar-chevron.rotated {
    transform: rotate(180deg);
}

.sidebar-group-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

/* max-height is set by JS based on scrollHeight */

/* Dark Mode Overrides for New Components */
body.dark-mode .btn-primary-custom {
    box-shadow: 0 4px 12px rgba(0, 97, 255, 0.4);
}

body.dark-mode .btn-dark-custom {
    background: #1e293b;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .upload-card {
    background: var(--bg-surface-solid);
    border-color: var(--border-color);
}

body.dark-mode .drop-zone {
    background: rgba(30, 41, 59, 0.5);
    border-color: var(--border-color);
}

body.dark-mode .custom-nav-pills {
    background: rgba(15, 23, 42, 0.5);
}

body.dark-mode .badge-lote {
    background: rgba(0, 97, 255, 0.15);
    border-color: rgba(0, 97, 255, 0.2);
}

body.dark-mode .avatar-img {
    border-color: var(--border-color);
}

body.dark-mode .table thead th {
    color: var(--text-muted);
}

body.dark-mode .glass-card {
    background: var(--bg-surface);
}

body.dark-mode .form-control,
body.dark-mode .form-select {
    background: var(--bg-surface-solid);
    border-color: var(--border-color);
    color: var(--text-main);
}