/* ============================================
   VARIABLES Y CONFIGURACIÓN GLOBAL
   ============================================ */
:root {
    /* Paleta de colores profesional y moderna */
    --primary-color: #0d47a1;
    --primary-dark: #083d77;
    --primary-light: #1565c0;
    --secondary-color: #1976d2;
    --accent-color: #42a5f5;
    --success-color: #00c853;
    --warning-color: #ff9800;
    --danger-color: #d32f2f;
    --info-color: #0288d1;
    
    /* Gradientes profesionales */
    --gradient-primary: linear-gradient(135deg, #0d47a1 0%, #1976d2 100%);
    --gradient-secondary: linear-gradient(135deg, #0d47a1, #1565c0);
    --gradient-success: linear-gradient(135deg, #00c853, #00e676);
    --gradient-warning: linear-gradient(135deg, #ff9800, #ffb74d);
    --gradient-danger: linear-gradient(135deg, #d32f2f, #f44336);
    
    /* Grises profesionales */
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;
    
    /* Sidebar */
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
    --sidebar-bg: #1e293b;
    --sidebar-bg-dark: #0f172a;
    
    /* Layout */
    --header-height: 70px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
    --border-radius: 12px;
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    background-color: #f8f9fa;
    color: #2c3e50;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg-dark) 0%, var(--sidebar-bg) 100%);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(-100%); /* Cerrado por defecto */
}

.sidebar.open {
    transform: translateX(0); /* Abierto cuando tiene clase .open */
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    width: 40px;
    height: auto;
    border-radius: 8px;
}

.sidebar-title {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin: 0.25rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
    position: relative;
}

.nav-link i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-left-color: var(--secondary-color);
    transform: translateX(4px);
}

.nav-link.active {
    background: rgba(25, 118, 210, 0.2);
    color: #fff;
    border-left-color: var(--secondary-color);
    font-weight: 600;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--secondary-color);
    border-radius: 3px 0 0 3px;
}

.nav-divider {
    padding: 1rem 1.5rem 0.5rem;
    margin-top: 0.5rem;
}

.nav-divider span {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
}

.user-details {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.user-name {
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    text-transform: capitalize;
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: var(--transition);
    border: 1px solid rgba(220, 53, 69, 0.3);
}

.btn-logout:hover {
    background: rgba(220, 53, 69, 0.3);
    color: #fff;
    transform: translateY(-2px);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   CONTENIDO PRINCIPAL
   ============================================ */
.main-content {
    margin-left: 0; /* Sin margen cuando sidebar está cerrado */
    min-height: 100vh;
    transition: var(--transition);
    padding-top: var(--header-height);
}

.sidebar.open ~ .main-content,
body.sidebar-open .main-content {
    margin-left: var(--sidebar-width); /* Margen cuando sidebar está abierto */
}

@media (max-width: 991.98px) {
    .main-content {
        margin-left: 0 !important; /* Siempre sin margen en móviles */
    }
}

/* Header dentro del contenido */
.main-header {
    position: fixed;
    top: 0;
    left: 0; /* Sin margen cuando sidebar está cerrado */
    right: 0;
    height: var(--header-height);
    background: #fff;
    box-shadow: var(--shadow-md);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 2rem;
    transition: var(--transition);
}

.sidebar.open ~ .main-content .main-header,
body.sidebar-open .main-header {
    left: var(--sidebar-width); /* Margen cuando sidebar está abierto */
}

@media (max-width: 991.98px) {
    .main-header {
        left: 0 !important; /* Siempre sin margen en móviles */
    }
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
}

/* ============================================
   CONTENEDOR PRINCIPAL
   ============================================ */
.content-wrapper {
    padding: 2rem;
}

.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    transition: var(--transition);
}

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

.card-header {
    background: var(--gradient-secondary);
    color: #fff;
    padding: 1.25rem 1.5rem;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    font-weight: 600;
    border: none;
}

/* ============================================
   BOTONES
   ============================================ */
.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    transition: var(--transition);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    border: none;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(13, 71, 161, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: #fff;
}

.btn-warning {
    background: linear-gradient(135deg, #ffc107, #ffb300);
    color: #333;
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: #fff;
}

.btn-info {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: #fff;
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d, #495057);
    color: #fff;
}

/* ============================================
   FORMULARIOS
   ============================================ */
.form-label {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.form-control,
.form-select {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    padding: 0.75rem 1rem;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ============================================
   TABLAS
   ============================================ */
.table {
    margin-bottom: 0;
}

.table thead th {
    background: var(--gradient-primary);
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    border: none;
    padding: 1rem;
}

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

.table tbody tr:hover {
    background-color: rgba(13, 71, 161, 0.05);
    transform: scale(1.01);
}

.table td {
    padding: 1rem;
    vertical-align: middle;
    border-top: 1px solid #f1f3f4;
}

/* ============================================
   FOOTER
   ============================================ */
.main-footer {
    background: var(--primary-color);
    color: #fff;
    padding: 2rem 0;
    margin-top: 3rem;
}

.footer-logo {
    max-height: 60px;
    width: auto;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: flex-end;
}

.footer-link {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.footer-link:hover {
    background: rgba(255, 255, 255, 0.3);
    color: #fff;
    transform: translateY(-2px);
}

.footer-separator {
    color: rgba(255, 255, 255, 0.5);
}

.footer-divider {
    border-color: rgba(255, 255, 255, 0.2);
    margin: 1.5rem 0;
}

.footer-address {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.6;
}

.footer-brand {
    color: rgba(255, 255, 255, 0.95);
    font-size: 1rem;
    margin: 0;
}

.footer-brand strong {
    font-weight: 600;
    letter-spacing: 0.5px;
}

.footer-copyright {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    margin: 0;
}

/* ============================================
   PÁGINA PÚBLICA (sin sidebar)
   ============================================ */
body.public-page {
    background: #f8f9fa;
    min-height: 100vh;
}

body.public-page .public-header {
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1.5rem 0;
}

body.public-page .header-logo {
    height: 60px;
    width: auto;
}

body.public-page .main-content {
    padding-top: 0 !important;
}

body.public-page .main-content {
    margin-left: 0;
    padding-top: 0;
}

.public-header {
    background: #fff;
    box-shadow: var(--shadow-md);
    padding: 1rem 0;
}

.public-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-logo {
    height: 50px;
    width: auto;
}

.header-divider {
    height: 4px;
    background: var(--primary-color);
    margin: 0;
    border: none;
    opacity: 1;
}

/* ============================================
   UTILIDADES
   ============================================ */
.gradient-text {
    background: var(--gradient-secondary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .sidebar.open,
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .main-header {
        left: 0;
    }
    
    .sidebar-toggle-mobile {
        display: block !important;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 1001;
        background: var(--gradient-secondary);
        color: #fff;
        border: none;
        padding: 0.75rem 1rem;
        border-radius: 8px;
        box-shadow: var(--shadow-lg);
        font-size: 1.25rem;
        transition: var(--transition);
    }
    
    .sidebar-toggle-mobile:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-xl);
    }
    
    .content-wrapper {
        padding: 1rem;
    }
    
    .page-title {
        font-size: 1.25rem;
    }
}

@media (min-width: 992px) {
    .sidebar-toggle-mobile {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .card-body {
        padding: 1rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        margin-bottom: 0.25rem;
    }
}

@media (max-width: 576px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start !important;
    }
    
    .page-title {
        font-size: 1.1rem;
    }
    
    .display-4, .display-5 {
        font-size: 2rem;
    }
    
    .h3 {
        font-size: 1.5rem;
    }
}

/* ============================================
   ANIMACIONES
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* ============================================
   ALERTAS PERSONALIZADAS
   ============================================ */
.alert {
    border-radius: var(--border-radius);
    border: none;
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background: linear-gradient(135deg, rgba(40, 167, 69, 0.1), rgba(32, 201, 151, 0.1));
    color: #155724;
    border-left: 4px solid #28a745;
}

.alert-danger {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.1), rgba(200, 35, 51, 0.1));
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.alert-info {
    background: linear-gradient(135deg, rgba(23, 162, 184, 0.1), rgba(19, 132, 150, 0.1));
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

.alert-warning {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.1), rgba(255, 179, 0, 0.1));
    color: #856404;
    border-left: 4px solid #ffc107;
}

/* ============================================
   MEJORAS ADICIONALES
   ============================================ */
.min-vh-100 {
    min-height: 100vh;
}

/* Badges mejorados */
.badge {
    padding: 0.5em 0.75em;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Input groups mejorados */
.input-group-text {
    border-color: #e9ecef;
    background-color: #f8f9fa;
}

/* Cards con hover mejorado */
.card {
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-4px);
}

/* Tablas responsive mejoradas */
.table-responsive {
    border-radius: var(--border-radius);
    overflow: hidden;
}

/* Botones de acción mejorados */
.btn-group-sm > .btn,
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* Paginación mejorada */
.pagination .page-link {
    border-radius: 8px;
    margin: 0 2px;
    border: 2px solid #e9ecef;
    color: var(--primary-color);
    font-weight: 500;
    transition: var(--transition);
}

.pagination .page-link:hover {
    background: var(--gradient-primary);
    color: #fff;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.pagination .page-item.active .page-link {
    background: var(--gradient-primary);
    border-color: var(--primary-color);
    color: #fff;
}

/* Estadísticas cards */
.bg-opacity-10 {
    background-color: rgba(var(--bs-primary-rgb), 0.1) !important;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Scrollbar personalizado para todo el sitio */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Animaciones adicionales */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

/* Mejoras de accesibilidad */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.25);
}

/* Estados de hover mejorados */
a:hover {
    text-decoration: none;
}

/* Espaciado mejorado */
.py-5 {
    padding-top: 3rem !important;
    padding-bottom: 3rem !important;
}

/* Checkbox para selección masiva */
.credencial-checkbox {
    cursor: pointer;
    width: 18px;
    height: 18px;
    margin-right: 8px;
}

.form-check-input:indeterminate {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

