/* Reset y variables - Bootstrap ya incluye reset básico */

:root {
    --primary-color: #4a90e2;
    --primary-dark: #357abd;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #333;
    --text-light: #666;
    --border-color: #dee2e6;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header - Bootstrap ya maneja el layout */
header {
    background: var(--card-bg);
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

/* Botones */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

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

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

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

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

.btn-danger:hover {
    background-color: #c82333;
}

/* Layout principal */
.main-content {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.sidebar h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--text-color);
}

.campus-list {
    margin-bottom: 15px;
}

.campus-item {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 10px;
    background: var(--bg-color);
    transition: all 0.2s;
}

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

.campus-item.selected {
    border-color: var(--primary-color);
    background: #e8f4fd;
}

.campus-item label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
}

.campus-item input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.campus-info {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-light);
}

.campus-actions {
    margin-top: 8px;
    display: flex;
    gap: 5px;
}

.campus-actions button {
    padding: 4px 8px;
    font-size: 11px;
}

.sidebar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sidebar .sidebar-actions:first-of-type {
    margin-bottom: 10px;
}

.loading {
    text-align: center;
    color: var(--text-light);
    padding: 20px;
}

/* Contenido principal */
.content {
    flex: 1;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 30px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-light);
    transition: all 0.3s;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

/*
 * Solo las pestañas del panel principal (main.content); no usar .tab-content a secas
 * porque Bootstrap también usa esa clase en modales (p. ej. Calificaciones / Bitácora).
 */
main.content > .tab-content {
    display: none;
}

main.content > .tab-content.active {
    display: block;
}

/* Banner de carga: consulta lenta a campus Moodle */
.reports-loading-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 16px;
    border: 1px solid rgba(74, 144, 226, 0.35);
    border-radius: 10px;
    background: rgba(74, 144, 226, 0.08);
    color: var(--text-color, inherit);
}

.reports-loading-spinner {
    flex-shrink: 0;
    margin-top: 2px;
    color: #4a90e2;
}

.reports-loading-text {
    line-height: 1.45;
    font-size: 0.95rem;
}

/* Avance por campus (reporte certificados) — debajo del mensaje de paciencia */
.reports-progress-area {
    margin-bottom: 18px;
    padding: 0 2px;
}

.reports-progress-block + .reports-progress-block {
    margin-top: 14px;
}

.reports-progress-heading {
    font-weight: 500;
}

.reports-progress-track {
    height: 10px;
    border-radius: 8px;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.08);
}

.reports-progress-label {
    margin-top: 8px;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--text-muted, #6c757d);
}

/* Parámetros colapsables en la tarjeta de reporte */
.report-card--with-params:not(.report-card--params-expanded) {
    cursor: pointer;
}

.report-card--with-params:not(.report-card--params-expanded) > .report-card-heading,
.report-card--with-params:not(.report-card--params-expanded) > .report-card-desc {
    cursor: pointer;
}

.report-card--with-params.report-card--params-expanded {
    cursor: default;
}

.report-card--with-params.report-card--params-expanded:hover,
.report-card--with-params.report-card--params-expanded:focus-visible {
    transform: none;
    box-shadow: none;
    border-color: var(--border-color);
    background: var(--card-bg);
}

.report-card--with-params.report-card--params-expanded > .report-card-heading,
.report-card--with-params.report-card--params-expanded > .report-card-desc {
    cursor: default;
}

.report-card-params {
    width: 100%;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color, #dee2e6);
}

.report-card-params-body {
    padding: 10px 4px 4px;
}

.report-card-params-toggle[aria-expanded="true"] .report-card-params-chevron {
    transform: rotate(180deg);
}

.report-card-params-chevron {
    transition: transform 0.2s ease;
}

/* Tarjetas de reportes */
.report-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.report-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 14px 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    cursor: pointer;
    min-height: 120px;
}

.report-card:hover,
.report-card:focus-visible {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(74, 144, 226, 0.45);
    background: rgba(74, 144, 226, 0.05);
}

.report-card:focus-visible {
    outline: 2px solid rgba(74, 144, 226, 0.55);
    outline-offset: 2px;
}

.report-card:active {
    transform: translateY(0);
}

.report-card--active {
    border-color: rgba(74, 144, 226, 0.65);
    background: rgba(74, 144, 226, 0.1);
    box-shadow: var(--shadow-md);
}

.report-card-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    width: 100%;
}

.report-card-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.15) 0%, rgba(74, 144, 226, 0.08) 100%);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: transform 0.2s ease, background 0.2s ease;
}

.report-card:hover .report-card-icon,
.report-card:focus-visible .report-card-icon {
    transform: scale(1.05);
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.2) 0%, rgba(74, 144, 226, 0.12) 100%);
}

.report-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
    line-height: 1.25;
}

.report-card-desc {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.35;
    margin: 0;
    flex: 1;
}

.report-card.is-loading {
    opacity: 0.75;
    pointer-events: none;
    cursor: wait;
}

/* Formularios */
.search-form {
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.access-review-table-wrap {
    max-width: 100%;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Resultados */
.results {
    margin-top: 30px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.results-header h3 {
    font-size: 20px;
}

.badge {
    background: var(--primary-color);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.results-content {
    max-height: 600px;
    overflow-y: auto;
    margin-top: 20px;
}

/* DataTables compacto */
#resultsTable,
.revision-table {
    font-size: 13px;
}

#resultsTable td,
.revision-table td {
    padding: 8px 10px;
}

#resultsTable thead th,
.revision-table thead th {
    padding: 10px;
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

/* Enlaces de cursos */
.course-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.course-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.dt-buttons {
    margin-bottom: 15px;
}

.dt-button {
    background-color: var(--primary-color) !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 6px !important;
    margin-right: 5px !important;
}

.dt-button:hover {
    background-color: var(--primary-dark) !important;
}

.result-item {
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 10px;
    background: var(--bg-color);
}

.result-item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.result-item-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-color);
}

.result-item-campus {
    font-size: 12px;
    color: var(--text-light);
    background: var(--card-bg);
    padding: 4px 8px;
    border-radius: 4px;
}

.result-item-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    font-size: 14px;
    color: var(--text-light);
}

.result-item-details strong {
    color: var(--text-color);
}

/*
 * Modales: usar solo el comportamiento de Bootstrap 5 (.modal.fade + .modal-dialog).
 * No definir aquí .modal ni .modal.show (posición, z-index, fondo): rompe el apilado
 * (backdrop ~1050 encima del contenido ~1000) y deja la pantalla bloqueada en gris.
 */
.modal-content {
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
}

.close {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: var(--text-color);
}

.modal-form {
    padding: 30px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Loading overlay - debe estar por debajo de los modales de Bootstrap */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1040; /* Bootstrap modals usan 1050, así que esto debe ser menor */
    color: white;
    pointer-events: auto;
}

/* No forzar z-index en .modal globalmente: rompe el apilado de varios modales (p. ej. detalle de curso sobre admin. usuario). */

#userAdminModal .modal-dialog,
#userAdminCourseDetailModal .modal-dialog {
    width: 90vw;
    max-width: 1200px;
}

/* El .modal-content global fija max-width: 600px; aquí lo anulamos para este modal */
#userAdminModal .modal-content,
#userAdminCourseDetailModal .modal-content {
    width: 100%;
    max-width: none;
}

.loading-overlay-content {
    max-width: 420px;
}

.loading-progress-bar-track {
    width: 100%;
    max-width: 320px;
    height: 10px;
}

.loading-progress-wrap .progress-bar {
    background-color: var(--primary-color, #4a90e2);
}

.spinner {
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mensajes */
.alert {
    padding: 12px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: static;
        max-height: none;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    #userAdminModal .modal-dialog,
    #userAdminCourseDetailModal .modal-dialog {
        width: 95vw;
        max-width: 95vw;
        margin-left: auto;
        margin-right: auto;
    }
}

