﻿/* ============================================
   VARIABLES GLOBALES
   ============================================ */
:root {
    /* Colores principales - Manteniendo tu paleta */
    --primary-color: #006838;
    --primary-light: #2a8c5c;
    --primary-dark: #004d2a;
    --primary-rgb: 0, 104, 56;
    --secondary-color: #316911;
    --secondary-light: #4a8c2a;
    --secondary-dark: #234d0c;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    /* Colores neutros */
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    /* Dimensiones - MEJORADAS */
    --sidebar-width: 300px; /* 👈 antes 280px - MÁS ESPACIO */
    --sidebar-collapsed: 70px;
    --topbar-height: 70px;
    --footer-height: 60px;
    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 5px 15px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.15);
    /* Transiciones */
    --transition-fast: 0.2s ease;
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s ease;
}

/* ============================================
   RESET Y ESTILOS BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--gray-100);
    overflow-x: hidden;
    color: var(--gray-800);
    line-height: 1.5;
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* ============================================
   SIDEBAR MODERNO - VERSIÓN MEJORADA
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: width var(--transition-base);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) rgba(255,255,255,0.1);
}

    .sidebar::-webkit-scrollbar {
        width: 4px;
    }

    .sidebar::-webkit-scrollbar-track {
        background: rgba(255,255,255,0.1);
        border-radius: 4px;
    }

    .sidebar::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.3);
        border-radius: 4px;
    }

        .sidebar::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,0.5);
        }

    .sidebar.collapsed {
        width: var(--sidebar-collapsed);
    }

/* Sidebar Header */
.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .logo-container {
    justify-content: center;
}

.sidebar.collapsed .logo-text {
    display: none;
}

.logo-icon {
    font-size: 1.8rem;
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.logo-main {
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.logo-sub {
    font-size: 0.6rem;
    opacity: 0.7;
    letter-spacing: 0.5px;
}

.sidebar-toggle {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

    .sidebar-toggle:hover {
        background: rgba(255,255,255,0.2);
        transform: rotate(90deg);
    }

.sidebar.collapsed .sidebar-toggle i {
    display: none;
}

.sidebar.collapsed .sidebar-toggle::before {
    content: "\f053";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.9rem;
}

/* Sidebar Content */
.sidebar-content {
    padding: 0.75rem;
}

/* Sidebar Sections - MEJORADAS */
.sidebar-section {
    margin-bottom: 1.5rem;
}

    .sidebar-section h6 {
        padding: 0 0.75rem;
        margin-bottom: 0.5rem;
        font-size: 0.65rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 1.2px;
        color: rgba(255,255,255,0.5);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        opacity: 0.7;
    }

.sidebar.collapsed .sidebar-section h6 {
    display: none;
}

/* Navigation - MEJORADA */
.nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin: 4px 10px; /* 👈 MÁS AIRE */
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem; /* 👈 MÁS ESPACIO */
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    transition: all var(--transition-fast);
    border-radius: 12px; /* 👈 MÁS REDONDEADO */
    font-size: 0.88rem;
    font-weight: 500;
    gap: 12px;
    position: relative;
    overflow: hidden; /* 👈 PARA EFECTO HOVER */
}

    /* Efecto de borde izquierdo - HOVER MODERNO */
    .nav-link::before {
        content: "";
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        width: 3px;
        background: white;
        opacity: 0;
        transition: var(--transition-fast);
    }

    .nav-link:hover::before,
    .nav-link.active::before {
        opacity: 1;
    }

    .nav-link:hover {
        background: rgba(255,255,255,0.12);
        color: white;
        transform: translateX(6px); /* 👈 MOVIMIENTO MÁS SUAVE */
    }

    .nav-link.active {
        background: linear-gradient(135deg, rgba(255,255,255,0.25), rgba(255,255,255,0.15));
        color: white;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15); /* 👈 SOMBRA MÁS ELEGANTE */
    }

    .nav-link i {
        min-width: 26px; /* 👈 ICONOS MÁS ALINEADOS */
        text-align: center;
        font-size: 1.15rem;
        transition: all var(--transition-fast);
    }

    .nav-link span {
        flex: 1;
        white-space: normal; /* 👈 PERMITE SALTO DE LÍNEA - CRÍTICO */
        word-break: break-word; /* 👈 EVITA CORTE BRUTAL */
        line-height: 1.3;
        font-size: 0.88rem;
    }

.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-link .badge {
    display: none;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem;
}

    .sidebar.collapsed .nav-link i {
        margin: 0;
        font-size: 1.2rem;
    }

    /* Tooltip para collapsed sidebar */
    .sidebar.collapsed .nav-link:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        background: var(--primary-dark);
        color: white;
        padding: 0.25rem 0.75rem;
        border-radius: 6px;
        font-size: 0.7rem;
        white-space: nowrap;
        z-index: 1000;
        margin-left: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        pointer-events: none;
    }

/* Badges - MÁS FINOS */
.badge {
    padding: 0.2rem 0.45rem; /* 👈 MÁS COMPACTOS */
    font-size: 0.65rem; /* 👈 MÁS PEQUEÑOS */
    font-weight: 600;
    border-radius: 20px;
    transition: all var(--transition-fast);
    opacity: 0.9; /* 👈 MÁS SUAVES */
}

    .badge.bg-secondary {
        background: rgba(255,255,255,0.25) !important;
        color: white;
    }

    .badge.bg-success {
        background: #28a745 !important;
        color: white;
    }

    .badge.bg-warning {
        background: #ffc107 !important;
        color: #1a1f2e;
    }

    .badge.bg-danger {
        background: #dc3545 !important;
        color: white;
    }

    .badge.bg-info {
        background: #17a2b8 !important;
        color: white;
    }

/* Sidebar Footer */
.sidebar-footer {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.75rem;
    background: rgba(0,0,0,0.2);
    backdrop-filter: blur(8px);
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    font-size: 1.8rem;
    line-height: 1;
    flex-shrink: 0;
}

    .user-avatar i {
        filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
    }

.user-details {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

    .user-details strong {
        display: block;
        font-size: 0.8rem;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .user-details small {
        font-size: 0.65rem;
        opacity: 0.7;
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

/* Botones de autenticación en sidebar-footer */
.sidebar-footer .btn-outline-light {
    border-color: rgba(255,255,255,0.3);
    color: white;
    font-size: 0.75rem;
    padding: 0.4rem 0.5rem;
}

    .sidebar-footer .btn-outline-light:hover {
        background: rgba(255,255,255,0.1);
        border-color: white;
    }

.sidebar-footer .btn-light {
    background: white;
    color: var(--primary-color);
    font-size: 0.75rem;
    padding: 0.4rem 0.5rem;
}

    .sidebar-footer .btn-light:hover {
        background: var(--gray-100);
    }

.sidebar.collapsed .user-details {
    display: none;
}

.sidebar.collapsed .user-info {
    justify-content: center;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-base);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* ============================================
   TOPBAR MODERNO
   ============================================ */
.topbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 99;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggler {
    background: transparent;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 1.2rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

    .sidebar-toggler:hover {
        background: var(--gray-100);
        color: var(--primary-color);
    }

.breadcrumb {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin: 0;
    padding: 0;
    background: transparent;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    color: var(--gray-400);
}

/* Topbar Right */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-notification {
    background: transparent;
    border: none;
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 1.2rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

    .btn-notification:hover {
        background: var(--gray-100);
        color: var(--primary-color);
    }

    .btn-notification .badge {
        position: absolute;
        top: -2px;
        right: -2px;
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
        min-width: 18px;
        height: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

/* User Dropdown */
.user-dropdown .user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    color: var(--gray-700);
    cursor: pointer;
    transition: all var(--transition-fast);
}

    .user-dropdown .user-menu:hover {
        background: var(--gray-100);
    }

.user-avatar-sm {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.user-dropdown .dropdown-menu {
    border: none;
    box-shadow: var(--shadow-lg);
    border-radius: 12px;
    padding: 0.5rem;
    margin-top: 0.5rem;
    min-width: 200px;
}

.user-dropdown .dropdown-item {
    border-radius: 8px;
    padding: 0.5rem 1rem;
    transition: all var(--transition-fast);
}

    .user-dropdown .dropdown-item:hover {
        background: var(--gray-100);
        transform: translateX(4px);
    }

    .user-dropdown .dropdown-item i {
        width: 20px;
        margin-right: 0.5rem;
        color: var(--primary-color);
    }

.dropdown-divider {
    margin: 0.5rem 0;
    border-color: var(--gray-200);
}

/* ============================================
   PAGE CONTENT
   ============================================ */
.page-content {
    padding: 1.5rem;
    flex: 1;
}

/* ============================================
   FOOTER
   ============================================ */
.main-footer {
    background: white;
    border-top: 1px solid var(--gray-200);
    padding: 0.75rem 1.5rem;
    font-size: 0.8rem;
    color: var(--gray-600);
}

/* ============================================
   LOADING OVERLAY
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

    .loading-overlay .spinner-border {
        width: 3rem;
        height: 3rem;
        color: var(--primary-color);
    }

/* ============================================
   CARDS MODERNAS
   ============================================ */
.card {
    border: none;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    background: white;
    margin-bottom: 1.5rem;
}

    .card:hover {
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
    }

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--gray-200);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    font-size: 1rem;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    background: transparent;
    border-top: 1px solid var(--gray-200);
    padding: 1rem 1.5rem;
}

/* Metric Cards */
.metric-card {
    border: none;
    border-radius: 20px;
    overflow: hidden;
    transition: all var(--transition-base);
    margin-bottom: 1.5rem;
    background: white;
}

    .metric-card:hover {
        transform: translateY(-5px);
        box-shadow: var(--shadow-lg);
    }

    .metric-card .card-body {
        padding: 1.5rem;
    }

.metric-label {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--gray-800);
}

.metric-icon {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    font-size: 2.5rem;
    opacity: 0.15;
}

.metric-footer {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--gray-200);
}

.trend-up {
    color: #28a745;
}

.trend-down {
    color: #dc3545;
}

/* Gradient Backgrounds for Cards */
.bg-primary-gradient {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
}

    .bg-primary-gradient .metric-label,
    .bg-primary-gradient .metric-value,
    .bg-primary-gradient .metric-footer {
        color: white;
    }

.bg-success-gradient {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

.bg-warning-gradient {
    background: linear-gradient(135deg, #ffc107, #fd7e14);
    color: white;
}

.bg-danger-gradient {
    background: linear-gradient(135deg, #dc3545, #e83e8c);
    color: white;
}

/* ============================================
   TABLAS MODERNAS
   ============================================ */
.table {
    margin-bottom: 0;
}

    .table thead th {
        border-bottom: 2px solid var(--gray-200);
        color: var(--gray-600);
        font-weight: 600;
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        padding: 1rem;
    }

    .table tbody td {
        padding: 1rem;
        vertical-align: middle;
        border-bottom: 1px solid var(--gray-200);
    }

    .table tbody tr {
        transition: all var(--transition-fast);
    }

        .table tbody tr:hover {
            background: var(--gray-100);
        }

.table-responsive {
    border-radius: 16px;
    overflow: hidden;
}

/* ============================================
   FORMULARIOS MODERNOS
   ============================================ */
.form-control,
.form-select {
    border-radius: 10px;
    border: 1px solid var(--gray-300);
    padding: 0.6rem 1rem;
    transition: all var(--transition-fast);
    font-size: 0.9rem;
}

    .form-control:focus,
    .form-select:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 0.2rem rgba(var(--primary-rgb), 0.25);
        outline: none;
    }

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
    font-size: 0.85rem;
}

/* ============================================
   BOTONES MODERNOS
   ============================================ */
.btn {
    border-radius: 10px;
    padding: 0.5rem 1.25rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    font-size: 0.9rem;
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

    .btn-primary:hover {
        background: var(--primary-dark);
        border-color: var(--primary-dark);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 104, 56, 0.3);
    }

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

    .btn-outline-primary:hover {
        background: var(--primary-color);
        border-color: var(--primary-color);
        transform: translateY(-1px);
    }

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
}

/* ============================================
   DROPDOWNS
   ============================================ */
.dropdown-menu {
    border: none;
    box-shadow: var(--shadow-lg);
    border-radius: 12px;
    padding: 0.5rem;
    animation: fadeInDown 0.2s ease;
}

.dropdown-item {
    border-radius: 8px;
    padding: 0.5rem 1rem;
    transition: all var(--transition-fast);
}

    .dropdown-item:hover {
        background: var(--gray-100);
        transform: translateX(4px);
    }

.dropdown-header {
    padding: 0.5rem 1rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--gray-500);
}

/* ============================================
   ANIMACIONES
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
/* Laptops 14–16" (~1280–1600): sidebar más estrecho y contenido fluido */
@media (max-width: 1600px) {
    :root {
        --sidebar-width: 240px;
    }

    .page-content {
        padding: 0.85rem 1rem !important;
    }

    .topbar {
        padding: 0 1rem;
    }
}

@media (max-width: 1366px) {
    :root {
        --sidebar-width: 220px;
    }

    .page-content {
        padding: 0.65rem 0.75rem !important;
    }
}

@media (max-width: 1024px) {
    :root {
        --sidebar-width: 280px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-base);
        width: var(--sidebar-width) !important;
    }

        .sidebar.show {
            transform: translateX(0);
        }

        .sidebar.collapsed {
            transform: translateX(-100%);
        }

    .main-content {
        margin-left: 0 !important;
    }

    .topbar {
        padding: 0 1rem;
    }

    .page-content {
        padding: 1rem;
    }

    .metric-value {
        font-size: 1.5rem;
    }

    .user-menu span {
        display: none;
    }

    .breadcrumb {
        font-size: 0.75rem;
    }
}

@media (max-width: 576px) {
    .topbar-left .sidebar-toggler {
        width: 32px;
        height: 32px;
    }

    .page-content {
        padding: 0.75rem;
    }

    .card-body {
        padding: 1rem;
    }

    .table thead th,
    .table tbody td {
        padding: 0.75rem;
    }
}

/* ============================================
   UTILIDADES ADICIONALES
   ============================================ */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.shadow-hover {
    transition: all var(--transition-fast);
}

    .shadow-hover:hover {
        box-shadow: var(--shadow-lg);
    }

.bg-light-hover {
    transition: all var(--transition-fast);
}

    .bg-light-hover:hover {
        background: var(--gray-100);
    }

/* Scrollbar Personalizado */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 4px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--gray-500);
    }
