/* =================================
   Dashboard de Encuestas ISPDN
   ================================= */

/* Variables CSS */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --info-color: #0dcaf0;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --border-radius: 8px;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --transition: all 0.3s ease;
}

/* Reset y base */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f6fa;
    color: var(--dark-color);
    line-height: 1.6;
}

/* Header personalizado */
.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

.navbar-text {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.375rem 0.75rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
}

/* Tarjetas de resumen */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    margin-bottom: 1.5rem;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.card-header {
    background-color: var(--light-color);
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.card-body {
    padding: 1.25rem;
}

/* Tarjetas de estadísticas */
.card.bg-primary,
.card.bg-success,
.card.bg-info,
.card.bg-warning {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
}

.card.bg-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #146c43 100%);
}

.card.bg-info {
    background: linear-gradient(135deg, var(--info-color) 0%, #087990 100%);
}

.card.bg-warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #cc9a00 100%);
    color: var(--dark-color) !important;
}

/* Botones mejorados */
.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: var(--transition);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    border: none;
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #146c43 100%);
    border: none;
}

/* Formularios */
.form-select,
.form-control {
    border-radius: var(--border-radius);
    border: 1px solid #ced4da;
    transition: var(--transition);
}

.form-select:focus,
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Tabla mejorada */
.table-responsive {
    border-radius: var(--border-radius);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
}

.table th {
    border-top: none;
    font-weight: 600;
    background-color: var(--dark-color);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table td {
    vertical-align: middle;
    padding: 0.75rem;
}

.table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* Badges para calificaciones */
.badge-score {
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.875rem;
}

.score-5 { background-color: var(--success-color); color: white; }
.score-4 { background-color: #20c997; color: white; }
.score-3 { background-color: var(--warning-color); color: var(--dark-color); }
.score-2 { background-color: #fd7e14; color: white; }
.score-1 { background-color: var(--danger-color); color: white; }

/* Loading y animaciones */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Gráficos */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

canvas {
    max-height: 300px !important;
}

/* Top docentes */
.docente-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
}

.docente-item:hover {
    transform: translateX(5px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

.docente-nombre {
    font-weight: 500;
    color: var(--dark-color);
    flex: 1;
}

.docente-especialidad {
    font-size: 0.875rem;
    color: var(--secondary-color);
    margin-top: 0.25rem;
}

.docente-score {
    font-weight: 600;
    font-size: 1.1rem;
    padding: 0.25rem 0.5rem;
    border-radius: 15px;
    min-width: 50px;
    text-align: center;
}

/* Comentarios */
.comentario-item {
    padding: 1rem;
    margin-bottom: 0.75rem;
    background-color: white;
    border-left: 4px solid var(--primary-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.comentario-header {
    font-size: 0.875rem;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
}

.comentario-texto {
    font-style: italic;
    color: var(--dark-color);
    line-height: 1.5;
}

/* =================================
   ESTILOS PARA MATRIZ DE TABULACIÓN
   ================================= */

/* Estilos específicos para la matriz de tabulación */
.matriz-table {
    font-size: 0.85em;
    margin-bottom: 0;
}

.matriz-table th {
    background-color: #198754 !important;
    color: white;
    font-weight: bold;
    text-align: center;
    vertical-align: middle;
    font-size: 0.8em;
    padding: 8px 4px;
}

.matriz-table td {
    vertical-align: middle;
    padding: 6px 4px;
    font-size: 0.8em;
}

.matriz-table .alternativa-cell {
    text-align: left !important;
    font-weight: 600;
    padding-left: 8px;
    min-width: 250px;
    max-width: 300px;
    word-wrap: break-word;
    line-height: 1.2;
}

.matriz-header h6 {
    font-size: 0.95em;
    margin-bottom: 10px;
    padding: 8px;
    background-color: #e3f2fd;
    border-radius: 4px;
    border-left: 4px solid #2196f3;
}

/* Pestañas de preguntas */
.nav-tabs .nav-link {
    font-size: 0.9em;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem 0.375rem 0 0;
}

.nav-tabs .nav-link.active {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
}

/* Responsive para matriz */
@media (max-width: 1200px) {
    .matriz-table {
        font-size: 0.75em;
    }
    
    .matriz-table th,
    .matriz-table td {
        padding: 4px 2px;
    }
    
    .matriz-table .alternativa-cell {
        min-width: 200px;
        max-width: 250px;
        font-size: 0.7em;
    }
}

@media (max-width: 768px) {
    .matriz-table {
        font-size: 0.65em;
    }
    
    .nav-tabs .nav-link {
        font-size: 0.8em;
        padding: 0.4rem 0.8rem;
    }
    
    .matriz-table .alternativa-cell {
        min-width: 150px;
        max-width: 200px;
        font-size: 0.65em;
    }
}

/* Colores mejorados para celdas de matriz */
.bg-success.text-white {
    background-color: #28a745 !important;
    color: white !important;
}

.bg-warning.text-dark {
    background-color: #ffc107 !important;
    color: #212529 !important;
}

.bg-light.text-dark {
    background-color: #f8f9fa !important;
    color: #212529 !important;
}

.bg-danger.text-white {
    background-color: #dc3545 !important;
    color: white !important;
}

/* =================================
   ESTILOS PARA REPORTE POR DOCENTE
   ================================= */

.reporte-docente {
    font-size: 0.9em;
}

.reporte-docente .pregunta-matriz {
    margin-bottom: 1.5rem;
    page-break-inside: avoid;
}

.reporte-docente .card {
    border: 1px solid #dee2e6;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.reporte-docente .card-header {
    padding: 0.5rem 1rem;
}

.reporte-docente .card-header h6 {
    font-size: 0.85em;
    line-height: 1.3;
    margin: 0;
}

.reporte-docente .card-body {
    padding: 0.5rem;
}

.reporte-docente table {
    font-size: 0.8em;
    margin-bottom: 0;
    width: 100%;
    table-layout: auto;
}

.reporte-docente th,
.reporte-docente td {
    padding: 4px 6px;
    font-size: 0.75em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.reporte-docente .table-responsive {
    overflow-x: auto;
    max-width: 100%;
}

.reporte-docente .table-bordered th,
.reporte-docente .table-bordered td {
    border: 1px solid #dee2e6;
}

/* Responsive para reporte de docente */
@media (max-width: 768px) {
    .reporte-docente {
        font-size: 0.8em;
    }
    
    .reporte-docente table {
        font-size: 0.7em;
    }
    
    .reporte-docente th,
    .reporte-docente td {
        padding: 2px 4px;
        font-size: 0.65em;
    }
}

/* Estilos para impresión del reporte de docente */
@media print {
    .reporte-docente .pregunta-matriz {
        page-break-inside: avoid;
        margin-bottom: 15px;
    }
    
    .reporte-docente .card {
        border: 1px solid #000;
        box-shadow: none;
        margin-bottom: 10px;
    }
    
    .reporte-docente .card-header {
        background-color: #28a745 !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
    }
}

/* Modal mejorado */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

.modal-header {
    background-color: var(--primary-color);
    color: white;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

/* Responsive */
@media (max-width: 768px) {
    .container-fluid {
        padding: 0.5rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    canvas {
        max-height: 250px !important;
    }
}

@media (max-width: 576px) {
    .navbar-brand {
        font-size: 1rem;
    }
    
    .card-body h2 {
        font-size: 1.5rem;
    }
    
    .docente-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .docente-score {
        margin-top: 0.5rem;
        align-self: center;
    }
}

/* Utilities adicionales */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer {
    cursor: pointer;
}

.border-start-primary {
    border-left: 4px solid var(--primary-color) !important;
}

.border-start-success {
    border-left: 4px solid var(--success-color) !important;
}

.border-start-warning {
    border-left: 4px solid var(--warning-color) !important;
}

.border-start-danger {
    border-left: 4px solid var(--danger-color) !important;
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    body {
        background-color: white !important;
    }
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* =================================
   SIDEBAR NAVIGATION
   ================================= */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 48px 0 0;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    background-color: #f8f9fa;
    width: 250px;
    transition: all 0.3s ease;
    overflow-x: hidden;
}

.sidebar.collapsed {
    width: 60px !important;
}

.sidebar .nav-link {
    color: #333;
    font-weight: 500;
    padding: 12px 16px;
    transition: all 0.3s;
    border-radius: 0;
    display: flex;
    align-items: center;
    position: relative;
    white-space: nowrap;
}

.sidebar .nav-link:hover {
    color: #0d6efd;
    background-color: rgba(0, 0, 0, .05);
}

.sidebar .nav-link.active {
    color: #0d6efd;
    background-color: rgba(13, 110, 253, .1);
    border-left: 3px solid #0d6efd;
}

.sidebar .nav-link i {
    margin-right: 8px;
    width: 16px;
    text-align: center;
    min-width: 20px;
    flex-shrink: 0;
}

.sidebar-heading {
    font-size: .75rem;
    text-transform: uppercase;
    font-weight: 600;
    color: #6c757d;
    transition: all 0.3s ease;
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

/* Botón toggle del sidebar */
#toggleSidebar {
    border: 1px solid #0d6efd;
    color: #0d6efd;
    background: white;
    transition: all 0.3s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#toggleSidebar:hover {
    background-color: #0d6efd;
    color: white;
}

/* Ocultar texto cuando está colapsado */
.sidebar.collapsed .nav-text,
.sidebar.collapsed .sidebar-heading span,
.sidebar.collapsed .sidebar-title {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Tooltip para sidebar colapsado */
.sidebar.collapsed .nav-link {
    position: relative;
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .nav-link:hover::after {
    content: attr(data-title);
    position: absolute;
    left: 65px;
    top: 50%;
    transform: translateY(-50%);
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 1000;
    font-size: 12px;
}

/* Ajuste del contenido principal */
main, .main-content {
    margin-left: 250px;
    transition: all 0.3s ease;
    padding: 1rem;
    min-height: 100vh;
    max-width: calc(100vw - 250px);
    overflow-x: auto;
}

main.collapsed, .main-content.collapsed {
    margin-left: 60px;
    max-width: calc(100vw - 60px);
}

.content-section {
    min-height: 100vh;
    padding: 20px 0;
}

/* =================================
   COMENTARIOS DE ESTUDIANTES
   ================================= */
.comentario-item {
    background-color: #f8f9fa;
    border-left: 4px solid #0d6efd;
    transition: all 0.3s ease;
}

.comentario-item:hover {
    background-color: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.comentario-item h6 {
    color: #0d6efd;
    font-weight: 600;
}

.comentario-item p {
    line-height: 1.6;
    color: #495057;
    font-style: italic;
}

.comentario-item small {
    color: #6c757d;
    font-size: 0.85em;
}

/* Cards de estadísticas de comentarios */
.card.bg-primary .card-body {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
}

.card.bg-success .card-body {
    background: linear-gradient(135deg, #198754 0%, #146c43 100%);
}

.card.bg-info .card-body {
    background: linear-gradient(135deg, #0dcaf0 0%, #0aa2c0 100%);
}

.card.bg-warning .card-body {
    background: linear-gradient(135deg, #ffc107 0%, #d39e00 100%);
}

/* Responsive para comentarios */
@media (max-width: 768px) {
    .comentario-item {
        margin-bottom: 1rem;
    }
    
    .comentario-item h6 {
        font-size: 0.9rem;
    }
    
    .comentario-item p {
        font-size: 0.85rem;
    }
}

/* FIX ESPECIALIDADES - Texto visible */
.docente-especialidad, 
.especialidad-row,
.especialidad-header,
.reporte-docente .especialidad-header {
    background-color: #e3f2fd !important;
    color: #1565c0 !important;
    font-weight: bold !important;
    text-align: left !important;
    padding: 12px !important;
    border: 2px solid #2196f3 !important;
}

.reporte-docente .ciclo-subheader {
    background-color: #f5f5f5 !important;
    color: #424242 !important;
    font-weight: 600;
    text-align: left !important;
    padding-left: 20px !important;
    border: 1px solid #bdbdbd !important;
}

/* Asegurar visibilidad en modo oscuro también */
@media (prefers-color-scheme: dark) {
    .docente-especialidad, 
    .especialidad-row,
    .especialidad-header,
    .reporte-docente .especialidad-header {
        background-color: #1976d2 !important;
        color: #ffffff !important;
        font-weight: bold !important;
    }
    
    .reporte-docente .ciclo-subheader {
        background-color: #424242 !important;
        color: #ffffff !important;
    }
}

/* Responsive para el sidebar */
@media (max-width: 767.98px) {
    .sidebar {
        position: relative;
        top: auto;
        bottom: auto;
        left: auto;
        padding: 0;
        width: 100% !important;
        box-shadow: none;
        border-bottom: 1px solid #dee2e6;
    }
    
    .sidebar .nav-link {
        padding: 10px 15px;
    }
    
    main.col-md-9 {
        margin-left: 0 !important;
        padding-left: 15px;
        padding-right: 15px;
    }
}

/* Responsive para móvil */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 250px !important;
        z-index: 1000;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    main, .main-content {
        margin-left: 0 !important;
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    
    #toggleSidebar {
        position: fixed;
        top: 70px;
        left: 15px;
        z-index: 1001;
        background: #0d6efd;
        color: white;
        border: none;
    }
}

/* Impresión - ocultar sidebar */
@media print {
    .sidebar {
        display: none !important;
    }
    
    main.col-md-9 {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .docente-especialidad, 
    .especialidad-row,
    .especialidad-header,
    .reporte-docente .especialidad-header {
        background-color: #e0e0e0 !important;
        color: #000000 !important;
        border: 2px solid #000000 !important;
    }
    
    .reporte-docente .ciclo-subheader {
        background-color: #f0f0f0 !important;
        color: #000000 !important;
        border: 1px solid #000000 !important;
    }
}
