/* Test History Specific Styles */

/* History Controls */
.history-controls {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.filter-select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-select:hover {
    border-color: var(--primary-color);
}

/* History Statistics */
.history-stats {
    margin-bottom: 2rem;
}

.history-stats .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.history-stats .stat-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.history-stats .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.history-stats .stat-icon {
    width: 50px;
    height: 50px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.history-stats .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.history-stats .stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* History List */
.history-list {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.section-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--light-bg);
}

.section-header .section-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.results-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* History Table */
.history-table-container {
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.history-table th {
    background: var(--light-bg);
    padding: 1rem 1.5rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    position: relative;
    user-select: none;
}

.history-table th.sortable {
    cursor: pointer;
    transition: var(--transition);
}

.history-table th.sortable:hover {
    background: #e2e8f0;
}

.history-table th.sortable span {
    margin-right: 0.5rem;
}

.history-table th.sortable i {
    opacity: 0.5;
    transition: var(--transition);
}

.history-table th.sortable:hover i {
    opacity: 1;
}

.history-table th.sorted-asc i::before {
    content: '\f0de'; /* fa-sort-up */
    opacity: 1;
    color: var(--primary-color);
}

.history-table th.sorted-desc i::before {
    content: '\f0dd'; /* fa-sort-down */
    opacity: 1;
    color: var(--primary-color);
}

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

.history-table tbody tr {
    transition: var(--transition);
}

.history-table tbody tr:hover {
    background: var(--light-bg);
}

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

/* Test Type Badge */
.test-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: capitalize;
}

.test-type-badge.listening {
    background: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
}

.test-type-badge.reading {
    background: rgba(16, 185, 129, 0.1);
    color: #047857;
}

.test-type-badge.writing {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.test-type-badge.speaking {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.test-type-badge i {
    font-size: 0.75rem;
}

/* Score Badge */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
    color: white;
}

.score-badge.excellent {
    background: linear-gradient(135deg, #10b981 0%, #047857 100%);
}

.score-badge.very-good {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

.score-badge.good {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.score-badge.competent {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

.score-badge.limited {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.score-badge.basic {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

/* Progress Indicator */
.progress-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.progress-trend.improving {
    background: rgba(16, 185, 129, 0.1);
    color: #047857;
}

.progress-trend.declining {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.progress-trend.stable {
    background: rgba(107, 114, 128, 0.1);
    color: #374151;
}

.progress-trend i {
    font-size: 0.7rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.action-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
}

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

.action-btn.primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 2rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* Pagination */
.pagination-container {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-color);
    background: var(--light-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.pagination-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.pagination-btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination-btn:hover:not(.active):not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
}

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

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

.pagination-ellipsis {
    padding: 0.5rem 0.25rem;
    color: var(--text-secondary);
}

/* Modal Enhancements */
.modal-large .modal-content {
    max-width: 800px;
    width: 90%;
}

.test-detail-content {
    display: grid;
    gap: 2rem;
}

.detail-section {
    background: var(--light-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.detail-section h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.detail-item {
    text-align: center;
}

.detail-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.detail-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.feedback-section {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.feedback-section h5 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

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

.feedback-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.feedback-list li:last-child {
    border-bottom: none;
}

.feedback-list li i {
    margin-top: 0.25rem;
    flex-shrink: 0;
}

.feedback-list.strengths li i {
    color: var(--success-color);
}

.feedback-list.weaknesses li i {
    color: var(--danger-color);
}

.feedback-list.suggestions li i {
    color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .controls-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .history-stats .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .history-table {
        font-size: 0.8rem;
    }
    
    .history-table th,
    .history-table td {
        padding: 0.75rem 0.5rem;
    }
    
    .pagination-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .action-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .action-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .history-stats .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .history-table th,
    .history-table td {
        padding: 0.5rem 0.25rem;
    }
    
    .test-type-badge,
    .score-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    .modal-large .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
}