/* 
  public/assets/css/admin-tutor-ia.css
  Estilos específicos para el monitoreo de TutorIA 
*/

.stat-card h4 {
    font-size: 11px;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 1.2px;
    margin-bottom: 10px;
    font-weight: 700;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    color: #1B396A;
}

.users-table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    padding: 25px;
    margin-top: 20px;
    border-top: 1px solid #f1f5f9;
}

.nc-badge {
    background: #1B396A;
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-family: monospace;
    font-size: 11px;
}

.credit-bar-wrap {
    width: 100%;
    max-width: 120px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 8px;
}

.credit-bar-fill {
    height: 100%;
    transition: width 0.5s;
}

.btn-action {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 2px;
    border: none;
    transition: all 0.2s;
}

.btn-reset {
    background: #f0f9ff;
    color: #0369a1;
}

.btn-reset:hover {
    background: #0369a1;
    color: white;
}

.btn-delete {
    background: #fef2f2;
    color: #b91c1c;
}

.btn-delete:hover {
    background: #b91c1c;
    color: white;
}

.search-wrap {
    position: relative;
}

.search-wrap i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

.search-input {
    padding-left: 45px !important;
    border-radius: 8px !important;
    height: 45px;
    border: 1px solid #e2e8f0;
}

.filter-select {
    height: 45px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-size: 14px;
    color: #475569;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
}

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

.btn-refresh-admin {
    background: #1B396A;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-refresh-admin:hover {
    background: #142a50;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-danger-admin {
    background: #fff1f2;
    color: #e11d48;
    border: 1px solid #fda4af;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-danger-admin:hover {
    background: #e11d48;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.2);
}

.table thead th {
    background: #f8fafc;
    padding: 15px;
    font-size: 11px;
    font-weight: 700;
    color: #1B396A;
    border-bottom: 2px solid #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.table tbody td {
    padding: 18px 15px;
    font-size: 13px;
    border-bottom: 1px solid #f1f5f9;
    color: #475569;
    vertical-align: middle;
}

/* Anchos de columnas (antes inline en <th>) */
.th-sem { width: 50px; }
.th-fecha-envio { width: 140px; }
.th-tono { width: 110px; }
.th-fb-fecha { width: 150px; }
.th-fb-alumno { width: 100px; }
.th-fb-rating { width: 80px; }

/* Programa Semestral Styles */
.program-table thead th {
    background: #f1f5f9 !important;
}

.program-week-row td {
    padding: 10px 15px !important;
}

.week-badge {
    background: #e2e8f0;
    color: #475569;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 12px;
}

.program-input {
    border-radius: 6px !important;
    border: 1px solid #e2e8f0;
    padding: 6px 10px;
    font-size: 12px;
    width: 100%;
    transition: all 0.2s;
}

.program-input:focus {
    border-color: #1B396A;
    outline: none;
    box-shadow: 0 0 0 3px rgba(27, 57, 106, 0.1);
}

.program-select {
    border-radius: 6px !important;
    border: 1px solid #e2e8f0;
    padding: 4px 8px;
    font-size: 12px;
    background: #f8fafc;
    height: 32px;
    cursor: pointer;
}

.admin-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.admin-input {
    height: 40px;
    border-radius: 6px !important;
}

.status-badge-container {
    height: 40px;
    display: flex;
    align-items: center;
}

.badge-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-online {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.status-offline {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.panel-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 15px;
}

/* RAG Upload Styles */
#ragFileInput {
    display: none;
}

.rag-select-btn {
    margin-top: 15px;
    width: 100%;
}

#ragFileName {
    font-size: 12px;
    color: #1B396A;
    font-weight: 600;
}

.stats-help-text-bottom {
    margin-top: 15px;
    margin-bottom: 0;
}

/* Modal de detalle de feedback (antes inline) */
#feedbackModal .modal-content {
    border-radius: 15px;
    border: none;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

#feedbackModal .modal-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 15px 15px 0 0;
}

#feedbackModal .modal-title {
    color: #1B396A;
    font-weight: 800;
}

#feedbackModal .btn-close {
    background: none;
    border: none;
    font-size: 20px;
}

#feedbackModal .modal-body {
    padding: 30px;
}

#modalQuestion {
    background: #f1f5f9;
    padding: 15px;
    border-radius: 10px;
    color: #1e293b;
    font-size: 14px;
    border-left: 4px solid #1B396A;
}

#modalAnswer {
    background: #fff;
    padding: 15px;
    border-radius: 10px;
    color: #475569;
    font-size: 14px;
    border: 1px solid #e2e8f0;
    white-space: pre-wrap;
}

#modalMeta {
    font-size: 12px;
    color: #94a3b8;
}

.upload-rag-box {
    border: 2px dashed #e2e8f0;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    background: #f8fafc;
    transition: all 0.3s;
}

.upload-rag-box:hover {
    border-color: #1B396A;
    background: #f1f5f9;
}

.rag-upload-icon {
    font-size: 40px;
    color: #1B396A;
    margin-bottom: 15px;
}

.rag-upload-text strong {
    display: block;
    font-size: 14px;
    color: #1e293b;
    margin-bottom: 5px;
}

.rag-upload-text span {
    font-size: 12px;
    color: #64748b;
}

.rag-info-panel {
    background: #f8fafc;
    border-radius: 12px;
    padding: 25px;
    height: 100%;
    border: 1px solid #e2e8f0;
}

.rag-tips {
    list-style: none;
    padding: 0;
    margin: 0;
}

.rag-tips li {
    font-size: 13px;
    color: #475569;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.rag-tips li i {
    color: #1B396A;
    font-size: 16px;
}

.rag-tips code {
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    color: #1B396A;
    font-weight: 700;
}

/* 
   Responsividad y Ajustes para Móvil 
*/

/* Eliminar flecha indicadora de scroll que confunde al usuario */
.table-responsive::after {
    display: none !important;
}

@media (max-width: 991px) {
    .section-header-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .header-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .header-actions button {
        padding: 12px 5px;
        font-size: 11px;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-card .stat-value {
        font-size: 20px;
    }

    /* Optimización de Tablas - TODO DEBE CABER EN PANTALLA (PC) */
    .table-responsive {
        overflow-x: auto;
        /* Cambiado a auto para permitir scroll si el contenido lo requiere */
        margin-bottom: 30px;
        border-radius: 12px;
        background: white;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.02);
        width: 100% !important;
    }

    /* En PC (Pantallas grandes) ocultamos el scroll si cabe */
    @media (min-width: 992px) {
        .table-responsive {
            overflow-x: auto; /* Permitir scroll solo si es estrictamente necesario */
        }

        .table {
            table-layout: auto; /* Cambiado de fixed para que las columnas se adapten mejor */
        }
    }

    .table {
        width: 100% !important;
        margin-bottom: 0;
    }

    .table thead th {
        padding: 18px 10px;
        font-size: 10px;
        font-weight: 800;
        text-transform: uppercase;
        color: #1B396A;
        background: #f8fafc;
        border-bottom: 2px solid #edf2f7;
    }

    .table tbody td {
        padding: 15px 10px;
        font-size: 13px;
        vertical-align: middle;
        border-bottom: 1px solid #f1f5f9;
        white-space: nowrap;
    }

    /* Definir anchos fijos para columnas en la tabla de feedback */
    .feedback-table th:nth-child(1),
    .feedback-table td:nth-child(1) {
        width: 120px;
    }

    .feedback-table th:nth-child(2),
    .feedback-table td:nth-child(2) {
        width: 100px;
    }

    .feedback-table th:nth-child(5),
    .feedback-table td:nth-child(5) {
        width: 80px;
    }

    .feedback-table th:nth-child(6),
    .feedback-table td:nth-child(6) {
        width: 40px;
    }

    /* Forzar ancho mínimo en móvil para evitar que se apriete */
    @media (max-width: 991px) {
        .table:not(.program-table) {
            min-width: 900px !important;
        }

        .program-table {
            min-width: 500px !important; /* Más pequeño para las tablas de programa */
        }

        .table-responsive {
            overflow-x: auto !important;
        }
    }
}

.clickable-row {
    cursor: pointer;
    transition: all 0.3s ease;
}

.clickable-row:hover {
    background: #f8fafc !important;
    box-shadow: inset 4px 0 0 #1B396A;
}

.text-truncate {
    max-width: 400px;
    /* Aumentado para que la tabla use más espacio en PC */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 991px) {
    .text-truncate {
        max-width: 150px;
        /* Más pequeño en móvil */
    }
}

/* Badge Refinado */
.nc-badge {
    background: #1B396A;
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 2px 5px rgba(27, 57, 106, 0.2);
}


/* Ajustes para Tablas de Programa (Proactiva) */
.program-table {
    margin-bottom: 0;
}

.program-table th, .program-table td {
    padding: 12px 8px !important;
}

.program-table th:nth-child(1),
.program-table td:nth-child(1) {
    width: 45px !important;
}

.program-table th:nth-child(2),
.program-table td:nth-child(2) {
    width: 130px !important;
}

.program-table th:nth-child(4),
.program-table td:nth-child(4) {
    width: 120px !important;
}

/* Fix para el botón de Borrar y Editar y el header */
.panel-header-flex .header-actions .btn-sm {
    padding: 6px 12px;
    font-size: 11px;
    border-radius: 6px;
}

.action-admin-btn {
    background: #1B396A;
    color: white;
    border: none;
    transition: all 0.3s;
    font-weight: 700;
}

.action-admin-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.program-input,
.program-select {
    font-size: 11px !important;
    padding: 4px 8px !important;
    height: 34px !important;
}

.week-badge {
    font-size: 10px !important;
    padding: 2px 6px !important;
}


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

    /* En pantallas muy pequeñas, ocultamos columnas menos críticas */
    .feedback-table th:nth-child(1),
    .feedback-table td:nth-child(1) {
        display: none;
    }

    /* Ocultar fecha */
}

/* ==========================================================================
   Gestión Dinámica de Créditos
   ========================================================================== */
.global-credits-panel {
    background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px 22px;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.global-credits-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.global-credits-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #1B396A;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.global-credits-title {
    font-weight: 700;
    font-size: 15px;
    color: #1e293b;
    margin-bottom: 3px;
}

.global-credits-desc {
    font-size: 12px;
    color: #64748b;
    margin: 0;
}

.global-credits-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.global-credits-input {
    width: 90px;
    height: 38px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    color: #1e293b;
    background: white;
}

.global-credits-input:disabled {
    background: #f1f5f9;
    color: #94a3b8;
}

.global-credits-unlimited-label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    margin: 0 5px;
    user-select: none;
}

.btn-edit-credits {
    background: #e0f2fe;
    color: #0284c7;
}

.btn-edit-credits:hover {
    background: #0284c7;
    color: white;
}

.badge-unlimited {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    color: white;
    padding: 3px 9px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.25);
}

.badge-custom-limit {
    background: #f1f5f9;
    color: #475569;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
}