/* Estilos globales del sistema SICA */
:root {
    --primary-color: #1e40af;
    --secondary-color: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --sidebar-width: 280px;
    --sidebar-bg: #0f172a;
    --sidebar-bg-hover: #1e293b;
    --sidebar-accent: #3b82f6;
}

html {
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f1f5f9;
    width: 100%;
    min-width: 320px;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: white;
    z-index: 1000;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

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

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.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: 20px;
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h3 {
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 1px;
    margin: 0;
    color: white;
}

.sidebar-header p {
    font-size: 0.75rem;
    opacity: 0.9;
    margin: 5px 0 0 0;
    color: rgba(255,255,255,0.8);
}

/* Selector de Año Lectivo en Sidebar */
.sidebar-anio-selector {
    padding: 12px 15px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    margin: 15px;
    border-radius: 8px;
}

.sidebar-anio-selector label {
    display: block;
    color: rgba(255,255,255,0.7);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.sidebar-anio-selector .form-select {
    background: rgba(255,255,255,0.98);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #0f172a;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: all 0.2s;
}

.sidebar-anio-selector .form-select:hover {
    border-color: var(--sidebar-accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.sidebar-anio-selector .form-select:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    border-color: var(--sidebar-accent);
}

.sidebar-user {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    background: rgba(255,255,255,0.02);
}

.sidebar-user .user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-size: 1.4rem;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.sidebar-menu {
    padding: 10px 0;
}

.sidebar-menu .menu-label {
    padding: 12px 20px 8px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    font-weight: 600;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover {
    background: var(--sidebar-bg-hover);
    color: white;
}

.sidebar-menu a.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.2), transparent);
    color: white;
    border-left-color: var(--sidebar-accent);
}

.sidebar-menu a i {
    width: 22px;
    font-size: 1.1rem;
    margin-right: 10px;
}

/* Submenú */
.sidebar-submenu {
    padding-left: 52px;
    background: rgba(0,0,0,0.15);
    border-left: 3px solid rgba(255,255,255,0.1);
}

.sidebar-submenu a {
    padding: 8px 20px;
    font-size: 0.85rem;
    opacity: 0.8;
}

.sidebar-submenu a:hover {
    opacity: 1;
    background: rgba(255,255,255,0.05);
}

.sidebar-submenu a.active {
    opacity: 1;
    border-left-color: var(--sidebar-accent);
}

.has-submenu .submenu-arrow {
    transition: transform 0.3s;
    font-size: 0.8rem;
}

.has-submenu[aria-expanded="true"] .submenu-arrow {
    transform: rotate(90deg);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 20px;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease, width 0.3s ease;
}

/* Contenedor fluido para máximo aprovechamiento de espacio */
.main-content > *:first-child {
    max-width: 100%;
}

.main-content .container,
.main-content .container-fluid {
    max-width: 100%;
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
}

/* Asegurar que todo el contenido ocupe el ancho */
.main-content * {
    max-width: 100%;
}

/* Cards */
.content-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    padding: 25px;
    border: 1px solid #e2e8f0;
}

.stat-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    padding: 20px;
    transition: all 0.2s;
    height: 100%;
    border: 1px solid #e2e8f0;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--sidebar-accent);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Overlay para móvil */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

@media (max-width: 992px) {
    /* FORZAR ancho total */
    html {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    body {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        position: relative !important;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        position: fixed !important;
        left: -280px !important;
    }

    .sidebar.show {
        transform: translateX(0) !important;
        left: 0 !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 100vw !important;
        padding: 15px 10px;
        position: relative !important;
        left: 0 !important;
        right: 0 !important;
    }

    .sidebar-toggle-btn {
        display: none !important;
    }

    /* Reset completo de contenedores */
    .container, .container-fluid, .main-content .container, .main-content .container-fluid {
        padding-left: 0 !important;
        padding-right: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        min-width: 100% !important;
    }

    /* Reset de Bootstrap rows */
    .row {
        margin-left: -10px !important;
        margin-right: -10px !important;
        width: calc(100% + 20px) !important;
    }

    .row > * {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Asegurar que las columnas ocupen todo el ancho */
    .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
        flex: 0 0 auto;
        width: 100% !important;
        max-width: 100% !important;
    }

    .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 {
        flex: 0 0 auto;
        width: 100% !important;
        max-width: 100% !important;
    }

    @media (min-width: 576px) {
        .col-sm-1 { width: 8.333333% !important; max-width: 8.333333% !important; }
        .col-sm-2 { width: 16.666667% !important; max-width: 16.666667% !important; }
        .col-sm-3 { width: 25% !important; max-width: 25% !important; }
        .col-sm-4 { width: 33.333333% !important; max-width: 33.333333% !important; }
        .col-sm-5 { width: 41.666667% !important; max-width: 41.666667% !important; }
        .col-sm-6 { width: 50% !important; max-width: 50% !important; }
        .col-sm-7 { width: 58.333333% !important; max-width: 58.333333% !important; }
        .col-sm-8 { width: 66.666667% !important; max-width: 66.666667% !important; }
        .col-sm-9 { width: 75% !important; max-width: 75% !important; }
        .col-sm-10 { width: 83.333333% !important; max-width: 83.333333% !important; }
        .col-sm-11 { width: 91.666667% !important; max-width: 91.666667% !important; }
        .col-sm-12 { width: 100% !important; max-width: 100% !important; }
    }

    /* Cards y tablas */
    .card, .table-responsive, .table {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* TABLAS RESPONSIVAS EN MÓVIL - Scroll horizontal */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .table {
        min-width: 100% !important;
        width: max-content !important;
    }

    /* Ajustar texto en tablas para mejor lectura */
    .table thead th,
    .table tbody td {
        white-space: nowrap !important;
    }

    /* Eliminar cualquier overflow EXCEPTO en tablas */
    .main-content, .container, .container-fluid, .row, .card, .btn, .alert, .form-control {
        overflow-x: visible !important;
    }
}

/* Media query específico para tablets */
@media (min-width: 577px) and (max-width: 992px) {
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .table {
        width: max-content !important;
        min-width: 100% !important;
    }
}

/* Media query para celulares pequeños */
@media (max-width: 576px) {
    html, body {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    .main-content {
        padding: 10px 5px !important;
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 100vw !important;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-card .stat-value {
        font-size: 1.8rem;
    }

    .row {
        margin-left: -5px !important;
        margin-right: -5px !important;
        width: calc(100% + 10px) !important;
    }

    .row > * {
        padding-left: 5px !important;
        padding-right: 5px !important;
    }

    /* Asegurar que todas las cards y tablas se vean bien */
    .card, .container, .container-fluid {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* TABLAS CON SCROLL HORIZONTAL EN MÓVIL */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
        margin: 0 !important;
        margin-bottom: 15px !important;
        border-radius: 8px;
        background: white;
        border: 1px solid #e5e7eb;
    }

    table {
        font-size: 0.85rem;
        width: max-content !important;
        min-width: 100% !important;
        margin-bottom: 0 !important;
    }

    /* Mejorar visibilidad de tabla en móvil */
    .table thead th {
        white-space: nowrap !important;
        font-size: 0.8rem;
        padding: 8px !important;
    }

    .table tbody td {
        white-space: nowrap !important;
        padding: 8px !important;
    }

    /* Botones de acción en tablas */
    .table .btn-group {
        white-space: nowrap !important;
    }

    .table .btn-sm {
        padding: 0.4rem 0.7rem !important;
        font-size: 0.75rem !important;
    }

    /* Indicador visual de scroll en tablas */
    .table-responsive::after {
        content: '← Desliza para ver más →';
        display: block;
        text-align: center;
        font-size: 0.7rem;
        color: #9ca3af;
        padding: 6px;
        background: linear-gradient(to bottom, #f9fafb, #f3f4f6);
        border-radius: 0 0 7px 7px;
        margin-top: 5px;
    }

    /* Botones en móvil */
    .btn {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }

    .btn-sm {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    /* Formularios en móvil */
    .form-control, .form-select {
        font-size: 1rem;
        width: 100% !important;
    }

    /* Modal en móvil */
    .modal-dialog {
        max-width: 95%;
        margin: 10px auto;
    }

    /* Eliminar overflow EXCEPTO en tablas */
    .main-content, .container, .container-fluid, .row, .card, .btn, .alert, .form-control, .modal-content {
        overflow-x: visible !important;
    }
}

/* Botón de toggle para PC */
.sidebar-toggle-btn {
    position: fixed;
    left: var(--sidebar-width);
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 60px;
    background: var(--sidebar-accent);
    border: none;
    border-radius: 0 8px 8px 0;
    color: white;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-btn:hover {
    background: var(--primary-color);
    width: 25px;
}

.sidebar-toggle-btn i {
    font-size: 0.8rem;
}

/* Cuando el sidebar está colapsado en PC */
.sidebar.collapsed {
    transform: translateX(calc(var(--sidebar-width) * -1));
}

.main-content.expanded {
    margin-left: 0;
}

.sidebar-toggle-btn.collapsed {
    left: 0;
    border-radius: 0 8px 8px 0;
}

/* Estilos para cards de Programaciones */
.programacion-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.programacion-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15) !important;
}

.programacion-card .card-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.programacion-card .info-item {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.programacion-card .info-item i {
    font-size: 1.1rem;
}
