/**
 * FACIALTEC - Estilos del Historial v3.0
 */

/* =====================================================
   BOTÓN HISTORIAL EN HEADER
   ===================================================== */
.btn-history {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: rgba(154, 108, 255, 0.15);
    border: 1px solid rgba(154, 108, 255, 0.3);
    border-radius: 25px;
    color: #9a6cff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-history:hover {
    background: rgba(154, 108, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(154, 108, 255, 0.3);
}

.btn-history i {
    font-size: 16px;
}

@media (max-width: 480px) {
    .btn-history span {
        display: none;
    }
    .btn-history {
        padding: 10px 12px;
    }
}

/* =====================================================
   CARD HISTORIAL
   ===================================================== */
.history-card {
    max-width: 1200px;
    margin: 0 auto;
    padding: 25px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.history-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-header h2 i {
    color: #9a6cff;
}

/* =====================================================
   FILTROS
   ===================================================== */
.history-filters {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.filter-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-group {
    flex: 1;
    min-width: 180px;
}

.filter-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 6px;
}

.filter-group .form-input,
.filter-group .form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    background: white;
}

.filter-group .form-input:focus,
.filter-group .form-select:focus {
    border-color: #9a6cff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(154, 108, 255, 0.1);
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    min-width: 250px;
}

.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}

/* =====================================================
   TABLA DE HISTORIAL
   ===================================================== */
.history-table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background: white;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.history-table thead {
    background: linear-gradient(135deg, #f8f9fa, #f3f4f6);
}

.history-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.history-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f3f4f6;
    color: #4b5563;
}

.history-table tbody tr:hover {
    background: rgba(154, 108, 255, 0.03);
}

.history-table tbody tr:last-child td {
    border-bottom: none;
}

.loading-row {
    text-align: center;
    padding: 40px !important;
    color: #9ca3af;
}

.loading-row i {
    margin-right: 10px;
    color: #9a6cff;
}

.empty-row {
    text-align: center;
    padding: 40px !important;
    color: #9ca3af;
}

/* Score badge en tabla */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 13px;
    color: white;
}

.score-badge.excellent { background: linear-gradient(135deg, #22c55e, #16a34a); }
.score-badge.good { background: linear-gradient(135deg, #84cc16, #65a30d); }
.score-badge.moderate { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.score-badge.low { background: linear-gradient(135deg, #f97316, #ea580c); }
.score-badge.poor { background: linear-gradient(135deg, #ef4444, #dc2626); }

/* Botones de acción en tabla */
.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-action {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-action.view {
    background: rgba(154, 108, 255, 0.1);
    color: #9a6cff;
}

.btn-action.view:hover {
    background: #9a6cff;
    color: white;
}

.btn-action.qr {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.btn-action.qr:hover {
    background: #22c55e;
    color: white;
}

/* =====================================================
   PAGINACIÓN
   ===================================================== */
.history-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 15px 0;
}

.pagination-btn {
    min-width: 40px;
    height: 40px;
    border: 1px solid #e5e7eb;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    color: #4b5563;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    border-color: #9a6cff;
    color: #9a6cff;
}

.pagination-btn.active {
    background: linear-gradient(135deg, #9a6cff, #7c4dff);
    color: white;
    border-color: transparent;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 13px;
    color: #6b7280;
    margin: 0 15px;
}

/* =====================================================
   MODAL ANÁLISIS
   ===================================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    background: linear-gradient(135deg, #9a6cff, #7c4dff);
    color: white;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(85vh - 70px);
}

/* Contenido del modal de análisis */
.modal-analysis-header {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-photo {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    object-fit: cover;
    border: 3px solid #9a6cff;
}

.modal-client-info h4 {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 5px;
}

.modal-client-info p {
    font-size: 13px;
    color: #6b7280;
    margin: 3px 0;
}

.modal-scores {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.modal-score-item {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 12px;
}

.modal-score-item .value {
    font-size: 28px;
    font-weight: 800;
    color: #9a6cff;
}

.modal-score-item .label {
    font-size: 11px;
    color: #6b7280;
    margin-top: 5px;
}

.modal-qr-section {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-radius: 12px;
    margin-top: 20px;
}

.modal-qr-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: #0369a1;
    margin-bottom: 15px;
}

.modal-qr-section img {
    max-width: 150px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.modal-qr-section .qr-url {
    font-size: 11px;
    color: #6b7280;
    margin-top: 10px;
    word-break: break-all;
}

/* =====================================================
   QR SECTION EN RESULTADOS
   ===================================================== */
.qr-section {
    margin: 30px auto;
    max-width: 400px;
}

.qr-container {
    text-align: center;
    padding: 25px;
    background: linear-gradient(135deg, rgba(154, 108, 255, 0.05), rgba(124, 77, 255, 0.1));
    border: 2px solid rgba(154, 108, 255, 0.2);
    border-radius: 16px;
}

.qr-container h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.qr-container h3 i {
    color: #9a6cff;
}

.qr-container > p {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 15px;
}

.qr-container #qrcode {
    display: flex;
    justify-content: center;
    margin: 15px 0;
}

.qr-container #qrcode img {
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.qr-codigo {
    font-size: 12px;
    color: #9a6cff;
    font-weight: 600;
    margin-top: 10px;
}

/* =====================================================
   SEDE/ESPECIALISTA EN RESULTADOS
   ===================================================== */
.sede-especialista-result {
    font-size: 14px;
    color: #6b7280;
    margin: 5px 0;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
    .history-card {
        padding: 15px;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    .filter-actions {
        min-width: 100%;
        justify-content: center;
    }
    
    .history-table th,
    .history-table td {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    /* Ocultar algunas columnas en móvil */
    .history-table th:nth-child(3),
    .history-table td:nth-child(3),
    .history-table th:nth-child(5),
    .history-table td:nth-child(5) {
        display: none;
    }
    
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-analysis-header {
        flex-direction: column;
        text-align: center;
    }
    
    .modal-scores {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .modal-score-item .value {
        font-size: 22px;
    }
}
