/* style.css - 2025 Modern & Responsive Design */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@200;300;400;500;700;800;900&display=swap');

/* --- 1. Global Variables & Design System --- */
:root {
    /* Color Palette - Premium Royal Blue Theme */
    --primary-hue: 225;
    --primary-color: hsl(var(--primary-hue), 85%, 55%);
    /* Vibrant Royal Blue */
    --primary-dark: hsl(var(--primary-hue), 85%, 35%);
    /* Deep Navy */
    --primary-light: hsl(var(--primary-hue), 90%, 96%);
    /* Very Pale Blue */
    --accent-color: hsl(35, 95%, 55%);
    /* Gold Accent */

    --secondary-color: #64748b;

    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #d97706;

    /* Backgrounds */
    --bg-body: #f3f6fc;
    /* Cool Grayish Blue */
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    /* Dark Slate */

    /* Text */
    --text-main: #1e293b;
    /* Slate 800 */
    --text-muted: #64748b;
    /* Slate 500 */
    --text-light: #f8fafc;

    /* Spacing & Layout */
    --header-height: 80px;
    --sidebar-width: 280px;
    --container-padding: clamp(1.5rem, 5vw, 3rem);

    /* Borders & Shadows */
    --radius-sm: 0.75rem;
    /* 12px */
    --radius-md: 1.25rem;
    /* 20px */
    --radius-lg: 2rem;
    /* 32px */

    /* Soft, Layered Shadows */
    --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px -6px rgba(0, 0, 0, 0.08), 0 4px 8px -4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 48px -12px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 30px hsla(var(--primary-hue), 85%, 55%, 0.25);

    /* Typography */
    --font-xs: 0.8125rem;
    --font-sm: 0.9375rem;
    --font-base: 1.0625rem;
    --font-lg: 1.25rem;
    --font-xl: 1.75rem;
    --font-2xl: 2.5rem;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.7;
    font-size: var(--font-base);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-fast);
}

ul {
    list-style: none;
}

button {
    font-family: inherit;
}

/* Scrollbar Polish */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* --- 3. Login Page (Center Card) --- */
/* --- 3. Login Page (Center Card) --- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: var(--container-padding);
    background: radial-gradient(circle at top right, #f8fafc 0%, #e2e8f0 100%);
    position: relative;
    overflow: hidden;
}

/* Decorative background blobs - Soft & Modern */
.login-container::before,
.login-container::after {
    content: '';
    position: absolute;
    width: 60vh;
    height: 60vh;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    opacity: 0.08;
    filter: blur(80px);
    z-index: 0;
    animation: drift 15s infinite alternate ease-in-out;
}

.login-container::before {
    top: -15vh;
    right: -15vh;
}

.login-container::after {
    bottom: -15vh;
    left: -15vh;
    animation-delay: -7s;
}

@keyframes drift {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(30px, 30px) scale(1.1);
    }
}

.login-form {
    position: relative;
    z-index: 10;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    padding: 3.5rem 3rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    width: 100%;
    max-width: 440px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    animation: fadeInUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-form h2 {
    font-size: var(--font-2xl);
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 2.5rem;
    text-align: center;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.form-group {
    margin-bottom: 1.75rem;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 0.6rem;
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-muted);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 1rem 1.2rem;
    font-size: var(--font-base);
    border: 2px solid transparent;
    /* Prepare for focus ring */
    background: white;
    box-shadow: 0 0 0 1px #cbd5e1;
    /* Faux border transparent compatible */
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    color: var(--text-main);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-color), 0 4px 12px rgba(59, 130, 246, 0.15);
}

.form-group input:hover,
.form-group select:hover {
    box-shadow: 0 0 0 1px #94a3b8;
}

.login-form button {
    width: 100%;
    padding: 1rem;
    margin-top: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-lg);
    transition: all 0.3s ease;
    box-shadow: 0 10px 20px -5px rgba(59, 130, 246, 0.4);
    position: relative;
    overflow: hidden;
}

.login-form button:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px -5px rgba(59, 130, 246, 0.5);
    filter: brightness(1.1);
}

.login-form button:active {
    transform: translateY(-1px);
}

.error {
    color: #b91c1c;
    background: #fef2f2;
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-top: 1.5rem;
    font-size: var(--font-sm);
    text-align: center;
    border: 1px solid #fecaca;
    display: none;
    font-weight: 500;
}

.error:not(:empty) {
    display: block;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* --- 4. Dashboard Layout --- */
.dashboard-container {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-body);
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: var(--text-light);
    height: 100vh;
    position: sticky;
    top: 0;
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    transition: var(--transition-smooth);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    /* Subtle border for RTL context if needed */
}

.sidebar h3 {
    font-size: var(--font-xl);
    font-weight: 800;
    margin-bottom: 3.5rem;
    text-align: center;
    background: linear-gradient(135deg, #60a5fa 30%, #a78bfa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Login Language Switcher */
.login-form .lang-switcher {
    text-align: center;
    margin-bottom: 2rem;
    font-size: var(--font-sm);
    font-weight: 500;
}

.login-form .lang-switcher a {
    color: var(--text-muted);
    margin: 0 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.login-form .lang-switcher a:hover,
.login-form .lang-switcher a[data-active="true"] {
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
}

.sidebar ul {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar ul li a {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    color: #94a3b8;
    font-weight: 600;
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.sidebar ul li a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    transform: translateX(-4px);
    /* RTL moves left */
}

html[dir="rtl"] .sidebar ul li a:hover {
    transform: translateX(-4px);
}

html[dir="ltr"] .sidebar ul li a:hover {
    transform: translateX(4px);
}

.sidebar ul li a.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0.1) 100%);
    color: #60a5fa;
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.3);
}

.sidebar ul li a.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 60%;
    width: 4px;
    background: #60a5fa;
    border-radius: 4px 0 0 4px;
}

html[dir="ltr"] .sidebar ul li a.active::before {
    right: auto;
    left: 0;
    border-radius: 0 4px 4px 0;
}


/* Main Content Area */
.main-content {
    flex: 1;
    padding: var(--container-padding);
    width: 100%;
}

.header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1rem 2.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    position: sticky;
    top: 1rem;
    z-index: 50;
}

.header span {
    font-size: var(--font-base);
    font-weight: 600;
    color: var(--text-main);
}

.header strong {
    color: var(--primary-color);
}

.logout-btn {
    background-color: #fef2f2;
    color: var(--danger-color);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: var(--font-sm);
    transition: var(--transition-fast);
    border: 1px solid #fee2e2;
}

.logout-btn:hover {
    background-color: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

/* --- 5. Profile & Cards --- */
.profile-card {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden;
}

/* Subtle top pattern for card */
.profile-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 2.5rem;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 2.5rem;
    margin-bottom: 2.5rem;
}

.profile-pic {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    border: 5px solid white;
    box-shadow: 0 0 0 2px var(--primary-light), var(--shadow-md);
    transition: transform 0.3s ease;
}

.profile-pic:hover {
    transform: scale(1.05);
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.detail-item {
    background: #ffffff;
    padding: 1.75rem;
    border-radius: var(--radius-md);
    border: 1px solid #f1f5f9;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.detail-item:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}

.detail-item strong {
    display: block;
    color: var(--text-muted);
    font-size: var(--font-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.detail-item span {
    font-size: var(--font-lg);
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.4;
}

/* --- 6. Tables & Results --- */
.results-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 2rem;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid #e2e8f0;
    background: white;
}

.results-table th,
.results-table td {
    padding: 0.75rem 1rem;
    text-align: right;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    /* Ensure clean vertical alignment */
    font-size: 0.95rem;
    /* Slightly smaller for cleaner look */
    line-height: 1.4;
}

html[dir="rtl"] .results-table th,
html[dir="rtl"] .results-table td {
    text-align: right;
}

html[dir="ltr"] .results-table th,
html[dir="ltr"] .results-table td {
    text-align: left;
}

.results-table thead th {
    background-color: #f8fafc;
    color: var(--secondary-color);
    font-weight: 800;
    font-size: var(--font-xs);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid #e2e8f0;
}

/* Specific Column Tuning */
.results-table td:not(:first-child),
.results-table th:not(:first-child) {
    white-space: nowrap;
    /* Keep data columns on one line */
    width: 1%;
    /* Shrink to fit content */
}

/* Subject Column (First Child) */
.results-table td:first-child,
.results-table th:first-child {
    min-width: 200px;
    /* Ensure enough space for subject name */
}

.results-table tbody tr:last-child td {
    border-bottom: none;
}

.results-table tbody tr {
    transition: background-color 0.2s ease;
}

.results-table tbody tr:hover {
    background-color: #f1f5f9;
}

.results-table tbody tr:nth-child(even) {
    background-color: #fafbfc;
    /* Subtle zebra stripe optimization */
}

/* Interactive Grades */
.subject-row {
    cursor: pointer;
}

.subject-row:hover td {
    color: var(--primary-color);
}

.arrow {
    display: inline-block;
    transition: transform 0.3s var(--transition-smooth);
    color: var(--text-muted);
    font-size: 0.9em;
}

.arrow.expanded {
    transform: rotate(-90deg);
    color: var(--primary-color);
}

.grade-breakdown {
    background: #f8fafc;
    /* Slightly darker for nested content */
    padding: 2rem;
    box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.03);
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
}

/* --- 7. Responsive & Mobile Optimization --- */

/* Tablet & Mobile Breakpoints */
@media (max-width: 992px) {
    .sidebar {
        display: none;
    }

    /* Hide default sidebar for now, we'll make a mobile nav */

    /* Navigation Bar for Mobile/Tablet */
    .dashboard-container {
        flex-direction: column;
        padding-bottom: 80px;
        /* Space for bottom nav */
    }

    .sidebar {
        display: flex;
        flex-direction: row;
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        width: 100%;
        height: auto;
        padding: 0;
        background: white;
        /* Light theme for mobile nav usually looks cleaner */
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    }

    .sidebar h3 {
        display: none;
    }

    .sidebar ul {
        flex-direction: row;
        justify-content: space-around;
        width: 100%;
        margin: 0;
        padding: 0.5rem;
    }

    .sidebar ul li {
        flex: 1;
    }

    .sidebar ul li a {
        flex-direction: column;
        justify-content: center;
        padding: 0.5rem;
        font-size: 0.8rem;
        border-radius: var(--radius-sm);
        color: var(--secondary-color);
        text-align: center;
    }

    .sidebar ul li a:hover {
        background: transparent;
        color: var(--primary-color);
        transform: none;
    }

    .sidebar ul li a.active {
        background: transparent;
        color: var(--primary-color);
        box-shadow: none;
    }

    /* Add icons content via CSS if they don't exist in HTML is tricky, 
       assuming HTML has text. We'll style the text to be compact. */

    .header {
        position: sticky;
        top: 0;
        z-index: 90;
        margin: 0;
        border-radius: 0;
        border-bottom: 1px solid #e2e8f0;
        padding: 1rem;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    /* Card View for Tables on Mobile (General) */
    .results-table:not(.transcript-table),
    .results-table:not(.transcript-table) thead,
    .results-table:not(.transcript-table) tbody,
    .results-table:not(.transcript-table) th,
    .results-table:not(.transcript-table) td,
    .results-table:not(.transcript-table) tr {
        display: block;
    }

    /* Transcript Table Specific (Keep as Table with Scroll) */
    .transcript-table {
        display: table;
        min-width: 600px;
        /* Force width */
    }

    .semester-results {
        overflow-x: auto;
        /* Enable scroll */
        -webkit-overflow-scrolling: touch;
    }

    .results-table:not(.transcript-table) thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .results-table:not(.transcript-table) tr {
        border: 1px solid #e2e8f0;
        margin-bottom: 1rem;
        border-radius: var(--radius-sm);
        background: white;
        box-shadow: var(--shadow-sm);
    }

    .results-table:not(.transcript-table) td {
        border: none;
        border-bottom: 1px solid #f1f5f9;
        position: relative;
        padding-inline-start: 40%;
        text-align: left;
    }

    html[dir="rtl"] .results-table:not(.transcript-table) td {
        text-align: left;
        padding-inline-start: 40%;
        padding-inline-end: 1rem;
    }

    .results-table:not(.transcript-table) td:before {
        position: absolute;
        top: 1rem;
        right: 1rem;
        width: 35%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        color: var(--secondary-color);
        content: attr(data-label);
        text-align: right;
    }

    html[dir="rtl"] .results-table:not(.transcript-table) td:before {
        right: 1rem;
        text-align: right;
    }
}

/* --- 8. Print Optimization --- */
@media print {

    .sidebar,
    .view-switcher,
    .logout-btn {
        display: none !important;
    }

    .dashboard-container {
        display: block;
    }

    .main-content {
        padding: 0;
    }

    .profile-card {
        box-shadow: none;
        border: none;
        padding: 0;
    }

    body,
    .detail-item,
    .header {
        background: white;
        color: black;
    }

    .results-table {
        box-shadow: none;
        border: 1px solid #000;
    }

    .results-table th {
        background: #eee !important;
        color: black;
    }
}

/* --- 9. Official Transcript Replica (Strict Design) --- */

/* Wrapper for the new view */
.official-replica-wrapper {
    background: white;
    color: black;
    font-family: 'Times New Roman', 'Tajawal', serif;
    /* Serif font for academic look */
    max-width: 1000px;
    margin: 0 auto;
    border: 1px solid white;
    /* Invisible border to separate from bg */
}

/* Header Area */
.replica-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 1rem;
    border-bottom: 3px solid #0000ff;
    margin-bottom: 0.5rem;
}

.replica-logo-area {
    text-align: center;
    flex: 1;
}

.replica-logo-img {
    width: 100px;
    height: auto;
    margin-bottom: 5px;
}

.uni-title {
    font-size: 14pt;
    font-weight: bold;
    margin-bottom: 10px;
    display: block;
}

.record-title {
    color: #0000ff;
    font-size: 18pt;
    font-weight: bold;
    text-decoration: underline;
    display: block;
}

.replica-student-photo img {
    width: 100px;
    height: 120px;
    border: 2px solid #008000;
    /* Green border as per image */
    padding: 2px;
}

.replica-ministry-info {
    text-align: right;
    font-size: 12pt;
    font-weight: bold;
    line-height: 1.4;
}

/* Student Info Bar */
.replica-info-bar {
    border-top: 2px solid #0000ff;
    border-bottom: 3px solid #0000ff;
    padding: 5px 0;
    margin-bottom: 1rem;
    font-size: 11pt;
    font-weight: bold;
}

.replica-info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.info-field span {
    color: #0000ff;
    margin-right: 5px;
    /* RTL aware: text is right aligned generally */
}

html[dir="rtl"] .info-field span {
    margin-right: 5px;
    margin-left: 0;
}

html[dir="ltr"] .info-field span {
    margin-left: 5px;
    margin-right: 0;
}


/* The Main Grid Layout for Levels */
.replica-level-container {
    display: flex;
    /* Flex is easier than grid for RTL/LTR flipping sometimes, but Grid is more robust */
    border: 2px solid #0000ff;
    margin-bottom: 5px;
    page-break-inside: avoid;
    flex-direction: row;
}

/* Vertical Sidebars */
.level-sidebar {
    background-color: #ccccff;
    /* Periwinkle */
    writing-mode: vertical-rl;
    text-orientation: mixed;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 12pt;
    color: #0000ff;
    /* Blue text */
    padding: 5px;
    width: 40px;
    flex-shrink: 0;
    border-inline-end: 2px solid #0000ff;
}

.level-sidebar.left-side {
    border-inline-end: none;
    border-inline-start: 2px solid #0000ff;
    background-color: #ccccff;
    font-size: 10pt;
}

/* Main Content (Semesters) */
.semesters-wrapper {
    display: flex;
    flex: 1;
}

.semester-col {
    flex: 1;
    border-inline-end: 2px solid #0000ff;
}

.semester-col:last-child {
    border-inline-end: none;
}

.semester-header {
    background-color: #ffffcc;
    /* Yellow */
    color: #0000ff;
    font-weight: bold;
    text-align: center;
    padding: 2px;
    border-bottom: 2px solid #0000ff;
    font-size: 11pt;
}

/* Inner Table */
.replica-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
}

.replica-table th {
    background-color: #e0ffff;
    /* Light Blue */
    color: #0000aa;
    border-bottom: 1px solid #0000ff;
    border-inline-start: 1px solid #0000ff;
    padding: 2px;
}

.replica-table td {
    padding: 2px 4px;
    border-bottom: 1px solid #0000ff;
    /* Blue dotted or solid */
    border-inline-start: 1px solid #0000ff;
    font-weight: bold;
}

.replica-table tr:last-child td {
    border-bottom: none;
}

.replica-table th:first-child,
.replica-table td:first-child {
    border-inline-start: none;
}


/* Column grid widths */
.replica-table th:nth-child(1),
.replica-table td:nth-child(1) {
    width: 5%;
    text-align: center;
}

/* # */
.replica-table th:nth-child(2),
.replica-table td:nth-child(2) {
    width: 55%;
    text-align: right;
}

/* Subject */
.replica-table th:nth-child(3),
.replica-table td:nth-child(3) {
    width: 10%;
    text-align: center;
}

/* Hours */
.replica-table th:nth-child(4),
.replica-table td:nth-child(4) {
    width: 15%;
    text-align: center;
}

/* Grade */
.replica-table th:nth-child(5),
.replica-table td:nth-child(5) {
    width: 15%;
    text-align: center;
}

/* Estimate */

/* Footer */
.replica-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 3px solid #0000ff;
}

.footer-sig {
    text-align: center;
    font-weight: bold;
    font-size: 12pt;
}

/* Print Overrides */
@media print {
    @page {
        size: A4 portrait;
        margin: 5mm;
    }

    body,
    .main-content {
        margin: 0;
        padding: 0;
        background: white !important;
    }

    .official-replica-wrapper {
        width: 100%;
        max-width: none;
        border: none;
    }

    /* Force background colors */
    .level-sidebar {
        background-color: #ccccff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .semester-header {
        background-color: #ffffcc !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .replica-table th {
        background-color: #e0ffff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Header/Footer Elements to hide */
    .view-switcher,
    .print-button,
    .sidebar,
    .header {
        display: none !important;
    }
}

@media print {
    /* Override needed */
}

/* --- 10. Enhanced Interactive Transcript Styles --- */
.transcript-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, white 0%, #f8fafc 100%);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 1.5rem;
}

.transcript-header h3 {
    font-size: var(--font-xl);
    font-weight: 800;
    color: var(--primary-dark);
    margin: 0;
}

.transcript-header .details-grid {
    display: flex;
    gap: 2rem;
}

.transcript-header .detail-item {
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
}

.transcript-header .detail-item strong {
    color: var(--text-muted);
    font-size: var(--font-xs);
    margin-bottom: 0.25rem;
}

.transcript-header .detail-item span {
    font-size: var(--font-lg);
    color: var(--text-main);
}

.level-results {
    margin-bottom: 1.5rem;
    animation: fadeInUp 0.5s ease-out backwards;
}

.level-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 0.8rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary-color);
    /* LTR default */
    border-right: none;
}

html[dir="rtl"] .level-header {
    border-left: none;
    border-right: 4px solid var(--primary-color);
}

.level-header h2 {
    font-size: var(--font-lg);
    color: var(--primary-dark);
    margin: 0;
}

.semester-results {
    background: white;
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 0;
    border: 1px solid #f1f5f9;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.semester-results:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--primary-light);
}

.semester-results h4 {
    font-size: var(--font-base);
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.5rem;
}

.summary-row td {
    background-color: #f8fafc;
    color: var(--primary-dark);
    font-size: var(--font-base);
    border-top: 2px solid #e2e8f0;
}

/* Status Badges (added via CSS based on text content if possible, or simple coloring) */
.results-table td[data-label="الحالة"] {
    font-weight: 700;
}

/* Status Badges */

.badge-success {
    color: var(--success-color);
    background-color: rgba(16, 185, 129, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
}

.badge-danger {
    color: var(--danger-color);
    background-color: rgba(239, 68, 68, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
}

.badge-neutral {
    color: var(--secondary-color);
    background-color: #f1f5f9;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* --- 11. Refined Official Transcript Styles (Paper-Like) --- */
.official-replica-wrapper {
    background: #fff;
    color: #111;
    font-family: 'Times New Roman', 'Tajawal', serif;
    max-width: 1000px;
    margin: 2rem auto;
    padding: 2rem;
    border: 1px solid #e5e5e5;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    /* Soft lift for preview */
}

@media print {
    .official-replica-wrapper {
        margin: 0;
        padding: 0;
        border: none;
        box-shadow: none;
    }

    .semesters-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 1rem;
    }

    .semester-results {
        break-inside: avoid;
        margin-bottom: 0;
        border: 1px solid #ddd;
    }
}

/* Semesters Grid Layout */
.semesters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .semesters-grid {
        display: flex;
        /* Force stack on mobile */
        flex-direction: column;
    }
}