/* ===== VARIABLES CSS ===== */
:root {
    /* Colores principales */
    --primary-blue: #0066ff;
    --dark-blue: #004ec2;
    --light-blue: #e6f0ff;
    --primary-orange: #ff7700;
    --dark-orange: #e56d00;
    --light-orange: #fff2e6;
    
    /* Colores de estado */
    --success: #28a745;
    --info: #17a2b8;
    --warning: #ffc107;
    --danger: #dc3545;
    
    /* Colores neutros */
    --neutral-text: #2d3748;
    --neutral-light: #f7fafc;
    --neutral-dark: #1a202c;
    --neutral-border: #e2e8f0;
    --neutral-background: #f8fafc;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Transiciones */
    --transition-fast: 0.15s ease;
    --transition: 0.3s ease;
    
    /* Radios */
    --radius-sm: 0.25rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
}

/* ===== RESET GLOBAL ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== ESTILOS BASE ===== */
body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--neutral-background);
    color: var(--neutral-text);
    min-height: 100vh;
    line-height: 1.5;
}

/* ===== LAYOUT PRINCIPAL ===== */
.dashboard-container {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
    background: linear-gradient(150deg, var(--dark-blue), var(--primary-blue));
    color: white;
    width: 260px;
    transition: width var(--transition);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.sidebar-closed {
    width: 70px;
}

/* Header del Sidebar */
.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 70px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: white;
    cursor: pointer;
    transition: opacity var(--transition);
}

.sidebar-logo:hover {
    opacity: 0.8;
}

.logo-img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    transition: var(--transition);
    flex-shrink: 0;
}

.logo-text {
    margin-left: 10px;
    font-weight: 600;
    font-size: 1.25rem;
    transition: opacity var(--transition), visibility var(--transition);
    white-space: nowrap;
}

.sidebar-closed .logo-text {
    opacity: 0;
    visibility: hidden;
    width: 0;
    margin-left: 0;
}

.sidebar-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

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

/* Contenido del Sidebar */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 0;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.6);
    padding: 0 1.25rem;
    margin-bottom: 0.5rem;
    transition: opacity var(--transition);
}

.sidebar-closed .nav-section-title {
    opacity: 0;
}

.nav-list {
    list-style: none;
}

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

.nav-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.8);
    padding: 0.75rem 1.25rem;
    border-radius: 0;
    position: relative;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.sidebar-closed .nav-link {
    padding: 0.75rem;
    justify-content: center;
}

.nav-link:hover, 
.nav-item.active .nav-link {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.nav-item.active .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 60%;
    width: 4px;
    background-color: var(--primary-orange);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.nav-link i {
    font-size: 1.1rem;
    margin-right: 0.75rem;
    min-width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-closed .nav-link i {
    margin-right: 0;
    font-size: 1.2rem;
}

.nav-text {
    transition: opacity var(--transition), visibility var(--transition);
    white-space: nowrap;
}

.sidebar-closed .nav-text {
    opacity: 0;
    visibility: hidden;
    width: 0;
}

/* Footer del Sidebar */
.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-btn {
    display: flex;
    align-items: center;
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 0.65rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition-fast);
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.logout-btn i {
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.sidebar-closed .logout-btn span {
    display: none;
}

/* Mejoras para sidebar colapsado */
.sidebar-closed .nav-link {
    padding: 0.75rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sidebar-closed .nav-link i {
    margin: 0;
    text-align: center;
    width: 100%;
}

.sidebar-closed .nav-item.active .nav-link::before {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 40%;
    width: 3px;
}

.sidebar-closed .nav-list {
    padding: 0;
}

.sidebar-closed .nav-item {
    display: flex;
    justify-content: center;
}

/* ===== CONTENIDO PRINCIPAL ===== */
.main-content {
    flex: 1;
    margin-left: 260px;
    transition: margin-left var(--transition);
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.main-content-expanded {
    margin-left: 70px;
}

/* ===== HEADER PRINCIPAL ===== */
.main-header {
    background: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .5rem 1.5rem; /* ✅ CORREGIDO: Se removió el espacio extra */
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 90;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    min-height: 70px;
}

/* ===== ESTRUCTURA DEL HEADER MEJORADA ===== */
.header-left {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    justify-content: flex-end; /* ✅ AÑADIDO: Asegurar alineación a la derecha */
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--neutral-text);
    font-size: 1.25rem;
    cursor: pointer;
    display: none;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: background var(--transition-fast);
}

.menu-toggle:hover {
    background: var(--neutral-light);
}

/* ===== ACCIONES DEL HEADER ===== */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 100%; /* ✅ AÑADIDO: Altura completa */
}



.priority-indicator {
    position: absolute;
    top: -6px;
    left: -6px;
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: priority-pulse 2s infinite;
    z-index: 1062;
    pointer-events: none;
    transform: scale(0.9);
}

@keyframes priority-pulse {
    0%, 100% {
        transform: scale(0.9);
        box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.4);
    }
    50% {
        transform: scale(1);
        box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.1);
    }
}

/* ===== DROPDOWN DE USUARIO MEJORADO ===== */
.user-dropdown {
    position: relative;
}

.user-profile-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    transition: background var(--transition-fast);
}

.user-profile-link:hover {
    background: var(--neutral-light);
    color: inherit;
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--neutral-border);
    transition: border-color var(--transition-fast);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar:hover {
    border-color: var(--primary-blue);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name {
    font-weight: 500;
    margin-left: 0.75rem;
    margin-right: 0.5rem;
    white-space: nowrap;
    color: var(--neutral-text);
}

/* ===== DROPDOWNS GENERALES ===== */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 260px;
    background-color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 100;
    overflow: hidden;
    border: 1px solid var(--neutral-border);
}

.dropdown-title {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--neutral-text);
    border-bottom: 1px solid var(--neutral-border);
    background: var(--neutral-light);
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--neutral-text);
    transition: background var(--transition-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.dropdown-item:hover {
    background-color: var(--neutral-light);
    color: var(--neutral-text);
}

.dropdown-item.text-danger {
    color: var(--danger);
}

.dropdown-item.text-danger:hover {
    background-color: #fef2f2;
    color: var(--danger);
}

.dropdown-item i {
    margin-right: 0.75rem;
    opacity: 0.7;
    font-size: 0.9rem;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--neutral-border);
    margin: 0.25rem 0;
}

.dropdown-footer {
    display: block;
    padding: 0.65rem 1rem;
    text-align: center;
    background-color: var(--neutral-light);
    color: var(--primary-blue);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background var(--transition-fast);
}

.dropdown-footer:hover {
    background-color: #e6e6e6;
    color: var(--primary-blue);
}

/* ===== CONTENIDO DEL DASHBOARD ===== */
.content-wrapper {
    padding: 1.5rem;
    flex: 1;
}

.dashboard-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ===== SECCIÓN DE BIENVENIDA ===== */
.welcome-section {
    background: linear-gradient(to right, var(--primary-blue), #0088ff);
    color: white;
    border-radius: var(--radius);
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
}

.welcome-content {
    flex: 1;
}

.welcome-content h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.welcome-content p {
    opacity: 0.9;
    margin-bottom: 1.5rem;
}

.welcome-stats {
    display: flex;
    gap: 1.5rem;
}

.stat-item {
    background: rgba(255, 255, 255, 0.15);
    padding: 1rem;
    border-radius: var(--radius);
    backdrop-filter: blur(4px);
    flex: 1;
    text-align: center;
    transition: transform var(--transition-fast), background var(--transition-fast);
}

.stat-item:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
}

.welcome-image {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 200px;
}

.welcome-image img {
    width: 100%;
    height: auto;
}

/* ===== TARJETAS DE ESTADÍSTICAS ===== */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.card {
    background-color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    border: none;
}

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

.card-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--neutral-border);
    background-color: #f8f9fa;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    margin: 0;
}

.card-header h2 i {
    margin-right: 0.5rem;
}

.view-all {
    font-size: 0.85rem;
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    transition: color var(--transition-fast);
}

.view-all:hover {
    color: var(--dark-blue);
}

.view-all i {
    margin-left: 0.35rem;
    font-size: 0.75rem;
    transition: transform var(--transition-fast);
}

.view-all:hover i {
    transform: translateX(2px);
}

.card-body {
    padding: 1.25rem;
}

.stat-card .card-body {
    display: flex;
    align-items: center;
    padding: 1.5rem;
}

.stat-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    margin-right: 1rem;
    font-size: 1.25rem;
    color: white;
    flex-shrink: 0;
}

.stat-card-info {
    flex: 1;
}

.stat-card-title {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--neutral-dark);
    margin: 0;
}

/* ===== COMPONENTES ADICIONALES ===== */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
    margin-right: 0.3rem;
    border-radius: var(--radius-sm);
    color: black;
}

.avatar-sm {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== COLORES DE FONDO ===== */
.bg-primary {
    background-color: var(--primary-blue) !important;
}

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

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

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

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

/* ===== ALERTAS ===== */
.alert {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
}

.alert-success {
    background-color: #d1e7dd;
    border-color: #badbcc;
    color: #0f5132;
}

.alert-danger {
    background-color: #f8d7da;
    border-color: #f5c2c7;
    color: #842029;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #ffecb5;
    color: #664d03;
}

/* ===== FORMULARIOS ===== */
.form-check-label {
    cursor: pointer;
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.input-group-text {
    background-color: #f8f9fa;
}

/* ===== BOTONES ===== */
.btn-light {
    background-color: #f8f9fa;
    border-color: #e9ecef;
}

.btn-light:hover {
    background-color: #e9ecef;
    border-color: #dde0e3;
}

/* ===== PAGINACIÓN ===== */
.pagination {
    margin-bottom: 0;
}

.page-link {
    color: var(--primary-blue);
    border: 1px solid #dee2e6;
    margin: 0 0.2rem;
    border-radius: 0.25rem;
}

.page-link:hover {
    background-color: #e9ecef;
    border-color: #dee2e6;
    color: var(--dark-blue);
}

.page-item.active .page-link {
    background-color: var(--primary-blue);
    border-color: var(--primary-blue);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px !important;
    }

    .sidebar-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
    }
    
    .main-header {
        padding: 0.9rem 1rem;
        width: 100%;
    }
    
    .main-header .header-right {
        gap: 0.5rem;
    }
    
    .menu-toggle {
        display: block;
    }

    .welcome-section {
        flex-direction: column;
        text-align: center;
    }

    .welcome-stats {
        margin-top: 1rem;
    }

    .welcome-image {
        display: none;
    }
}

@media (max-width: 768px) {
    .stats-cards {
        grid-template-columns: 1fr;
    }

    .welcome-stats {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .main-header {
        padding: 0.5rem 0.75rem;
    }
    
    .main-header .header-right {
        gap: 0.5rem;
    }
    
    .user-name {
        display: none;
    }
    
    /* Ajustar tamaños de botones en móvil */
    .notification-btn,
    .user-avatar {
        width: 36px;
        height: 36px;
    }
    
    .notification-btn .fa-bell {
        font-size: 1rem !important;
    }
}

@media (max-width: 576px) {
    .main-header {
        padding: 0.5rem;
    }
    
    .main-header .header-left {
        min-width: 0;
    }
    
    .main-header .header-right {
        flex-shrink: 1;
        min-width: 0;
        gap: 0.25rem;
    }

    .quick-actions-grid {
        grid-template-columns: 1fr;
    }
    
    /* Botones más pequeños en móviles */
    .notification-btn,
    .user-avatar {
        width: 32px;
        height: 32px;
    }
    
    .notification-btn .fa-bell {
        font-size: 0.9rem !important;
    }
    
    .notification-count {
        min-width: 16px;
        height: 16px;
        font-size: 0.6rem;
        top: -4px;
        right: -4px;
    }
    
    .priority-indicator {
        width: 14px;
        height: 14px;
        top: -4px;
        left: -4px;
    }
}

/* ===== ESTILOS ADICIONALES PARA CRUD ===== */
.content-container {
    max-width: 100%;
    padding: 1rem;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.table th {
    font-weight: 600;
    color: #344767;
}

.table-hover tbody tr:hover {
    background-color: #f8f9fa;
}

/* ===== MEJORAS DE ACCESIBILIDAD ===== */
@media (prefers-reduced-motion: reduce) {
    .priority-indicator {
        animation: none;
    }
    
    * {
        transition: none !important;
    }
}

/* ===== UTILIDADES ===== */
.d-flex {
    display: flex !important;
}

.align-items-center {
    align-items: center !important;
}

.justify-content-center {
    justify-content: center !important;
}

.text-center {
    text-align: center !important;
}

.me-2 {
    margin-right: 0.5rem !important;
}

.ms-2 {
    margin-left: 0.5rem !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}   