/* --- Base & Professional App Style --- */
body.page-template-page-preboard-results, body.page-template-page-preboard-results-php {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}
.app-container {
    display: flex; flex-direction: column; justify-content: center;
    align-items: center; min-height: 100vh; padding: 20px;
}
.app-container.results-shown { justify-content: flex-start; }

.preboard-container {
    width: 100%; max-width: 800px;
    background: #B58377; border-radius: 16px;
    box-shadow: 0 15px 35px rgba(50, 50, 93, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07);
    border: 1px solid #e9ecef; overflow: hidden;
    transform: translateY(10px); opacity: 0;
    animation: fadeInPop 0.5s ease forwards;
    transition: max-width 0.4s ease;
}
@keyframes fadeInPop { to { transform: translateY(0); opacity: 1; } }
.results-shown .preboard-container { max-width: 1200px; }

/* --- Table Responsive Wrapper --- */
.table-responsive-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- Header --- */
.preboard-header { padding: 30px 35px; background: linear-gradient(135deg, #3D5AFE 0%, #C9C9C9 100%); text-align: center; color: white; }
.preboard-header .school-name { font-size: 16px; font-weight: 400; opacity: 0.9; margin: 0 0 5px 0; letter-spacing: 0.5px; }
.preboard-header .test-name { font-size: 28px; font-weight: 700; margin: 0; }

/* --- View Switcher & Forms --- */
.view-switcher { display: flex; padding: 5px; background-color: #e9ecef; }
.switcher-btn { flex: 1; padding: 10px; border: none; background-color: transparent; cursor: pointer; font-size: 15px; font-weight: 500; color: #6c757d; border-radius: 8px; transition: all 0.25s ease; position: relative; }
.switcher-btn.active { background-color: #fff; color: #3D5AFE; box-shadow: 0 2px 4px rgba(0,0,0,0.08); }
.search-box { padding: 30px 35px; }
#preboard-search-form label, #teacher-search-form label { font-weight: 500; margin-bottom: 8px; color: #495057; display: block; }
#preboard-search-form input, #teacher-search-form input, #teacher-search-form select { width: 100%; padding: 18px; border: 1px solid #ced4da; border-radius: 8px; box-sizing: border-box; font-size: 12px; transition: all 0.2s; }
#preboard-search-form input:focus, #teacher-search-form input:focus, #teacher-search-form select:focus { border-color: #3D5AFE; box-shadow: 0 0 0 4px rgba(61, 90, 254, 0.15); outline: none; }
#preboard-search-form button, #teacher-search-form button { width: 100%; padding: 14px; margin-top: 20px; background: linear-gradient(45deg, #28a745, #218838); color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 16px; font-weight: 600; transition: all 0.2s; }
#preboard-search-form button:hover, #teacher-search-form button:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(40, 167, 69, 0.3); }

/* --- Single Student Result Card UI --- */
.result-card { padding: 25px; position: relative; }
#downloadable-area { position: relative; background-color: #fff; }
.result-card::after { content: ''; background-image: url('../../hss shangus_ background logo_2024.png'); background-repeat: no-repeat; background-position: center; background-size: 250px; position: absolute; top: 55%; left: 50%; transform: translate(-50%, -50%); width: 100%; height: 100%; opacity: 0.06; z-index: 1; pointer-events: none; }
.result-card > * { position: relative; z-index: 2; }
.registration-number-display { text-align: center; font-size: 18px; font-weight: bold; color: #dc3545; padding: 10px; background-color: #f8f9fa; border-bottom: 1px solid #dee2e6; }
.student-details { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; padding: 20px; background-color: #f8f9fa; border-radius: 8px; margin-bottom: 25px; }
.detail-item { min-width: 0; }
.detail-item .detail-label { font-size: 11px; color: #6c757d; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.detail-item .detail-value { font-size: 14px; font-weight: 600; color: #212529; word-wrap: break-word; }

/* --- Teacher View UI --- */
.subject-filter-container { padding: 20px 35px; background: #fdfdff; border-bottom: 1px solid #dee2e6; display: flex; align-items: center; gap: 15px; }
.subject-filter-container label { font-weight: 500; margin-bottom: 0; color: #343a40; white-space: nowrap;}
#subject-filter-select { padding: 15px; border-radius: 8px; border: 1px solid #ced4da; font-size: 12px; flex-grow: 1; background-color: #fff; cursor: pointer; }
.analytics-dashboard { padding: 30px 35px; background-color: #f8f9fa; border-bottom: 1px solid #dee2e6; }
.dashboard-title { text-align: center; font-size: 22px; margin: 0 0 25px 0; color: #343a40; }
.analytics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 20px; }
.analytic-card { background: #fff; border-radius: 12px; padding: 20px; text-align: center; box-shadow: 0 7px 14px rgba(50, 50, 93, 0.05), 0 3px 6px rgba(0, 0, 0, 0.05); transition: all 0.2s ease-in-out; border: 1px solid #e9ecef; }
.analytic-card:hover { transform: translateY(-3px); box-shadow: 0 10px 20px rgba(50, 50, 93, 0.1), 0 4px 8px rgba(0, 0, 0, 0.07); }
.analytic-title { font-size: 14px; font-weight: 600; color: #495057; }
.analytic-value { font-size: 36px; font-weight: 700; margin: 8px 0; color: #28a745; }
.analytic-label { font-size: 11px; color: #6c757d; text-transform: uppercase; letter-spacing: 0.8px; }
.analytic-footer { margin-top: 15px; font-size: 12px; color: #6c757d; border-top: 1px solid #f1f3f5; padding-top: 10px; display: flex; justify-content: space-around; }

/* --- General & Full Results Table --- */
.full-results-container { padding: 20px 0; }
.results-table {
    /* [CRITICAL FIX] REMOVED width: 100% to allow natural overflow */
    border-collapse: collapse;
}
.results-table th, .results-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
    text-align: left;
    font-size: 13px; /* --- ADJUSTED FONT SIZE --- */
}
.results-table thead { background: linear-gradient(135deg, #3D5AFE 0%, #1E88E5 100%); color: white; }
.results-table thead th { font-weight: 600; text-align: center; position: sticky; top: 0; z-index: 10; }
.results-table thead th:first-child, .results-table thead th:nth-child(2), .results-table thead th:nth-child(3) { text-align: left; }
.results-table tbody tr:hover { background-color: #f5f7fa; }
.results-table td { text-align: center; }
.results-table td:first-child, .results-table td:nth-child(2), .results-table td:nth-child(3) { text-align: left; }
.full-results-table { font-size: 13px; white-space: nowrap; }
.full-results-table th, .full-results-table td { padding: 10px 12px; }
.full-results-table th:nth-child(2), .full-results-table td:nth-child(2) { white-space: normal; font-weight: 500; }
.full-results-table th:nth-child(3), .full-results-table td:nth-child(3) { white-space: normal; }
.results-table .highlight { background-color: rgba(61, 90, 254, 0.15); font-weight: bold; color: #3D5AFE; }
.results-table thead .highlight { background-color: rgba(61, 90, 254, 0.3); }

/* --- Percentage & NA Colors --- */
.percent-pass { color: #198754; font-weight: 600; }
.percent-warn { color: #ffc107; font-weight: 600; }
.percent-fail { color: #dc3545; font-weight: 600; }
.na-mark { color: #adb5bd; font-style: italic; }

/* --- General Components --- */
.action-buttons { text-align: center; padding: 25px; background-color: #f8f9fa; border-top: 1px solid #e9ecef;}
.action-buttons button { padding: 12px 28px; border: none; border-radius: 8px; cursor: pointer; font-size: 15px; font-weight: 500; transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center; margin: 5px; }
.action-buttons button i { margin-right: 8px; }
#download-btn { background-color: #007bff; color: white; }
#download-btn:hover { background-color: #0069d9; transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3); }
#new-search-btn, #new-report-btn { background-color: #6c757d; color: white; }
#new-search-btn:hover, #new-report-btn:hover { background-color: #5a6268; transform: translateY(-2px); box-shadow: 0 4px 10px rgba(90, 98, 104, 0.3); }
.notice { margin: 30px; }
.loading-spinner { margin: 50px auto; border: 4px solid #f1f3f5; border-top: 4px solid #3D5AFE; border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- [UPDATED] MOBILE RESPONSIVE OVERHAUL --- */
@media (max-width: 600px) {
    .app-container { padding: 0; }
    .preboard-container { border-radius: 0; box-shadow: none; border: none; }
    .preboard-header { padding: 20px 15px; }
    .preboard-header .test-name { font-size: 20px; }
    .search-box { padding: 25px 15px; }
    
    /* Compact Analytics */
    .analytics-dashboard { padding: 20px 15px; }
    .dashboard-title { font-size: 18px; margin-bottom: 15px; }
    .analytics-grid { gap: 10px; }
    .analytic-card { padding: 12px; }
    .analytic-value { font-size: 24px; }
    .analytic-label { font-size: 10px; }
    .analytic-footer { font-size: 11px; }

    /* Compact Student Details */
    .result-card { padding: 15px; }
    .student-details { padding: 15px; margin-bottom: 20px; grid-template-columns: 1fr 1fr; }
    .detail-value { font-size: 13px; }
    .registration-number-display { font-size: 14px; }

    /* Compact Table Font */
    .results-table th, .results-table td {
        padding: 10px 12px;
        font-size: 12px; /* --- SMALLER FONT FOR MOBILE --- */
    }

    /* Compact Buttons */
    .action-buttons {
        display: flex;
        justify-content: center;
        gap: 10px;
        padding: 20px 15px;
    }
    .action-buttons button {
        flex: 1;
        padding: 10px 5px; /* Reduced padding */
        font-size: 12px; /* Reduced font size */
        margin: 0;
    }
    .action-buttons button i {
        margin-right: 5px;
    }
}