/* Admin Page Global Styling */
:root {
    --primary: #0284c7;
    --primary-light: #e0f2fe;
    --primary-hover: #0369a1;
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-light: #94a3b8;
    --border-color: #cbd5e1;
    --success: #10b981;
    --success-light: #d1fae5;
    --error: #ef4444;
    --error-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.admin-container {
    width: 100%;
    max-width: 1200px;
    padding: 24px;
    display: flex;
    flex-direction: column;
}

/* Header */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    background: #ffffff;
    padding: 20px 24px;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-md);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.admin-logo-icon {
    font-size: 28px;
    color: var(--primary);
}

.header-logo h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
}

.admin-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-back-home {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: #f1f5f9;
    color: var(--text-main);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

.btn-back-home:hover {
    background: #e2e8f0;
    color: var(--primary);
}

/* Stats Overview */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: #ffffff;
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.bg-blue { background: #e0f2fe; color: #0284c7; }
.bg-green { background: #d1fae5; color: #057857; }
.bg-yellow { background: #fef3c7; color: #d97706; }
.bg-purple { background: #f3e8ff; color: #7c3aed; }

.stat-details {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-family: 'Outfit', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 4px;
}

/* Data Section Card */
.admin-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-lg);
    margin-bottom: 28px;
    overflow: hidden;
}

.admin-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.admin-card-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Filters Bar */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    width: 240px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.9rem;
}

.search-box input {
    width: 100%;
    padding: 9px 12px 9px 34px;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: inherit;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.select-filter {
    padding: 9px 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    background: #ffffff;
    font-family: inherit;
    cursor: pointer;
}

.select-filter:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-refresh:hover {
    background: var(--primary);
    color: #ffffff;
}

/* Data Table */
.table-responsive {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.admin-table th, .admin-table td {
    padding: 14px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.admin-table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-table tbody tr:hover {
    background-color: #f8fafc;
}

.admin-table td .btn-view {
    padding: 6px 12px;
    background: #f1f5f9;
    color: var(--text-main);
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.admin-table td .btn-view:hover {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

/* Badges for scores */
.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 4px;
}

.badge-score-excellent { background-color: var(--success-light); color: #047857; }
.badge-score-good { background-color: var(--primary-light); color: #0369a1; }
.badge-score-pass { background-color: var(--warning-light); color: #b45309; }
.badge-score-fail { background-color: var(--error-light); color: #b91c1c; }

.badge-pre { background-color: #bae6fd; color: #0369a1; }
.badge-post { background-color: #a7f3d0; color: #047857; }

/* Modal Design */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal.fade-in {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #ffffff;
    width: 90%;
    max-width: 760px;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.fade-in .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 18px 24px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Student meta inside modal */
.student-meta-box {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    padding: 16px 20px;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
}

.meta-item span {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.meta-item strong, .meta-item span.text-muted {
    font-size: 0.88rem;
}

.score-emphasis {
    color: var(--primary);
    font-size: 1.1rem !important;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* AI Report block inside modal */
.modal-ai-advice {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: var(--radius-sm);
    padding: 20px;
}

.modal-ai-advice h4, .modal-answers-record h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-main);
}

.modal-markdown-body {
    font-size: 0.86rem;
    line-height: 1.6;
    color: var(--text-main);
}

.modal-markdown-body h4 {
    font-size: 0.92rem;
    margin-top: 12px;
    margin-bottom: 6px;
    color: var(--primary);
    border-left: 2px solid var(--primary);
    padding-left: 6px;
}

.modal-markdown-body ul, .modal-markdown-body ol {
    padding-left: 18px;
    margin-bottom: 10px;
}

.modal-markdown-body li {
    margin-bottom: 4px;
}

/* Modal answer list */
.modal-answers-record {
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 20px;
}

.modal-ans-card {
    border-bottom: 1px solid #f1f5f9;
    padding: 12px 0;
}

.modal-ans-card:last-child {
    border-bottom: none;
}

.modal-ans-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.86rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.modal-ans-details {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.modal-ans-explanation {
    margin-top: 6px;
    padding: 6px 10px;
    background-color: #f8fafc;
    border-radius: 4px;
    font-size: 0.78rem;
    border-left: 2px solid var(--text-light);
}

.color-correct { color: var(--success); }
.color-incorrect { color: var(--error); }

/* Common Helper utilities */
.text-center { text-align: center; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.text-muted { color: var(--text-muted); }
.hidden { display: none !important; }

/* Footer styling */
.admin-footer {
    margin-top: auto;
    padding: 20px 0;
    border-top: 1px solid #e2e8f0;
    font-size: 0.75rem;
    color: var(--text-light);
}
