/**
 * Sistema de Boletas Escolares
 * Estilos CSS Personalizados
 * Compatible con móviles, tablets y PC
 */

/* =====================================================
   VARIABLES CSS
   ===================================================== */
:root {
    --primary-color: #1a56db;
    --primary-dark: #1e429f;
    --primary-light: #3f83f8;
    --secondary-color: #6b7280;
    --success-color: #059669;
    --warning-color: #d97706;
    --danger-color: #dc2626;
    --info-color: #0891b2;
    
    --body-bg: #f3f4f6;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    
    --border-color: #e5e7eb;
    --border-radius: 0.5rem;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --navbar-height: 64px;
    --sidebar-width: 280px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--body-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =====================================================
   NAVBAR
   ===================================================== */
.navbar {
    height: var(--navbar-height);
    box-shadow: var(--shadow);
    z-index: 1030;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.1rem;
}

.navbar-brand img {
    max-height: 40px;
    width: auto;
}

/* =====================================================
   CONTENIDO PRINCIPAL
   ===================================================== */
.main-content {
    margin-top: var(--navbar-height);
    flex: 1;
    padding-bottom: 2rem;
}

.main-content-full {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

/* =====================================================
   TARJETAS
   ===================================================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--text-primary);
}

.card-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Stats Cards */
.stat-card {
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s ease;
}

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

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card .stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* =====================================================
   FORMULARIOS
   ===================================================== */
.form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.form-control,
.form-select {
    border-color: var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-text {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* Textarea para descripciones */
textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

textarea.form-control.descripcion-larga {
    min-height: 200px;
}

/* =====================================================
   BOTONES
   ===================================================== */
.btn {
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: all 0.15s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.table th {
    background-color: #f9fafb;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

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

/* DataTables Responsive */
.dataTables_wrapper {
    padding: 1rem 0;
}

.dataTables_filter input {
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
}

.dataTables_length select {
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 0.375rem 2rem 0.375rem 0.75rem;
}

/* =====================================================
   BADGES
   ===================================================== */
.badge {
    font-weight: 500;
    padding: 0.375rem 0.625rem;
    border-radius: 9999px;
}

.badge-nivel-inicial {
    background-color: #fef2f2;
    color: #dc2626;
}

.badge-nivel-proceso {
    background-color: #fffbeb;
    color: #d97706;
}

.badge-nivel-avanzado {
    background-color: #ecfdf5;
    color: #059669;
}

.badge-nivel-consolidado {
    background-color: #eff6ff;
    color: #1d4ed8;
}

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

.alert-success {
    background-color: #ecfdf5;
    color: #065f46;
}

.alert-danger {
    background-color: #fef2f2;
    color: #991b1b;
}

.alert-warning {
    background-color: #fffbeb;
    color: #92400e;
}

.alert-info {
    background-color: #eff6ff;
    color: #1e40af;
}

/* =====================================================
   SELECT2 CUSTOMIZATION
   ===================================================== */
.select2-container--bootstrap-5 .select2-selection {
    border-color: var(--border-color);
    border-radius: var(--border-radius);
    min-height: 42px;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    padding: 0.5rem 0.75rem;
}

/* =====================================================
   MODAL
   ===================================================== */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

.modal-title {
    font-weight: 600;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

/* =====================================================
   LOGIN PAGE
   ===================================================== */
.login-container {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
}

.login-card {
    background: var(--card-bg);
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
}

.login-logo {
    width: 100px;
    height: auto;
    margin-bottom: 1.5rem;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* =====================================================
   DASHBOARD
   ===================================================== */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.welcome-banner h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.welcome-banner p {
    opacity: 0.9;
    margin-bottom: 0;
}

/* =====================================================
   BOLETA PREVIEW
   ===================================================== */
.boleta-preview {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.boleta-header {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--text-primary);
}

.boleta-logo {
    width: 80px;
    height: auto;
    margin-right: 1rem;
}

.boleta-info-institucion {
    flex: 1;
}

.boleta-info-institucion h2 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.boleta-info-institucion p {
    font-size: 0.75rem;
    margin-bottom: 0.125rem;
    color: var(--text-secondary);
}

.boleta-info-escolar {
    text-align: right;
}

.boleta-titulo {
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 1.5rem 0;
    text-decoration: underline;
}

.boleta-campo {
    margin-bottom: 0.75rem;
}

.boleta-campo label {
    font-weight: 600;
    display: inline;
}

.boleta-campo span {
    border-bottom: 1px solid var(--text-primary);
    padding-left: 0.5rem;
    padding-right: 2rem;
}

.boleta-descripcion {
    border: 1px solid var(--border-color);
    padding: 1rem;
    min-height: 200px;
    margin: 1rem 0;
    text-align: justify;
    line-height: 1.8;
}

.boleta-sugerencias {
    border: 1px solid var(--border-color);
    padding: 1rem;
    min-height: 100px;
    margin: 1rem 0;
}

.boleta-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 1rem;
}

.boleta-asistencia {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin: 1.5rem 0;
}

.boleta-asistencia div {
    text-align: center;
}

.boleta-firma {
    text-align: center;
    margin-top: 3rem;
}

.boleta-firma-linea {
    border-top: 1px solid var(--text-primary);
    width: 200px;
    margin: 0 auto;
    padding-top: 0.5rem;
}

/* =====================================================
   EVALUACIÓN DE INDICADORES
   ===================================================== */
.indicador-card {
    border-left: 4px solid var(--border-color);
    margin-bottom: 1rem;
    transition: border-color 0.2s ease;
}

.indicador-card.nivel-inicial {
    border-left-color: #dc2626;
}

.indicador-card.nivel-proceso {
    border-left-color: #d97706;
}

.indicador-card.nivel-avanzado {
    border-left-color: #059669;
}

.indicador-card.nivel-consolidado {
    border-left-color: #1d4ed8;
}

.indicador-dimension {
    font-weight: 600;
    color: var(--text-primary);
}

.indicador-descripcion {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Radio buttons personalizados para niveles */
.nivel-radio-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nivel-radio {
    display: none;
}

.nivel-radio + label {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.15s ease;
}

.nivel-radio:checked + label {
    color: white;
}

.nivel-radio[value="1"]:checked + label {
    background-color: #dc2626;
    border-color: #dc2626;
}

.nivel-radio[value="2"]:checked + label {
    background-color: #d97706;
    border-color: #d97706;
}

.nivel-radio[value="3"]:checked + label {
    background-color: #059669;
    border-color: #059669;
}

.nivel-radio[value="4"]:checked + label {
    background-color: #1d4ed8;
    border-color: #1d4ed8;
}

/* =====================================================
   FOOTER
   ===================================================== */
.footer {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

/* =====================================================
   LOADER / SPINNER
   ===================================================== */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loader {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =====================================================
   IA GENERATION
   ===================================================== */
.ia-generating {
    position: relative;
}

.ia-generating::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ia-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.ia-badge i {
    font-size: 0.875rem;
}

/* =====================================================
   RESPONSIVE - TABLETS (768px - 1024px)
   ===================================================== */
@media (max-width: 1024px) {
    .stat-card .stat-number {
        font-size: 1.5rem;
    }
    
    .boleta-preview {
        padding: 1.5rem;
    }
    
    .boleta-header {
        flex-direction: column;
        text-align: center;
    }
    
    .boleta-logo {
        margin: 0 auto 1rem;
    }
    
    .boleta-info-escolar {
        text-align: center;
        margin-top: 1rem;
    }
}

/* =====================================================
   RESPONSIVE - MÓVILES (< 768px)
   ===================================================== */
@media (max-width: 767.98px) {
    :root {
        --navbar-height: 56px;
    }
    
    body {
        font-size: 0.875rem;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
    
    .navbar-brand img {
        max-height: 32px;
    }
    
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .card {
        border-radius: 0.375rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .welcome-banner {
        padding: 1.5rem;
    }
    
    .welcome-banner h1 {
        font-size: 1.25rem;
    }
    
    .stat-card {
        margin-bottom: 0.75rem;
    }
    
    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .stat-card .stat-number {
        font-size: 1.25rem;
    }
    
    .table-responsive {
        font-size: 0.8125rem;
    }
    
    .btn {
        padding: 0.5rem 0.875rem;
    }
    
    .btn-icon {
        width: 34px;
        height: 34px;
    }
    
    /* Login móvil */
    .login-container {
        padding: 1rem;
    }
    
    .login-card {
        padding: 1.5rem;
        border-radius: 0.75rem;
    }
    
    .login-logo {
        width: 80px;
    }
    
    .login-title {
        font-size: 1.25rem;
    }
    
    /* Boleta móvil */
    .boleta-preview {
        padding: 1rem;
        font-size: 0.8125rem;
    }
    
    .boleta-titulo {
        font-size: 1rem;
    }
    
    .boleta-asistencia {
        flex-direction: column;
        gap: 1rem;
    }
    
    .boleta-footer {
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Indicadores móvil */
    .nivel-radio-group {
        justify-content: center;
    }
    
    .nivel-radio + label {
        padding: 0.5rem 0.625rem;
        font-size: 0.8125rem;
    }
    
    /* Modal móvil */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    /* DataTables móvil */
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        text-align: center;
        margin-bottom: 1rem;
    }
    
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: center;
        margin-top: 1rem;
    }
}

/* =====================================================
   RESPONSIVE - MÓVILES PEQUEÑOS (< 576px)
   ===================================================== */
@media (max-width: 575.98px) {
    .row > [class*="col-"] {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .btn-group-responsive {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-group-responsive .btn {
        width: 100%;
    }
    
    .d-flex.gap-2 {
        gap: 0.5rem !important;
    }
    
    /* Ocultar columnas menos importantes en tablas */
    .table .d-none-mobile {
        display: none;
    }
}

/* =====================================================
   PRINT STYLES
   ===================================================== */
@media print {
    .navbar,
    .footer,
    .btn,
    .no-print {
        display: none !important;
    }
    
    .main-content {
        margin-top: 0;
        padding: 0;
    }
    
    .card {
        border: none;
        box-shadow: none;
    }
    
    .boleta-preview {
        border: none;
        padding: 0;
        max-width: 100%;
    }
    
    body {
        background: white;
        font-size: 11pt;
    }
    
    .boleta-descripcion,
    .boleta-sugerencias {
        border: 1px solid #000;
    }
}

/* =====================================================
   UTILIDADES ADICIONALES
   ===================================================== */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer {
    cursor: pointer;
}

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

.transition-all {
    transition: all 0.2s ease;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}
