/* =================================================================
   TEST RESULTS DASHBOARD - Phase 4 Styling
   ================================================================= */

.test-results-module {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color, #e5e7eb);
}

.results-header h2 {
    margin: 0;
    font-size: 1.75rem;
    color: var(--text-primary, #1f2937);
    display: flex;
    align-items: center;
    gap: 12px;
}

.results-header h2 i {
    color: var(--primary-color, #3b82f6);
}

.results-language {
    background: var(--primary-color, #3b82f6);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.9rem;
}

/* Filters */
.results-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--card-bg, #f9fafb);
    border-radius: 12px;
    border: 1px solid var(--border-color, #e5e7eb);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-select,
.filter-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--bg-primary, white);
    color: var(--text-primary, #1f2937);
    min-width: 150px;
}

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

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--primary-color, #3b82f6);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
}

.refresh-btn:hover {
    background: var(--primary-hover, #2563eb);
    transform: translateY(-1px);
}

.refresh-btn i {
    transition: transform 0.3s ease;
}

.refresh-btn:hover i {
    transform: rotate(180deg);
}

/* Statistics Cards */
.results-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-primary, white);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 1px solid var(--border-color, #e5e7eb);
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

.stat-card.total .stat-icon {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.stat-card.passed .stat-icon {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.stat-card.average .stat-icon {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
}

.stat-card.students .stat-icon {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
    margin-top: 4px;
}

/* Tabs */
.results-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color, #e5e7eb);
    padding-bottom: 0;
}

.results-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    transition: all 0.2s ease;
}

.results-tab:hover {
    color: var(--primary-color, #3b82f6);
    background: rgba(59, 130, 246, 0.05);
}

.results-tab.active {
    color: var(--primary-color, #3b82f6);
    border-bottom-color: var(--primary-color, #3b82f6);
}

.tab-count {
    background: var(--border-color, #e5e7eb);
    color: var(--text-secondary, #6b7280);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.results-tab.active .tab-count {
    background: var(--primary-color, #3b82f6);
    color: white;
}

/* Results Content */
.results-content {
    min-height: 400px;
    margin-bottom: 24px;
}

/* No Results State */
.no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary, #6b7280);
}

.no-results i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

.no-results p {
    margin: 4px 0;
    font-size: 1.1rem;
}

.no-results .hint {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Overview Section */
.overview-section {
    margin-bottom: 32px;
}

.overview-section h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px 0;
    font-size: 1.1rem;
    color: var(--text-primary, #1f2937);
}

.overview-section h3 i {
    color: var(--primary-color, #3b82f6);
}

.view-all-hint {
    text-align: center;
    padding: 12px;
    color: var(--text-secondary, #6b7280);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
    margin-top: 12px;
}

/* Results List */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-primary, white);
    border-radius: 10px;
    border: 1px solid var(--border-color, #e5e7eb);
    transition: all 0.2s ease;
}

.result-item:hover {
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.result-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.result-item .result-icon {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.result-item.passed .result-icon,
.result-item.level-pass .result-icon {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.result-item.level-outstanding .result-icon {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.result-item.failed .result-icon,
.result-item.level-failure .result-icon {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.result-item.level-improving .result-icon {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.result-info {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-weight: 600;
    color: var(--text-primary, #1f2937);
    margin-bottom: 4px;
}

.result-meta {
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
}

.result-score {
    text-align: right;
}

.score-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
}

.score-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.score-status.passed,
.score-status.level-pass {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.score-status.level-outstanding {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

.score-status.failed,
.score-status.level-failure {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.score-status.level-improving {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

/* Lesson/Student Groups */
.lesson-group,
.student-group {
    margin-bottom: 24px;
}

.lesson-group-header,
.student-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--card-bg, #f3f4f6);
    border-radius: 8px;
    margin-bottom: 8px;
}

.lesson-group-header h4,
.student-group-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary, #1f2937);
    display: flex;
    align-items: center;
    gap: 8px;
}

.lesson-group-header h4 i,
.student-group-header h4 i {
    color: var(--primary-color, #3b82f6);
}

.attempt-count,
.test-count {
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
    background: var(--bg-primary, white);
    padding: 4px 12px;
    border-radius: 12px;
}

/* Lesson Result Item (different layout) */
.result-date {
    text-align: center;
    min-width: 80px;
}

.date-main {
    font-weight: 600;
    color: var(--text-primary, #1f2937);
    font-size: 0.9rem;
}

.date-time {
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
}

.result-details {
    flex: 1;
}

.result-test-name {
    font-weight: 500;
    color: var(--text-primary, #1f2937);
    margin-bottom: 8px;
}

.result-score-bar {
    height: 8px;
    background: var(--border-color, #e5e7eb);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.score-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.score-fill.passed,
.score-fill.level-pass,
.score-fill.level-outstanding {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.score-fill.failed,
.score-fill.level-failure {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.score-fill.level-improving {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.result-metrics {
    display: flex;
    gap: 16px;
}

.metric {
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
    display: flex;
    align-items: center;
    gap: 6px;
}

.metric i {
    color: var(--primary-color, #3b82f6);
}

.result-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 80px;
}

.result-status i {
    font-size: 1.5rem;
}

.result-status.passed {
    color: #22c55e;
}

.result-status.failed {
    color: #ef4444;
}

.level-badge {
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.result-status.level-outstanding .level-badge {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

.result-status.level-pass .level-badge {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.result-status.level-improving .level-badge {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.result-status.level-failure .level-badge {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.view-detail-btn {
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 8px;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-detail-btn:hover {
    background: var(--primary-color, #3b82f6);
    border-color: var(--primary-color, #3b82f6);
    color: white;
}

/* Performance Chart */
.performance-chart {
    padding: 20px;
    background: var(--bg-primary, white);
    border-radius: 12px;
    border: 1px solid var(--border-color, #e5e7eb);
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 200px;
    padding: 20px 0;
}

.chart-bar {
    width: 60px;
    min-height: 20px;
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8px;
    transition: height 0.5s ease;
}

.chart-bar.outstanding {
    background: linear-gradient(to top, #22c55e, #4ade80);
}

.chart-bar.pass {
    background: linear-gradient(to top, #3b82f6, #60a5fa);
}

.chart-bar.improving {
    background: linear-gradient(to top, #f59e0b, #fbbf24);
}

.chart-bar.failure {
    background: linear-gradient(to top, #ef4444, #f87171);
}

.bar-value {
    font-weight: 700;
    color: white;
    font-size: 1.1rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.chart-labels {
    display: flex;
    justify-content: space-around;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.chart-label {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 12px;
}

.chart-label.outstanding {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.chart-label.pass {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.chart-label.improving {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

.chart-label.failure {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.no-data {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary, #6b7280);
}

/* Actions */
.results-actions {
    display: flex;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.export-btn {
    background: #22c55e;
    color: white;
}

.export-btn:hover {
    background: #16a34a;
}

.clear-btn {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
}

.clear-btn:hover {
    background: #ef4444;
    color: white;
}

/* Modals */
.result-detail-modal,
.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-primary, white);
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

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

.modal-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary, #1f2937);
}

.modal-header h3 i {
    color: var(--primary-color, #3b82f6);
}

.modal-close {
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--border-color, #e5e7eb);
    color: var(--text-primary, #1f2937);
}

.modal-body {
    padding: 24px;
}

.detail-section {
    margin-bottom: 24px;
}

.detail-section h4 {
    margin: 0 0 16px 0;
    font-size: 1rem;
    color: var(--text-primary, #1f2937);
}

.detail-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color, #f3f4f6);
}

.detail-label {
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    min-width: 100px;
}

.detail-value {
    color: var(--text-primary, #1f2937);
}

.detail-value.level-outstanding {
    color: #22c55e;
    font-weight: 600;
}

.detail-value.level-pass {
    color: #3b82f6;
    font-weight: 600;
}

.detail-value.level-improving {
    color: #f59e0b;
    font-weight: 600;
}

.detail-value.level-failure {
    color: #ef4444;
    font-weight: 600;
}

.question-scores {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.question-score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    min-width: 50px;
}

.question-score-item.good {
    background: rgba(34, 197, 94, 0.1);
}

.question-score-item.fair {
    background: rgba(245, 158, 11, 0.1);
}

.question-score-item.poor {
    background: rgba(239, 68, 68, 0.1);
}

.question-score-item.skipped {
    background: var(--border-color, #e5e7eb);
}

.q-num {
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
}

.q-score {
    font-size: 1.1rem;
    font-weight: 700;
}

.question-score-item.good .q-score {
    color: #22c55e;
}

.question-score-item.fair .q-score {
    color: #f59e0b;
}

.question-score-item.poor .q-score {
    color: #ef4444;
}

.question-score-item.skipped .q-score {
    color: var(--text-secondary, #6b7280);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.modal-footer button {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.print-btn {
    background: var(--primary-color, #3b82f6);
    color: white;
    border: none;
}

.print-btn:hover {
    background: var(--primary-hover, #2563eb);
}

.close-btn {
    background: transparent;
    border: 1px solid var(--border-color, #d1d5db);
    color: var(--text-primary, #1f2937);
}

.close-btn:hover {
    background: var(--border-color, #e5e7eb);
}

.cancel-btn {
    background: transparent;
    border: 1px solid var(--border-color, #d1d5db);
    color: var(--text-primary, #1f2937);
}

.cancel-btn:hover {
    background: var(--border-color, #e5e7eb);
}

.confirm-btn.danger {
    background: #ef4444;
    color: white;
    border: none;
}

.confirm-btn.danger:hover {
    background: #dc2626;
}

.confirm-modal .modal-body ul {
    margin: 12px 0;
    padding-left: 24px;
}

.confirm-modal .modal-body li {
    margin: 4px 0;
    color: var(--text-secondary, #6b7280);
}

/* No Language Message */
.no-language-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    color: var(--text-secondary, #6b7280);
}

.no-language-message i {
    font-size: 4rem;
    margin-bottom: 20px;
    color: #f59e0b;
}

.no-language-message p {
    font-size: 1.1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .test-results-module {
        padding: 12px;
    }

    .results-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .results-header h2 {
        font-size: 1.4rem;
    }

    .results-filters {
        flex-direction: column;
        gap: 12px;
    }

    .filter-group {
        width: 100%;
    }

    .filter-select,
    .filter-input {
        width: 100%;
    }

    .refresh-btn {
        width: 100%;
        justify-content: center;
        margin-left: 0;
    }

    .results-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card {
        padding: 16px 12px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .results-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .results-tab {
        padding: 10px 14px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .result-item {
        flex-wrap: wrap;
        gap: 12px;
    }

    .result-info {
        flex-basis: calc(100% - 60px);
    }

    .result-score {
        flex-basis: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .chart-bars {
        height: 150px;
    }

    .chart-bar {
        width: 45px;
    }

    .chart-label {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    .results-actions {
        flex-direction: column;
    }

    .action-btn {
        width: 100%;
        justify-content: center;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .test-results-module {
        --bg-primary: #1f2937;
        --card-bg: #374151;
        --text-primary: #f9fafb;
        --text-secondary: #9ca3af;
        --border-color: #4b5563;
    }
}

/* Print Styles */
@media print {
    .results-filters,
    .results-actions,
    .refresh-btn,
    .view-detail-btn,
    .modal-close,
    .modal-footer {
        display: none !important;
    }

    .test-results-module {
        padding: 0;
    }

    .result-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
