:root {
    --primary-color: #14243A; /* كحلي */
    --secondary-color: #16B8A6; /* أخضر فيروزي */
    --text-color: #333333;
    --bg-color: #F8FAFC;
    --white: #FFFFFF;
    --gray: #f3f4f6;
    --gray-dark: #6b7280;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.main-header {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 10px 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.main-header .container.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 16px;
}

/* Logo */
.logo {
    flex-shrink: 0;
}

.logo a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.logo img {
    max-height: 44px;
    width: auto;
    object-fit: contain;
}

.logo .logo-text {
    display: flex;
    flex-direction: column;
}

.logo h1 {
    font-size: 1.45rem;
    color: var(--secondary-color);
    font-weight: 800;
    line-height: 1.1;
    margin: 0;
    white-space: nowrap;
}

.logo .specialty {
    font-size: 0.78rem;
    opacity: 0.88;
    line-height: 1.2;
    white-space: nowrap;
}

/* Main Navigation */
.main-nav {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.main-nav > ul {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: nowrap;
    white-space: nowrap;
    list-style: none;
    margin: 0;
    padding: 0;
}

.main-nav li {
    list-style: none;
}

.main-nav a,
.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    font-size: 0.92rem;
    padding: 6px 11px;
    border-radius: 6px;
    color: var(--white);
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}

.main-nav a:hover,
.main-nav a.active,
.dropdown-toggle:hover,
.dropdown-toggle:focus,
.nav-item.dropdown.is-open .dropdown-toggle {
    background-color: var(--secondary-color);
    color: var(--white);
    outline: none;
}

/* Dropdown Navigation */
.nav-item.dropdown {
    position: relative;
    list-style: none;
    display: inline-flex;
    align-items: center;
}

.dropdown-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    gap: 5px;
}

.dropdown-arrow {
    font-size: 0.8rem;
    transition: transform 0.2s ease;
    display: inline-block;
}

.nav-item.dropdown.is-open .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: auto;
    min-width: 100%;
    width: max-content;
    max-width: 220px;
    background-color: var(--white);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    padding: 4px 0;
    margin: 0;
    list-style: none;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    text-align: right;
    pointer-events: none;
}

/* Hover bridge to keep dropdown stable during mouse transition */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 0;
    left: 0;
    height: 8px;
}

@media (hover: hover) and (pointer: fine) {
    .nav-item.dropdown:hover .dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        pointer-events: auto;
    }
    .nav-item.dropdown:hover .dropdown-arrow {
        transform: rotate(180deg);
    }
}

.nav-item.dropdown.is-open .dropdown-menu {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
}

.dropdown-menu li {
    width: 100%;
    margin: 0;
    padding: 0;
    display: block;
}

.dropdown-menu a {
    display: block;
    width: 100%;
    padding: 8px 14px;
    color: #1e293b;
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1.4;
    text-decoration: none;
    border-radius: 0;
    background: transparent;
    transition: background 0.15s ease, color 0.15s ease;
    box-sizing: border-box;
    white-space: nowrap;
}

.dropdown-menu a:hover,
.dropdown-menu a:focus {
    background-color: #f1f5f9;
    color: var(--primary-color);
    outline: none;
}

/* Header Actions & Search Form */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.search-form {
    display: flex;
    align-items: center;
    margin: 0;
}

.search-form input {
    padding: 7px 12px;
    border: 1px solid transparent;
    border-radius: 0 6px 6px 0;
    outline: none;
    font-family: 'Cairo', sans-serif;
    font-size: 0.88rem;
    width: 155px;
    background: #ffffff;
    color: var(--text-color);
    transition: width 0.25s ease, border-color 0.2s ease;
}

.search-form input:focus {
    width: 185px;
    border-color: var(--secondary-color);
}

.search-form button {
    padding: 7px 14px;
    background-color: var(--secondary-color);
    color: var(--white);
    border: none;
    border-radius: 6px 0 0 6px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    font-size: 0.88rem;
    transition: var(--transition);
}

.search-form button:hover {
    background-color: #129b8c;
}

/* Mobile Nav Toggle Button */
.mobile-nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 38px;
    height: 38px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    padding: 7px;
    cursor: pointer;
    transition: var(--transition);
}

.mobile-nav-toggle:hover,
.mobile-nav-toggle:focus {
    background: rgba(255, 255, 255, 0.12);
    outline: none;
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    height: 100%;
}

.hamburger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--white);
    border-radius: 2px;
    transition: all 0.25s ease;
}

.mobile-nav-toggle.is-active .hamburger-icon span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-nav-toggle.is-active .hamburger-icon span:nth-child(2) {
    opacity: 0;
}

.mobile-nav-toggle.is-active .hamburger-icon span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Mobile Drawer Top Bar, Close Button & Backdrop (Hidden on Desktop by default) */
.mobile-nav-top,
.mobile-nav-close,
.mobile-nav-backdrop {
    display: none;
}

/* ==========================================================================
   Responsive Breakpoints for Header & Navigation
   ========================================================================== */
@media (max-width: 1024px) {
    body.mobile-nav-open {
        overflow: hidden;
    }

    .main-header {
        padding: 8px 0;
    }

    .main-header .container.header-container {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }

    .header-actions {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }

    .mobile-nav-toggle {
        display: flex;
        flex-shrink: 0;
        width: 38px;
        height: 38px;
        padding: 8px;
    }

    /* Backdrop */
    .mobile-nav-backdrop {
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background-color: rgba(0, 0, 0, 0.45);
        z-index: 1040;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.28s ease;
    }

    .mobile-nav-backdrop.is-open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Off-canvas Drawer Navigation */
    .main-nav {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(320px, 86vw);
        height: 100vh;
        height: 100dvh;
        background-color: #1e3a5f;
        box-shadow: -4px 0 25px rgba(0, 0, 0, 0.3);
        z-index: 1050;
        margin: 0;
        padding: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        border-top: none;
        border-left: 1px solid rgba(255, 255, 255, 0.12);
        transform: translateX(105%);
        visibility: hidden;
        pointer-events: none;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s ease;
    }

    .main-nav.is-open {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
    }

    .mobile-nav-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 18px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
        background-color: #162b46;
        flex-shrink: 0;
    }

    .mobile-nav-brand {
        font-size: 1.15rem;
        font-weight: 800;
        color: var(--secondary-color);
        user-select: none;
    }

    .mobile-nav-close {
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        color: var(--white);
        width: 34px;
        height: 34px;
        border-radius: 6px;
        font-size: 1.4rem;
        line-height: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background-color 0.2s ease, transform 0.2s ease;
    }

    .mobile-nav-close:hover,
    .mobile-nav-close:focus {
        background: rgba(255, 255, 255, 0.25);
        color: var(--white);
        outline: none;
    }

    .main-nav > ul {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        width: 100%;
        padding: 14px 12px 24px 12px;
        box-sizing: border-box;
        white-space: normal;
    }

    .main-nav a,
    .dropdown-toggle {
        width: 100%;
        padding: 11px 14px;
        font-size: 0.95rem;
        font-weight: 600;
        justify-content: space-between;
        border-radius: 8px;
        color: var(--white);
        box-sizing: border-box;
    }

    .main-nav a:hover,
    .main-nav a:focus,
    .main-nav a.active,
    .dropdown-toggle:hover,
    .dropdown-toggle:focus {
        background-color: rgba(255, 255, 255, 0.12);
        color: var(--white);
    }

    .nav-item.dropdown {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .dropdown-menu {
        position: static;
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        box-shadow: none;
        border: none;
        background-color: #162b46;
        border-radius: 8px;
        padding: 4px 6px;
        margin-top: 4px;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        display: none;
    }

    .nav-item.dropdown.is-open .dropdown-menu {
        display: flex !important;
    }

    .dropdown-menu a {
        color: rgba(255, 255, 255, 0.92);
        padding: 9px 12px;
        font-size: 0.9rem;
        border-radius: 6px;
    }

    .dropdown-menu a:hover,
    .dropdown-menu a:focus {
        background-color: rgba(255, 255, 255, 0.15);
        color: var(--white);
    }

    .search-form input {
        width: 135px;
    }

    .search-form input:focus {
        width: 155px;
    }
}

@media (max-width: 540px) {
    .container {
        padding: 0 16px;
    }

    .logo h1 {
        font-size: 1.2rem;
    }

    .logo .specialty {
        font-size: 0.7rem;
    }

    .search-form input {
        width: 105px;
        padding: 6px 8px;
        font-size: 0.82rem;
    }

    .search-form input:focus {
        width: 120px;
    }

    .search-form button {
        padding: 6px 10px;
        font-size: 0.82rem;
    }

    .hero {
        padding: 50px 16px;
        margin-bottom: 30px;
    }

    .hero h1, .hero h2 {
        font-size: 1.7rem;
        margin-bottom: 14px;
    }

    .hero p {
        font-size: 1rem;
    }

    .section-title {
        font-size: 1.6rem;
        margin-top: 30px;
        margin-bottom: 25px;
    }

    .card {
        padding: 22px 18px;
    }

    .card h3 {
        font-size: 1.3rem;
    }

    .card-icon {
        font-size: 2.5rem;
        margin-bottom: 14px;
    }
}

@media (max-width: 380px) {
    .container {
        padding: 0 12px;
    }

    .logo h1 {
        font-size: 1.05rem;
    }

    .logo .specialty {
        font-size: 0.65rem;
    }

    .search-form input {
        width: 85px;
        padding: 5px 6px;
        font-size: 0.78rem;
    }

    .search-form input:focus {
        width: 95px;
    }

    .search-form button {
        padding: 5px 8px;
        font-size: 0.78rem;
    }

    .mobile-nav-toggle {
        width: 34px;
        height: 34px;
        padding: 6px;
    }
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, #1a3253 100%);
    color: var(--white);
    text-align: center;
    padding: 80px 20px;
    margin-bottom: 40px;
    border-bottom: 4px solid var(--secondary-color);
}

.hero h1, .hero h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: var(--secondary-color);
}

.hero p {
    font-size: 1.2rem;
    max-width: 600px;
    margin: 0 auto;
    opacity: 0.9;
}

/* Sections */
.section-title {
    text-align: center;
    margin-bottom: 40px;
    margin-top: 40px;
    color: var(--primary-color);
    font-size: 2rem;
    position: relative;
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background-color: var(--secondary-color);
    margin: 10px auto 0;
    border-radius: 2px;
}

/* Grids */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

@media (max-width: 768px) {
    .grid-3 {
        grid-template-columns: 1fr;
        gap: 18px;
        margin-bottom: 30px;
    }
}

/* Tools Grid (5 أدوات في صف واحد على الشاشات المكتبية الواسعة) */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 15px;
    margin-bottom: 40px;
    align-items: stretch;
}

.tool-card {
    border-top: 4px solid var(--secondary-color);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.tool-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: 0 12px 20px -4px rgba(0, 0, 0, 0.08);
}

.tool-card .card-icon {
    font-size: 1.85rem;
    margin-bottom: 10px;
    line-height: 1;
}

.tool-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.35;
    color: var(--primary-color);
}

.tool-card p {
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--gray-dark);
    margin-bottom: 16px;
    flex-grow: 1;
}

.tool-card .btn {
    width: 100%;
    padding: 8px 10px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 6px;
    margin-top: auto;
    white-space: nowrap;
    text-align: center;
}

/* التجاوب للشاشات المتوسطة والأجهزة اللوحية */
@media (max-width: 1024px) {
    .tools-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 16px;
    }
    .tool-card {
        padding: 22px 16px;
    }
    .tool-card .card-icon {
        font-size: 2rem;
    }
    .tool-card h3 {
        font-size: 1.1rem;
    }
}

@media (max-width: 768px) {
    .tools-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }
    .tool-card {
        padding: 20px 14px;
    }
}

/* الهواتف الذكية */
@media (max-width: 540px) {
    .tools-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .tool-card {
        padding: 18px 16px;
    }
    .tool-card .card-icon {
        font-size: 1.85rem;
    }
    .tool-card h3 {
        font-size: 1.1rem;
    }
    .tool-card p {
        font-size: 0.88rem;
    }
}


/* Cards */
.card {
    background-color: var(--white);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
    border-top: 5px solid var(--primary-color);
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    border-color: var(--secondary-color);
}

.card-icon {
    font-size: 3rem;
    color: var(--secondary-color);
    margin-bottom: 20px;
}

.card h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.card p {
    color: var(--gray-dark);
    margin-bottom: 20px;
    flex-grow: 1;
}

/* Article Cards */
.article-card {
    background-color: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.article-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}

.article-img {
    height: 200px;
    background-color: var(--gray);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-dark);
}

.article-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.article-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.article-content h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.article-content .date {
    font-size: 0.85rem;
    color: var(--gray-dark);
    margin-bottom: 15px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 25px;
    background-color: var(--primary-color);
    color: var(--white);
    border-radius: 6px;
    font-weight: 600;
    transition: var(--transition);
    border: none;
    cursor: pointer;
}

.btn:hover {
    background-color: var(--secondary-color);
}

.btn-secondary {
    background-color: var(--secondary-color);
}

.btn-secondary:hover {
    background-color: var(--primary-color);
}

.btn-outline {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline:hover {
    background-color: var(--primary-color);
    color: var(--white);
}

/* Lists and Tables */
.list-group {
    background-color: var(--white);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 30px;
}

.list-item {
    padding: 15px 20px;
    border-bottom: 1px solid var(--gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.list-item:hover {
    background-color: var(--gray);
}

.list-item-title {
    font-weight: 600;
    color: var(--primary-color);
}

.list-item-meta {
    font-size: 0.9rem;
    color: var(--gray-dark);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    background-color: var(--white);
    border-radius: 8px;
    color: var(--gray-dark);
    margin-bottom: 30px;
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--gray);
    margin-bottom: 20px;
}

/* Page Header */
.page-header {
    background-color: var(--white);
    padding: 40px 0;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--gray);
    text-align: center;
}

.page-header h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

/* Footer */
.main-footer {
    background-color: var(--primary-color);
    color: var(--white);
    text-align: center;
    padding: 30px 0;
    margin-top: auto; /* Push to bottom */
}

.footer-note {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-top: 10px;
}

/* Footer Social Links */
.footer-social-links {
    margin-bottom: 18px;
    text-align: center;
}

.footer-social-links .social-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
}

.footer-social-link {
    color: var(--white);
    opacity: 0.85;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    transition: var(--transition);
}

.footer-social-link:hover,
.footer-social-link:focus {
    opacity: 1;
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.18);
    color: var(--secondary-color);
    outline: none;
}

.footer-social-link svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Responsive */
@media (max-width: 768px) {
    .hero {
        padding: 50px 20px;
    }
    .list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}


/* Article content styles (RTL optimized & Educational) */
.article-body {
    font-size: 1.15rem;
    line-height: 1.9;
    color: #334155; /* Slate 700 */
    font-family: 'Cairo', sans-serif;
}

.article-body h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.article-body h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin: 1.8rem 0 0.8rem;
}

.article-body h4 {
    font-size: 1.25rem;
    color: var(--secondary-color);
    margin: 1.5rem 0 0.5rem;
}

.article-body p {
    margin-bottom: 1.2rem;
}

.article-body ul, .article-body ol {
    margin: 0 1.5rem 1.5rem 0;
    padding-right: 1.5rem;
}

.article-body li {
    margin-bottom: 0.5rem;
}

/* Custom Boxes */
.article-body .box-answer,
.article-body .box-tip,
.article-body .box-alert {
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.article-body .box-answer {
    background-color: #eff6ff; /* blue-50 */
    border-right: 4px solid #3b82f6; /* blue-500 */
    color: #1e3a8a; /* blue-900 */
}

.article-body .box-tip {
    background-color: #f0fdf4; /* green-50 */
    border-right: 4px solid #22c55e; /* green-500 */
    color: #14532d; /* green-900 */
}

.article-body .box-alert {
    background-color: #fef2f2; /* red-50 */
    border-right: 4px solid #ef4444; /* red-500 */
    color: #7f1d1d; /* red-900 */
}

/* Tables */
.article-body .table-responsive {
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Force scroll on small screens */
    margin-bottom: 20px;
}

.article-body th, .article-body td {
    border: 1px solid #cbd5e1;
    padding: 12px 16px;
    text-align: right;
}

.article-body th {
    background-color: var(--secondary-color);
    color: var(--white);
    font-weight: 700;
}

.article-body tr:nth-child(even) {
    background-color: #f8fafc;
}

/* Blockquotes */
.article-body blockquote {
    border-right: 4px solid var(--secondary-color);
    border-left: none;
    padding: 15px 20px;
    color: #475569;
    background: #f1f5f9;
    margin-bottom: 1.5rem;
    border-radius: 4px;
    font-style: italic;
}

/* Images */
.article-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem auto;
    display: block;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.article-body pre {
    background: #1e293b;
    color: #f8fafc;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    direction: ltr;
    text-align: left;
    margin-bottom: 1.5rem;
}

.article-body code {
    font-family: monospace;
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #b91c1c;
}
.article-body pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* Single Article Layout & Responsiveness */
.article-container {
    margin-top: 40px;
    margin-bottom: 60px;
}

.single-article-card {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.article-meta {
    margin-bottom: 20px;
}

.article-meta .category-link {
    color: var(--secondary-color);
    font-weight: bold;
    margin-left: 15px;
}

.article-meta .date {
    color: var(--gray-dark);
    font-size: 0.9rem;
}

.main-article-title {
    color: var(--primary-color);
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    margin-bottom: 30px;
    line-height: 1.4;
    word-wrap: break-word;
}

.article-featured-image {
    margin-bottom: 30px;
    text-align: center;
}

.article-featured-image img {
    display: block;
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    border-radius: 8px;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .article-container {
        margin-top: 20px;
        margin-bottom: 30px;
    }
    .single-article-card {
        padding: 20px 15px;
    }
    .main-article-title {
        margin-bottom: 20px;
    }
    .article-body {
        font-size: 1.05rem;
    }
    .article-body h2 {
        font-size: 1.5rem;
    }
    .article-body h3 {
        font-size: 1.3rem;
    }
}

/* Subject Description Card */
.subject-description-card {
    background-color: var(--white);
    border-radius: 12px;
    padding: 30px;
    margin: 40px auto;
    max-width: 900px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    border-right: 5px solid var(--secondary-color);
    text-align: right;
    display: block;
}
.subject-description-card h2 {
    color: var(--primary-color);
    font-size: 1.6rem;
    margin-bottom: 15px;
    font-weight: 700;
}
.subject-description-card p {
    font-size: 1.15rem;
    color: var(--text-color);
    line-height: 1.8;
}

/* FAQ Accordion */
.faq-container {
    max-width: 800px;
    margin: 0 auto;
}
.faq-item {
    background-color: var(--white);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden;
    transition: var(--transition);
}
.faq-question {
    padding: 20px;
    font-weight: 700;
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-color);
    font-size: 1.1rem;
    user-select: none;
}
.faq-question::after {
    content: '+';
    font-size: 1.8rem;
    color: var(--secondary-color);
    transition: transform 0.3s ease;
    line-height: 1;
}
.faq-item.active {
    border-color: var(--secondary-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}
.faq-item.active .faq-question::after {
    transform: rotate(45deg);
}
.faq-answer {
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease;
    color: var(--text-color);
    background-color: var(--white);
}
.faq-item.active .faq-answer {
    padding: 20px;
    max-height: 1000px;
    border-top: 1px solid #e2e8f0;
}

/* Share Buttons */
.share-buttons-container {
    padding-top: 15px;
    padding-bottom: 15px;
    border-top: 1px solid var(--gray);
    border-bottom: 1px solid var(--gray);
}
.share-btn {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff !important;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s ease, transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    font-family: inherit;
    text-decoration: none;
}
.share-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}
.share-btn:active {
    transform: translateY(0);
}
.fb-share { background-color: #1877f2; }
.tg-share { background-color: #229ED9; }
.wa-share { background-color: #25D366; }
.copy-share { background-color: #64748b; }
.copy-share.success { background-color: #10b981; }
.copy-share.error { background-color: #ef4444; }

/* ========================================================================= */
/* Baccalaureate GPA Calculator (حاسبة معدل البكالوريا - تصميم داكن احترافي) */
/* ========================================================================= */

.bac-calc-page {
    background: linear-gradient(180deg, #0b1524 0%, #0f1c2e 50%, #14243a 100%);
    color: #f1f5f9;
    padding: 35px 0 70px;
    min-height: calc(100vh - 160px);
}

/* Wide Container to utilize full available width */
.bac-calc-container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
    box-sizing: border-box;
}

/* Header Banner */
.bac-calc-header {
    text-align: center;
    margin-bottom: 35px;
}

.bac-calc-stream-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(22, 184, 166, 0.12);
    color: #16b8a6;
    border: 1px solid rgba(22, 184, 166, 0.45);
    padding: 7px 20px;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 14px;
    box-shadow: 0 0 15px rgba(22, 184, 166, 0.1);
}

.bac-calc-title {
    font-size: 2.3rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}

.bac-calc-subtitle {
    font-size: 1.05rem;
    color: #94a3b8;
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Balanced Two-Column Layout */
.bac-calc-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 28px;
    align-items: start;
    margin-bottom: 35px;
}

/* Main Table Container */
.bac-calc-card {
    background: #132238;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.bac-calc-table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.bac-calc-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: right;
}

.bac-calc-table th {
    background: #182b45;
    color: #cbd5e1;
    padding: 14px 18px;
    font-weight: 700;
    font-size: 0.95rem;
    border-bottom: 2px solid rgba(22, 184, 166, 0.35);
    white-space: nowrap;
}

.bac-calc-table th:first-child {
    border-top-right-radius: 10px;
}

.bac-calc-table th:last-child {
    border-top-left-radius: 10px;
}

.bac-calc-table td {
    padding: 13px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

.bac-calc-row {
    transition: background-color 0.2s ease;
}

.bac-calc-row:hover {
    background-color: rgba(22, 184, 166, 0.03);
}

.bac-calc-row.is-exempt {
    background-color: rgba(30, 41, 59, 0.5);
    opacity: 0.7;
}

.bac-subject-name {
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.02rem;
}

.bac-subject-icon {
    font-size: 1.3rem;
    display: inline-block;
    width: 30px;
    text-align: center;
}

.bac-coeff-badge {
    display: inline-block;
    background: #173252;
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.25);
    padding: 5px 12px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.98rem;
    text-align: center;
    min-width: 36px;
}

/* Grade Input Fields */
.bac-grade-input-wrap {
    position: relative;
    max-width: 120px;
}

.bac-grade-input {
    width: 100%;
    background: #091320;
    border: 1.5px solid #243b5a;
    color: #ffffff;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 800;
    text-align: center;
    font-family: inherit;
    transition: all 0.25s ease;
    margin-bottom: 0;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Remove default browser spin buttons */
.bac-grade-input::-webkit-outer-spin-button,
.bac-grade-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.bac-grade-input[type=number] {
    -moz-appearance: textfield;
}

.bac-grade-input:hover:not(:disabled) {
    border-color: #3b82f6;
}

.bac-grade-input:focus {
    border-color: #16b8a6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(22, 184, 166, 0.28), inset 0 2px 4px rgba(0, 0, 0, 0.2);
    background: #0d1b2d;
}

.bac-grade-input:disabled {
    background: #16202e;
    border-color: #273549;
    color: #64748b;
    cursor: not-allowed;
    opacity: 0.6;
}

.bac-grade-input.is-invalid {
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.12) !important;
    color: #fca5a5 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25) !important;
}

.bac-points-display {
    font-weight: 800;
    color: #16b8a6;
    font-size: 1.1rem;
    direction: ltr;
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

.bac-points-exempt {
    color: #e2e8f0;
    font-size: 0.88rem;
    font-weight: 700;
    background: #334155;
    padding: 3px 10px;
    border-radius: 6px;
    display: inline-block;
}

/* Modern Exemption Toggle Switch */
.bac-exempt-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    color: #94a3b8;
    user-select: none;
    transition: color 0.2s ease;
}

.bac-exempt-toggle:hover {
    color: #f1f5f9;
}

.bac-switch-input {
    appearance: none;
    -webkit-appearance: none;
    width: 38px;
    height: 22px;
    background: #1e293b;
    border-radius: 50px;
    border: 1.5px solid #334155;
    position: relative;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
    margin: 0;
    vertical-align: middle;
}

.bac-switch-input::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #94a3b8;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bac-switch-input:checked {
    background: #16b8a6;
    border-color: #16b8a6;
    box-shadow: 0 0 10px rgba(22, 184, 166, 0.4);
}

.bac-switch-input:checked::after {
    transform: translateX(-16px);
    background: #ffffff;
}

/* Actions Bar */
.bac-calc-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    gap: 15px;
    flex-wrap: wrap;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.bac-btn-reset {
    background: rgba(239, 68, 68, 0.08);
    border: 1.5px solid rgba(239, 68, 68, 0.5);
    color: #fca5a5;
    padding: 10px 22px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.bac-btn-reset:hover {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
    transform: translateY(-1px);
}

.bac-btn-print {
    background: #172a45;
    border: 1.5px solid rgba(22, 184, 166, 0.35);
    color: #e2e8f0;
    padding: 10px 22px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.bac-btn-print:hover {
    background: #16b8a6;
    color: #ffffff;
    border-color: #16b8a6;
    box-shadow: 0 4px 14px rgba(22, 184, 166, 0.35);
    transform: translateY(-1px);
}

/* Results Sidebar */
.bac-calc-sidebar {
    position: sticky;
    top: 90px;
}

.bac-results-card {
    background: linear-gradient(145deg, #132238 0%, #0c1828 100%);
    border: 1.5px solid rgba(22, 184, 166, 0.45);
    border-radius: 16px;
    padding: 26px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 0 25px rgba(22, 184, 166, 0.12);
    text-align: center;
}

.bac-results-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 4px;
}

.bac-results-sub {
    font-size: 0.88rem;
    color: #16b8a6;
    font-weight: 700;
    margin-bottom: 20px;
}

.bac-gpa-display {
    background: rgba(8, 17, 30, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

.bac-gpa-number {
    font-size: 3.6rem;
    font-weight: 800;
    color: #16b8a6;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 20px rgba(22, 184, 166, 0.3);
}

.bac-gpa-unit {
    font-size: 1.15rem;
    color: #94a3b8;
    font-weight: 700;
    margin-top: 4px;
}

.bac-mention-tag {
    display: inline-block;
    padding: 6px 20px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 0.95rem;
    margin-top: 12px;
    transition: all 0.3s ease;
}

.mention-default { background: #1e293b; color: #94a3b8; border: 1px solid #334155; }
.mention-excellent { background: rgba(16, 185, 129, 0.18); color: #34d399; border: 1.5px solid #10b981; box-shadow: 0 0 12px rgba(16, 185, 129, 0.2); }
.mention-verygood { background: rgba(6, 182, 212, 0.18); color: #22d3ee; border: 1.5px solid #06b6d4; box-shadow: 0 0 12px rgba(6, 182, 212, 0.2); }
.mention-good { background: rgba(59, 130, 246, 0.18); color: #60a5fa; border: 1.5px solid #3b82f6; box-shadow: 0 0 12px rgba(59, 130, 246, 0.2); }
.mention-fair { background: rgba(139, 92, 246, 0.18); color: #a78bfa; border: 1.5px solid #8b5cf6; box-shadow: 0 0 12px rgba(139, 92, 246, 0.2); }
.mention-passable { background: rgba(245, 158, 11, 0.18); color: #fbbf24; border: 1.5px solid #f59e0b; box-shadow: 0 0 12px rgba(245, 158, 11, 0.2); }
.mention-failed { background: rgba(239, 68, 68, 0.18); color: #f87171; border: 1.5px solid #ef4444; box-shadow: 0 0 12px rgba(239, 68, 68, 0.2); }

/* Progress Bar */
.bac-progress-bar {
    width: 100%;
    height: 10px;
    background: #091320;
    border-radius: 50px;
    overflow: hidden;
    margin: 15px 0 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.bac-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #16b8a6, #38bdf8);
    width: 0%;
    transition: width 0.4s ease;
    border-radius: 50px;
    box-shadow: 0 0 10px rgba(22, 184, 166, 0.5);
}

/* Metrics List */
.bac-metrics-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: right;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 15px;
}

.bac-metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 0;
    font-size: 0.95rem;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}

.bac-metric-item:last-child {
    border-bottom: none;
}

.bac-metric-item span {
    color: #94a3b8;
}

.bac-metric-item strong {
    color: #ffffff;
    font-size: 1.05rem;
}

/* Status Message */
.bac-status-msg {
    margin-top: 18px;
    padding: 13px 16px;
    border-radius: 10px;
    font-size: 0.92rem;
    line-height: 1.6;
    background: rgba(22, 184, 166, 0.08);
    border: 1px solid rgba(22, 184, 166, 0.25);
    color: #e2e8f0;
}

/* Full-Width Lower Sections */
.bac-bottom-section {
    margin-top: 40px;
}

/* Collapsible "How it Works" Full Width Card */
.bac-info-card {
    background: #132238;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 35px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.bac-info-header {
    padding: 20px 28px;
    background: #162840;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background 0.2s ease;
}

.bac-info-header:hover {
    background: #1c3354;
}

.bac-info-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: #ffffff;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 12px;
}

.bac-info-header .bac-toggle-icon {
    font-size: 1.3rem;
    color: #16b8a6;
    transition: transform 0.3s ease;
}

.bac-info-header.active .bac-toggle-icon {
    transform: rotate(180deg);
}

.bac-info-body {
    padding: 28px;
    display: none;
    line-height: 1.85;
    color: #cbd5e1;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: #111e31;
}

.bac-info-body h4 {
    color: #16b8a6;
    font-size: 1.15rem;
    margin: 22px 0 12px;
    font-weight: 700;
}

.bac-info-body h4:first-child {
    margin-top: 0;
}

.bac-info-body ul {
    list-style: disc;
    padding-right: 25px;
    margin-bottom: 16px;
}

.bac-info-body li {
    margin-bottom: 8px;
}

.bac-formula-box {
    background: #091320;
    border-right: 4px solid #16b8a6;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 16px 24px;
    border-radius: 8px;
    margin: 18px 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #38bdf8;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Balanced Two-Column Lower Grid for Definition Card & FAQs */
.bac-extra-grid {
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    gap: 28px;
    align-items: start;
}

.bac-tool-desc-card {
    background: #132238;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-right: 5px solid #16b8a6;
    border-radius: 16px;
    padding: 26px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    height: 100%;
    box-sizing: border-box;
}

.bac-tool-desc-card h3 {
    color: #16b8a6;
    font-size: 1.35rem;
    margin-bottom: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
}

.bac-tool-desc-card p {
    color: #cbd5e1;
    font-size: 1.05rem;
    line-height: 1.85;
    margin: 0;
}

/* Dark Mode FAQs Accordion on Calculator Page */
.bac-calc-page .faq-container {
    max-width: 100%;
    margin: 0;
}

.bac-calc-page .faq-item {
    background: #132238;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    margin-bottom: 14px;
    overflow: hidden;
}

.bac-calc-page .faq-question {
    background: #162840;
    color: #ffffff;
    padding: 18px 22px;
    font-size: 1.05rem;
    font-weight: 700;
}

.bac-calc-page .faq-question:hover {
    background: #1a304e;
}

.bac-calc-page .faq-question::after {
    color: #16b8a6;
}

.bac-calc-page .faq-item.active {
    border-color: #16b8a6;
    box-shadow: 0 4px 15px rgba(22, 184, 166, 0.15);
}

.bac-calc-page .faq-answer {
    background: #111e31;
    color: #cbd5e1;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 18px 22px;
    line-height: 1.75;
}

/* Print Styles */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
    .main-header, .main-footer, .bac-calc-actions, .bac-bottom-section, .search-form {
        display: none !important;
    }
    .bac-calc-page {
        background: #ffffff !important;
        color: #000000 !important;
        padding: 0 !important;
    }
    .bac-calc-card, .bac-results-card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        background: #ffffff !important;
        color: #000000 !important;
    }
    .bac-calc-table th {
        background: #f1f5f9 !important;
        color: #000000 !important;
    }
    .bac-calc-table td {
        color: #000000 !important;
    }
    .bac-grade-input {
        background: #ffffff !important;
        color: #000000 !important;
        border: none !important;
    }
    .bac-results-card {
        page-break-before: avoid;
    }
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    .bac-calc-layout {
        grid-template-columns: 1fr;
    }
    .bac-calc-sidebar {
        position: static;
        order: -1; /* Display results above the table on tablets and mobile */
        margin-bottom: 25px;
    }
    .bac-results-card {
        max-width: 600px;
        margin: 0 auto;
    }
    .bac-extra-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .bac-calc-page {
        padding: 20px 0 50px;
    }
    .bac-calc-container {
        padding: 0 12px;
    }
    .bac-calc-title {
        font-size: 1.65rem;
    }
    .bac-calc-subtitle {
        font-size: 0.95rem;
    }
    .bac-calc-card {
        padding: 16px 10px;
        border-radius: 12px;
    }
    .bac-calc-table th, .bac-calc-table td {
        padding: 10px 8px;
        font-size: 0.88rem;
    }
    .bac-subject-name {
        font-size: 0.9rem;
        gap: 6px;
    }
    .bac-subject-icon {
        width: 22px;
        font-size: 1.1rem;
    }
    .bac-coeff-badge {
        padding: 4px 8px;
        font-size: 0.88rem;
        min-width: 28px;
    }
    .bac-grade-input-wrap {
        max-width: 80px;
    }
    .bac-grade-input {
        padding: 6px 4px;
        font-size: 0.98rem;
    }
    .bac-gpa-number {
        font-size: 2.8rem;
    }
    .bac-info-header {
        padding: 16px 18px;
    }
    .bac-info-body {
        padding: 18px;
    }
    .bac-tool-desc-card {
        padding: 20px 16px;
    }
}

/* ========================================================================= */
/* Scientific Calculator (الآلة الحاسبة العلمية المتطورة)                      */
/* ========================================================================= */

.sci-calc-page {
    background: linear-gradient(180deg, #0b1524 0%, #0f1c2e 50%, #14243a 100%);
    color: #f1f5f9;
    padding: 35px 0 70px;
    min-height: calc(100vh - 160px);
}

.sci-calc-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

.sci-calc-header {
    text-align: center;
    margin-bottom: 30px;
}

.sci-calc-stream-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(22, 184, 166, 0.12);
    color: #16b8a6;
    border: 1px solid rgba(22, 184, 166, 0.45);
    padding: 6px 18px;
    border-radius: 50px;
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.sci-calc-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 8px;
}

.sci-calc-subtitle {
    font-size: 1.05rem;
    color: #94a3b8;
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.6;
}

.sci-calc-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 28px;
    align-items: start;
}

/* Calculator Unit */
.sci-calc-unit {
    background: #0d1b2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

/* Screen */
.sci-screen {
    background: #060e18;
    border: 1px solid rgba(22, 184, 166, 0.3);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 18px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sci-screen-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    color: #64748b;
}

.sci-mode-pill {
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-family: monospace;
    color: #16b8a6;
    background: rgba(22, 184, 166, 0.15);
}

.sci-memory-indicator {
    color: #94a3b8;
    font-size: 0.78rem;
}

.sci-expression-line {
    min-height: 26px;
    font-size: 1.15rem;
    color: #94a3b8;
    font-family: 'Consolas', 'Courier New', monospace;
    direction: ltr;
    text-align: left;
    overflow-x: auto;
    white-space: nowrap;
}

.sci-result-line {
    min-height: 50px;
    font-size: 2.3rem;
    font-weight: 700;
    color: #ffffff;
    font-family: 'Consolas', 'Courier New', monospace;
    direction: ltr;
    text-align: left;
    overflow-x: auto;
    white-space: nowrap;
    transition: color 0.18s ease;
}

.sci-result-line.has-error {
    color: #f87171;
    font-size: 1.25rem;
    font-family: 'Cairo', sans-serif;
    direction: rtl;
    text-align: right;
}

.sci-error-toast {
    display: none;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 6px;
    margin-top: 4px;
    text-align: right;
}

/* Mode & Utility Bar */
.sci-util-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

/* Keypad Grid (5 columns) */
.sci-keypad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

/* Button Base */
.sci-btn {
    height: 48px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-family: 'Cairo', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s ease;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #112238;
    color: #cbd5e1;
    outline: none;
}

.sci-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.sci-btn:active {
    transform: translateY(1px);
    filter: brightness(0.9);
}

/* Specialized Buttons */
.sci-btn-num {
    background: #14243a;
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 700;
}

.sci-btn-op {
    background: #1a3352;
    color: #38bdf8;
    font-size: 1.25rem;
    font-weight: 700;
}

.sci-btn-fn {
    background: #112238;
    color: #94a3b8;
    font-size: 0.95rem;
}

.sci-btn-fn sup, .sci-btn-fn sub {
    font-size: 0.75rem;
}

.sci-btn-mode {
    background: rgba(22, 184, 166, 0.12);
    color: #16b8a6;
    border-color: rgba(22, 184, 166, 0.35);
    font-weight: 700;
}

.sci-btn-mode.is-active {
    background: #16b8a6;
    color: #ffffff;
}

.sci-btn-del {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.35);
}

.sci-btn-clear {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.35);
    font-weight: 700;
}

.sci-btn-equal {
    grid-column: span 2;
    background: #13aa9a;
    color: #ffffff;
    font-size: 1.4rem;
    font-weight: 800;
    border-color: #16b8a6;
    box-shadow: 0 4px 12px rgba(19, 170, 154, 0.35);
}

.sci-btn-equal:hover {
    background: #109385;
}

/* Sidebar */
.sci-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sci-card {
    background: #0d1b2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}

.sci-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 12px;
    margin-bottom: 14px;
}

.sci-card-header h3 {
    margin: 0;
    font-size: 1.15rem;
    color: #ffffff;
    font-weight: 700;
}

.sci-clear-history-btn {
    background: transparent;
    border: none;
    color: #f87171;
    font-family: 'Cairo', sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.sci-clear-history-btn:hover {
    background: rgba(239, 68, 68, 0.15);
}

.sci-history-list {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sci-history-item {
    background: #081220;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    direction: ltr;
}

.sci-history-item:hover {
    border-color: rgba(22, 184, 166, 0.5);
    background: #0d1e34;
}

.sci-history-expr {
    font-size: 0.88rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sci-history-val {
    font-size: 1.1rem;
    font-weight: 700;
    color: #16b8a6;
}

.sci-history-empty {
    text-align: center;
    color: #64748b;
    font-size: 0.9rem;
    padding: 25px 0;
}

/* Shortcuts list */
.sci-shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.88rem;
}

.sci-shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.sci-kbd {
    display: inline-block;
    background: #14243a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #38bdf8;
    font-family: monospace;
    font-size: 0.82rem;
    padding: 2px 7px;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Responsive */
@media (max-width: 992px) {
    .sci-calc-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .sci-calc-unit {
        padding: 14px 10px;
    }
    .sci-screen {
        padding: 12px 14px;
    }
    .sci-result-line {
        font-size: 1.8rem;
    }
    .sci-btn {
        height: 44px;
        font-size: 0.95rem;
    }
    .sci-btn-num {
        font-size: 1.1rem;
    }
    .sci-keypad, .sci-util-bar {
        gap: 5px;
    }
    .sci-calc-title {
        font-size: 1.7rem;
    }
}

/* ========================================================================= */
/* Formulas Library (مكتبة القوانين التعليمية لشعبة العلوم التجريبية)           */
/* ========================================================================= */

.formulas-page {
    background: linear-gradient(180deg, #0b1524 0%, #0f1c2e 50%, #14243a 100%);
    color: #f1f5f9;
    padding: 35px 0 70px;
    min-height: calc(100vh - 160px);
}

.formulas-container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

.formulas-header {
    text-align: center;
    margin-bottom: 35px;
}

.formulas-stream-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(22, 184, 166, 0.12);
    color: #16b8a6;
    border: 1px solid rgba(22, 184, 166, 0.45);
    padding: 6px 18px;
    border-radius: 50px;
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.formulas-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 8px;
}

.formulas-subtitle {
    font-size: 1.05rem;
    color: #94a3b8;
    max-width: 720px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Controls (Search & Tabs) */
.formulas-controls {
    background: #0d1b2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 22px;
    margin-bottom: 25px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Search Box */
.formula-search-wrap {
    position: relative;
    width: 100%;
}

.formula-search-input {
    width: 100%;
    background: #060e18;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 14px 44px 14px 75px;
    color: #ffffff;
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.formula-search-input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(19, 170, 154, 0.2);
}

.formula-search-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 1.1rem;
    pointer-events: none;
}

.formula-search-clear {
    position: absolute;
    left: 45px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #94a3b8;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.15s;
}

.formula-search-clear:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.formula-search-kbd {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: #14243a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #64748b;
    font-family: monospace;
    font-size: 0.78rem;
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
}

/* Subject Tabs */
.formula-tabs-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.formula-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #112238;
    color: #94a3b8;
    font-family: 'Cairo', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.formula-tab-btn:hover {
    background: #162b46;
    color: #ffffff;
}

.formula-tab-btn.is-active {
    background: var(--secondary-color);
    color: #ffffff;
    border-color: var(--secondary-color);
    box-shadow: 0 4px 12px rgba(19, 170, 154, 0.35);
}

/* Category Filter Pills */
.formula-categories-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.formula-cat-pill {
    padding: 6px 14px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: #cbd5e1;
    font-family: 'Cairo', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.formula-cat-pill:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.formula-cat-pill.is-active {
    background: rgba(56, 189, 248, 0.18);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.5);
    font-weight: 700;
}

/* Meta Bar (Counter) */
.formulas-meta-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: 0.92rem;
    color: #94a3b8;
}

.formula-count-badge {
    background: #0d1b2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 600;
    color: #38bdf8;
}

/* Grid of Formula Cards */
.formulas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(560px, 1fr));
    gap: 24px;
}

/* Formula Card */
.formula-card {
    background: #0d1b2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, border-color 0.2s;
}

.formula-card:hover {
    border-color: rgba(22, 184, 166, 0.4);
    transform: translateY(-2px);
}

.formula-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.formula-badges-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.formula-subject-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
}

.formula-subject-badge.is-physics {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.formula-subject-badge.is-math {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.formula-subject-badge.is-science {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.formula-category-badge {
    font-size: 0.78rem;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 6px;
}

.formula-card-title {
    font-size: 1.18rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    line-height: 1.4;
}

/* Formula Box Display */
.formula-display-wrap {
    background: #060e18;
    border: 1px solid rgba(22, 184, 166, 0.3);
    border-radius: 10px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

.formula-box {
    font-family: 'Cambria Math', 'Consolas', 'Courier New', monospace;
    font-size: 1.35rem;
    font-weight: 700;
    color: #38bdf8;
    direction: ltr;
    text-align: left;
    overflow-x: auto;
    white-space: nowrap;
    line-height: 1.7;
    flex: 1;
}

.math-frac {
    display: inline-flex;
    flex-direction: column;
    vertical-align: middle;
    text-align: center;
    padding: 0 4px;
    font-size: 0.95em;
    line-height: 1.1;
}

.math-num {
    border-bottom: 2px solid #38bdf8;
    padding-bottom: 2px;
}

.math-den {
    padding-top: 2px;
}

.math-var {
    color: #ffffff;
}

.math-chem {
    color: #34d399;
    font-size: 1.1rem;
}

.math-res {
    color: #f1f5f9;
}

/* Copy Button */
.copy-formula-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 8px 12px;
    color: #cbd5e1;
    font-family: 'Cairo', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.copy-formula-btn:hover {
    background: rgba(22, 184, 166, 0.2);
    border-color: rgba(22, 184, 166, 0.5);
    color: #ffffff;
}

.copy-formula-btn.is-copied {
    background: rgba(16, 185, 129, 0.25);
    border-color: #10b981;
    color: #34d399;
}

/* Variables Breakdown */
.formula-vars-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 12px 14px;
}

.formula-vars-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.formula-vars-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.88rem;
}

.formula-vars-list li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.5;
}

.formula-var-key {
    font-family: monospace;
    font-weight: 700;
    color: #38bdf8;
    direction: ltr;
    display: inline-block;
    min-width: 32px;
}

.formula-var-desc {
    color: #cbd5e1;
}

/* Conditions & Notes */
.formula-conditions-box {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: rgba(245, 158, 11, 0.08);
    border-right: 3px solid #f59e0b;
    border-radius: 0 6px 6px 0;
    padding: 10px 14px;
    font-size: 0.84rem;
    color: #fde68a;
    line-height: 1.5;
}

.formula-conditions-icon {
    flex-shrink: 0;
    font-size: 1rem;
}

/* Empty State */
.formula-empty-state {
    display: none;
    background: #0d1b2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 50px 20px;
    text-align: center;
}

.formula-empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.formula-empty-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 8px;
}

.formula-empty-text {
    font-size: 0.95rem;
    color: #94a3b8;
    max-width: 480px;
    margin: 0 auto 20px;
    line-height: 1.6;
}

.formula-reset-btn {
    background: var(--secondary-color);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 10px 22px;
    font-family: 'Cairo', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.formula-reset-btn:hover {
    background: #109385;
}

/* Responsive */
@media (max-width: 768px) {
    .formulas-grid {
        grid-template-columns: 1fr;
    }
    .formula-display-wrap {
        flex-direction: column;
        align-items: flex-start;
    }
    .copy-formula-btn {
        width: 100%;
        justify-content: center;
    }
    .formula-box {
        font-size: 1.18rem;
    }
    .formulas-title {
        font-size: 1.7rem;
    }
}

/* ========================================================================= */
/* Study Timer (مؤقت المراجعة والتركيز — تقنية بومودورو)                     */
/* ========================================================================= */

.timer-page {
    background: linear-gradient(180deg, #0b1524 0%, #0f1c2e 50%, #14243a 100%);
    color: #f1f5f9;
    padding: 35px 0 70px;
    min-height: calc(100vh - 160px);
}

.timer-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

.timer-header {
    text-align: center;
    margin-bottom: 30px;
}

.timer-stream-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(22, 184, 166, 0.12);
    color: #16b8a6;
    border: 1px solid rgba(22, 184, 166, 0.45);
    padding: 6px 18px;
    border-radius: 50px;
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.timer-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 8px;
}

.timer-subtitle {
    font-size: 1.05rem;
    color: #94a3b8;
    max-width: 680px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Timer Main Card */
.timer-card {
    background: #0d1b2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 35px 25px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* Mode Switcher Tabs */
.timer-modes-bar {
    display: flex;
    background: #060e18;
    padding: 6px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    gap: 6px;
    margin-bottom: 30px;
    max-width: 480px;
    width: 100%;
}

.timer-mode-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 50px;
    padding: 10px 16px;
    color: #94a3b8;
    font-family: 'Cairo', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-align: center;
}

.timer-mode-btn:hover {
    color: #ffffff;
}

.timer-mode-btn.is-active {
    background: var(--secondary-color);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(19, 170, 154, 0.35);
}

.timer-card.mode-shortBreak .timer-mode-btn.is-active {
    background: #0ea5e9;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.35);
}

.timer-card.mode-longBreak .timer-mode-btn.is-active {
    background: #f59e0b;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

/* Circular Progress & Display */
.timer-dial-wrap {
    position: relative;
    width: 320px;
    height: 320px;
    margin: 10px 0 25px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.06);
    stroke-width: 8;
}

.timer-circle-progress {
    fill: none;
    stroke: var(--secondary-color);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s ease, stroke 0.3s ease;
    filter: drop-shadow(0 0 8px rgba(19, 170, 154, 0.5));
}

.timer-card.mode-shortBreak .timer-circle-progress {
    stroke: #0ea5e9;
    filter: drop-shadow(0 0 8px rgba(14, 165, 233, 0.5));
}

.timer-card.mode-longBreak .timer-circle-progress {
    stroke: #f59e0b;
    filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.5));
}

.timer-inner-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
    text-align: center;
}

.timer-stage-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.timer-digits {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 4.6rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1;
    letter-spacing: 2px;
    margin-bottom: 10px;
    user-select: none;
}

.timer-cycle-dots {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.timer-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transition: all 0.2s ease;
}

.timer-dot.is-filled {
    background: var(--secondary-color);
    box-shadow: 0 0 8px var(--secondary-color);
}

/* Control Buttons */
.timer-controls-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.timer-btn-primary {
    background: var(--secondary-color);
    color: #ffffff;
    border: none;
    border-radius: 50px;
    padding: 14px 44px;
    font-family: 'Cairo', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 6px 20px rgba(19, 170, 154, 0.4);
    min-width: 170px;
    text-align: center;
}

.timer-btn-primary:hover {
    transform: translateY(-2px);
    background: #109385;
}

.timer-btn-primary.is-running {
    background: #f59e0b;
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.timer-btn-primary.is-running:hover {
    background: #d97706;
}

.timer-btn-secondary {
    background: #14243a;
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50px;
    padding: 12px 22px;
    font-family: 'Cairo', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.timer-btn-secondary:hover {
    background: #1e3654;
    color: #ffffff;
}

/* Quick Tools Bar (Sound, Settings, Shortcuts) */
.timer-quick-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
}

.timer-icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 14px;
    color: #94a3b8;
    font-family: 'Cairo', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.timer-icon-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.timer-icon-btn.is-active {
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.4);
}

/* Alert Banner (Session Complete) */
.timer-completion-alert {
    display: none;
    position: fixed;
    top: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: #10b981;
    color: #ffffff;
    padding: 14px 26px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    font-family: 'Cairo', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    z-index: 2000;
    animation: slideDownAlert 0.3s ease;
    text-align: center;
}

@keyframes slideDownAlert {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Bottom Grid (Stats, Settings, Shortcuts) */
.timer-bottom-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 24px;
}

@media (max-width: 768px) {
    .timer-bottom-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

.timer-info-card {
    background: #0d1b2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.timer-info-card h3 {
    margin: 0 0 15px 0;
    font-size: 1.15rem;
    color: #ffffff;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 12px;
}

/* Settings Form Controls */
.timer-settings-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.timer-setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timer-setting-row label {
    font-size: 0.92rem;
    color: #cbd5e1;
    font-weight: 600;
}

.timer-setting-input {
    background: #060e18;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #38bdf8;
    font-family: monospace;
    font-size: 1rem;
    font-weight: 700;
    padding: 6px 10px;
    width: 65px;
    text-align: center;
    outline: none;
}

.timer-setting-input:focus {
    border-color: var(--secondary-color);
}

.timer-save-btn {
    background: var(--secondary-color);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-family: 'Cairo', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 6px;
    transition: background 0.15s;
}

.timer-save-btn:hover {
    background: #109385;
}

/* Stats */
.timer-stats-wrap {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.timer-stat-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #060e18;
    padding: 14px 18px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.timer-stat-label {
    font-size: 0.95rem;
    color: #94a3b8;
}

.timer-stat-number {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--secondary-color);
    font-family: monospace;
}

/* Shortcuts list */
.timer-shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.88rem;
}

.timer-shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

/* Responsive */
@media (max-width: 600px) {
    .timer-dial-wrap {
        width: 270px;
        height: 270px;
    }
    .timer-digits {
        font-size: 3.8rem;
    }
    .timer-btn-primary {
        width: 100%;
        padding: 12px 20px;
        font-size: 1.15rem;
    }
    .timer-modes-bar {
        border-radius: 12px;
    }
    .timer-mode-btn {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
    .timer-card {
        padding: 25px 15px;
    }
    .timer-title {
        font-size: 1.7rem;
    }
}

/* ========================================================================= */
/* Tests & Baccalaureate Simulation (الاختبارات التفاعلية ومحاكاة البكالوريا) */
/* ========================================================================= */

.tests-page {
    background: #f8fafc;
    padding: 40px 0 80px;
    min-height: calc(100vh - 160px);
}

.tests-header {
    text-align: center;
    margin-bottom: 35px;
}

.tests-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(22, 184, 166, 0.1);
    color: var(--secondary-color);
    border: 1px solid rgba(22, 184, 166, 0.35);
    padding: 6px 18px;
    border-radius: 50px;
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 14px;
}

.tests-title {
    font-size: 2.3rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.tests-subtitle {
    font-size: 1.05rem;
    color: #64748b;
    max-width: 720px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Filter Card */
.tests-filter-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 35px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tests-type-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 14px;
}

.tests-tab-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    color: #64748b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
    text-decoration: none;
}

.tests-tab-btn:hover {
    color: var(--primary-color);
    border-color: #cbd5e1;
}

.tests-tab-btn.active {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(20, 36, 58, 0.2);
}

.tests-subject-pills {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pills-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #475569;
}

.subject-pill {
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
    text-decoration: none;
}

.subject-pill:hover {
    background: #e2e8f0;
    color: var(--primary-color);
}

.subject-pill.active {
    background: var(--secondary-color);
    color: #ffffff;
    border-color: var(--secondary-color);
}

/* Tests Grid */
.tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: 25px;
    margin-bottom: 45px;
}

.test-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    border-top: 4px solid var(--secondary-color);
}

.test-card.is-simulation {
    border-top-color: #f59e0b;
}

.test-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e1;
}

.test-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    gap: 8px;
    flex-wrap: wrap;
}

.test-badges-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.badge-subject {
    font-size: 0.82rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    background: #eff6ff;
    color: #1d4ed8;
}

.badge-type {
    font-size: 0.82rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
}

.badge-interactive {
    background: #f0fdf4;
    color: #166534;
}

.badge-simulation {
    background: #fffbeb;
    color: #b45309;
}

.badge-year {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 600;
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 4px;
}

.test-card-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 10px;
    line-height: 1.5;
}

.test-card-desc {
    font-size: 0.92rem;
    color: #64748b;
    line-height: 1.6;
    margin-bottom: 18px;
    flex: 1;
}

.test-meta-info {
    display: flex;
    justify-content: space-between;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 20px;
    font-size: 0.85rem;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.meta-label {
    color: #64748b;
    font-size: 0.78rem;
}

.meta-val {
    font-weight: 700;
    color: var(--primary-color);
}

.test-start-btn {
    width: 100%;
    text-align: center;
    padding: 12px;
    font-weight: 700;
    border-radius: 8px;
    background: var(--primary-color);
    color: #ffffff;
    transition: background 0.2s;
    text-decoration: none;
    display: block;
}

.test-card.is-simulation .test-start-btn {
    background: var(--secondary-color);
}

.test-start-btn:hover {
    background: #0b1524;
    color: #ffffff;
}

.test-card.is-simulation .test-start-btn:hover {
    background: #109385;
}

/* Empty State */
.tests-empty-state {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 50px 20px;
    text-align: center;
    color: #64748b;
    margin-bottom: 40px;
}

.empty-icon {
    font-size: 3.5rem;
    margin-bottom: 12px;
}

/* Features Grid */
.tests-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 20px;
    margin-top: 30px;
}

@media (max-width: 600px) {
    .tests-features-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
}

.feature-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 22px;
    text-align: center;
}

.feature-icon {
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.feature-card h3 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.feature-card p {
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.6;
    margin: 0;
}

/* ========================================================================= */
/* Quiz Runner View (test-view.php)                                          */
/* ========================================================================= */

.quiz-runner-page {
    background: #f8fafc;
    min-height: 100vh;
    padding-bottom: 80px;
}

/* Sticky Quiz Header */
.quiz-sticky-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 12px 0;
}

.quiz-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.quiz-header-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quiz-badge-subject {
    background: #f1f5f9;
    color: var(--primary-color);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 700;
}

.quiz-header-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary-color);
    margin: 0;
}

.quiz-header-controls {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

/* Timer Box */
.quiz-timer-box {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-color);
}

.quiz-timer-box.is-warning {
    background: #fee2e2;
    border-color: #f87171;
    color: #dc2626;
    animation: timerPulse 1s infinite alternate;
}

@keyframes timerPulse {
    from { opacity: 1; }
    to { opacity: 0.7; }
}

.timer-digits {
    font-family: monospace;
    font-size: 1.15rem;
    letter-spacing: 1px;
}

/* Progress Wrap */
.quiz-progress-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 130px;
}

.progress-text {
    font-size: 0.78rem;
    color: #64748b;
    font-weight: 600;
}

.quiz-progress-bar {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--secondary-color);
    transition: width 0.3s ease;
}

.quiz-finish-btn {
    padding: 8px 18px;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 6px;
}

/* Body Layout */
.quiz-body-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    margin-top: 30px;
    align-items: start;
}

/* Sidebar Navigation */
.quiz-nav-sidebar {
    position: sticky;
    top: 90px;
}

.quiz-sidebar-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.sidebar-hint {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 16px;
}

.quiz-question-pills {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.q-pill {
    width: 100%;
    height: 42px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.q-pill-unanswered {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #475569;
}

.q-pill-answered {
    background: var(--secondary-color);
    border: 1px solid var(--secondary-color);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(22, 184, 166, 0.3);
}

.q-pill-active {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.quiz-legend {
    display: flex;
    justify-content: space-around;
    padding-top: 14px;
    border-top: 1px solid #f1f5f9;
    font-size: 0.8rem;
    color: #64748b;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot-answered {
    background: var(--secondary-color);
}

.dot-unanswered {
    background: #cbd5e1;
}

/* Question Cards */
.questions-stream {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.quiz-question-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    border-right: 5px solid #cbd5e1;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.quiz-question-card.is-answered {
    border-right-color: var(--secondary-color);
}

.quiz-question-card.is-focused {
    box-shadow: 0 0 0 3px rgba(22, 184, 166, 0.25);
}

.q-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 10px;
    flex-wrap: wrap;
}

.q-number-badge {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--primary-color);
    background: #f1f5f9;
    padding: 6px 14px;
    border-radius: 20px;
}

.q-meta-badges {
    display: flex;
    gap: 8px;
    align-items: center;
}

.q-type-badge {
    font-size: 0.82rem;
    background: #f8fafc;
    color: #475569;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

.q-points-badge {
    font-size: 0.82rem;
    font-weight: 700;
    background: #e0f2fe;
    color: #0369a1;
    padding: 4px 10px;
    border-radius: 4px;
}

.q-text-content {
    font-size: 1.12rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.7;
    margin-bottom: 20px;
}

.q-media-box {
    margin-bottom: 20px;
    text-align: center;
}

.q-media-box img {
    max-width: 100%;
    max-height: 280px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

/* MCQ Options */
.mcq-options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mcq-option-label {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 18px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mcq-option-label:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.mcq-option-label input[type="radio"] {
    display: none;
}

.mcq-radio-custom {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #94a3b8;
    background: #ffffff;
    display: inline-block;
    flex-shrink: 0;
    position: relative;
    transition: all 0.15s;
}

.mcq-option-label input[type="radio"]:checked + .mcq-radio-custom {
    border-color: var(--secondary-color);
    background: var(--secondary-color);
    box-shadow: inset 0 0 0 3px #ffffff;
}

.mcq-option-label:has(input[type="radio"]:checked) {
    background: rgba(22, 184, 166, 0.08);
    border-color: var(--secondary-color);
}

.mcq-option-text {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.5;
}

/* Written Answer Box */
.written-answer-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.written-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-color);
}

.written-textarea {
    width: 100%;
    padding: 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.written-textarea:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(22, 184, 166, 0.15);
}

.written-char-hint {
    font-size: 0.8rem;
    color: #64748b;
}

/* Question Footer Navigation */
.q-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 25px;
    padding-top: 18px;
    border-top: 1px solid #f1f5f9;
}

.q-prev-btn, .q-next-btn, .q-final-review-btn {
    padding: 8px 18px;
    font-size: 0.88rem;
    font-weight: 700;
}

/* Bottom Floating Bar (Mobile / Ease of access) */
.quiz-bottom-bar {
    margin-top: 35px;
    text-align: center;
}

.quiz-bottom-submit-btn {
    padding: 14px 40px;
    font-size: 1.1rem;
    font-weight: 800;
    border-radius: 8px;
}

/* Modal Dialog */
.quiz-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.quiz-modal-dialog {
    background: #ffffff;
    border-radius: 16px;
    max-width: 540px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: modalAppear 0.2s ease-out;
}

@keyframes modalAppear {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

.modal-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary-color);
    margin: 0;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
}

.quiz-modal-body {
    padding: 24px;
}

.modal-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    text-align: center;
}

.summary-box {
    padding: 14px 10px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.summary-num {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.summary-label {
    font-size: 0.8rem;
    color: #64748b;
}

.box-total .summary-num { color: var(--primary-color); }
.box-answered .summary-num { color: var(--secondary-color); }
.box-unanswered .summary-num { color: #ef4444; }

.unanswered-warning {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 16px;
}

.modal-confirm-text {
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.6;
    margin: 0;
}

.quiz-modal-footer {
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ========================================================================= */
/* Quiz Result View (test-result.php)                                        */
/* ========================================================================= */

.quiz-result-page {
    background: #f8fafc;
    padding: 40px 0 80px;
    min-height: calc(100vh - 160px);
}

.result-timeout-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 25px;
    font-weight: 700;
}

.result-hero-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 35px 25px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    margin-bottom: 40px;
}

.result-badge-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.result-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 6px;
}

.result-subtitle {
    font-size: 1rem;
    color: #64748b;
    margin-bottom: 25px;
}

.result-score-circle-wrap {
    margin: 20px 0 25px;
    display: flex;
    justify-content: center;
}

.result-score-circle {
    width: 170px;
    height: 170px;
    border-radius: 50%;
    background: linear-gradient(135deg, #14243a 0%, #1e3a5f 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(20, 36, 58, 0.25);
    border: 5px solid rgba(22, 184, 166, 0.4);
}

.score-number {
    font-size: 2.8rem;
    font-weight: 800;
    color: #38bdf8;
    line-height: 1;
}

.score-max {
    font-size: 0.95rem;
    color: #cbd5e1;
    margin-top: 4px;
}

.result-pending-notice {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 16px 20px;
    max-width: 680px;
    margin: 0 auto 25px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    text-align: right;
}

.notice-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.notice-text {
    font-size: 0.92rem;
    color: #92400e;
    line-height: 1.6;
}

.result-completed-notice {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    padding: 10px 20px;
    border-radius: 50px;
    display: inline-block;
    font-weight: 700;
    margin-bottom: 25px;
}

.result-stats-grid {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.stat-pill {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-label {
    color: #64748b;
}

.stat-val {
    color: var(--primary-color);
}

.result-actions-row {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

/* Correction Section */
.correction-section {
    margin-top: 40px;
}

.correction-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.correction-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    border-right: 5px solid #cbd5e1;
}

.correction-card.is-correct {
    border-right-color: #10b981;
}

.correction-card.is-incorrect {
    border-right-color: #ef4444;
}

.correction-card.is-written {
    border-right-color: #f59e0b;
}

.correction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.q-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.q-num-badge {
    background: var(--primary-color);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 4px 12px;
    border-radius: 20px;
}

.q-type-label {
    font-size: 0.82rem;
    color: #64748b;
}

.grade-full {
    background: #dcfce7;
    color: #166534;
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.9rem;
}

.grade-zero {
    background: #fee2e2;
    color: #991b1b;
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.9rem;
}

.grade-pending {
    background: #fef3c7;
    color: #92400e;
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
}

.correction-question-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.6;
    margin-bottom: 16px;
}

.correction-image {
    margin-bottom: 16px;
}

.correction-image img {
    max-width: 100%;
    max-height: 220px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* MCQ Correction Options */
.mcq-correction-options {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 16px;
}

.options-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 8px;
}

.correction-opt-item {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.92rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
}

.correction-opt-item.option-correct {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
    font-weight: 700;
}

.correction-opt-item.option-wrong {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
    font-weight: 700;
}

.opt-indicator {
    font-weight: 700;
    flex-shrink: 0;
}

/* Written Correction Details */
.written-correction-block {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 16px;
}

.student-answer-wrap, .model-answer-wrap, .admin-feedback-wrap {
    border-radius: 10px;
    padding: 14px 18px;
}

.student-answer-wrap {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
}

.model-answer-wrap {
    background: #fefce8;
    border: 1px solid #fef08a;
}

.admin-feedback-wrap {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}

.block-title {
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.student-answer-wrap .block-title { color: #334155; }
.model-answer-wrap .block-title { color: #854d0e; }
.admin-feedback-wrap .block-title { color: #1e3a8a; }

.student-answer-text, .model-answer-text, .feedback-text {
    font-size: 0.95rem;
    line-height: 1.6;
}

.student-answer-text { color: #0f172a; }
.model-answer-text { color: #713f12; }
.feedback-text { color: #1e40af; }

.correction-explanation {
    background: #f1f5f9;
    border-right: 3px solid var(--secondary-color);
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    font-size: 0.88rem;
    color: #334155;
    line-height: 1.6;
}

.exp-title {
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .quiz-body-layout {
        grid-template-columns: 1fr;
    }
    .quiz-nav-sidebar {
        position: static;
    }
}

@media (max-width: 600px) {
    .tests-grid {
        grid-template-columns: 1fr;
    }
    .tests-title {
        font-size: 1.8rem;
    }
    .quiz-header-inner {
        flex-direction: column;
        align-items: stretch;
    }
    .quiz-header-controls {
        justify-content: space-between;
    }
    .quiz-finish-btn {
        width: 100%;
    }
    .result-score-circle {
        width: 140px;
        height: 140px;
    }
    .score-number {
        font-size: 2.2rem;
    }
    .result-title {
        font-size: 1.6rem;
    }
}

@media print {
    .main-header, footer, .result-actions-row, .quiz-sticky-header, .quiz-nav-sidebar, .quiz-bottom-bar {
        display: none !important;
    }
    .tests-page, .quiz-result-page {
        background: #ffffff !important;
        padding: 0 !important;
    }
    .result-hero-card, .correction-card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
}
/* ========================================================================
   Mobile layout safeguards — targeted fixes for calculator and formula pages
   Keep desktop styling intact; prevent horizontal overflow on narrow screens.
   ======================================================================== */
html, body {
    max-width: 100%;
}
body {
    overflow-x: clip;
}
img, video, canvas, iframe, svg {
    max-width: 100%;
}
*, *::before, *::after {
    box-sizing: border-box;
}

.bac-calc-page,
.bac-calc-page .bac-calc-container,
.bac-calc-page .bac-calc-card,
.bac-calc-page .bac-results-card,
.bac-calc-page .bac-bottom-section,
.bac-calc-page .faq-container,
.bac-calc-page .faq-item,
.formulas-page,
.formulas-page .formulas-container,
.formulas-page .formula-card,
.formulas-page .formula-display-wrap,
.formulas-page .formula-vars-box {
    min-width: 0;
    max-width: 100%;
}

.bac-calc-page table,
.formulas-page table {
    max-width: 100%;
}

.bac-calc-page .faq-question,
.bac-calc-page .faq-answer,
.formulas-page .formula-card-title,
.formulas-page .formula-var-desc,
.formulas-page .formula-conditions-box {
    overflow-wrap: anywhere;
    word-break: normal;
}

.bac-calc-page .faq-answer {
    height: auto;
    max-height: none;
    white-space: normal;
}

.formulas-page .formula-box {
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.formulas-page .formula-vars-list {
    min-width: 0;
    padding-inline-start: 1.25rem;
}

@media (max-width: 768px) {
    .bac-calc-page {
        padding: 24px 0 42px;
        width: 100%;
    }
    .bac-calc-container,
    .formulas-container {
        width: 100%;
        max-width: 100%;
        padding-inline: 12px;
    }
    .bac-calc-page .bac-calc-card,
    .bac-calc-page .bac-results-card,
    .bac-calc-page .bac-bottom-section,
    .formulas-page .formula-card {
        width: 100%;
        min-width: 0;
        margin-inline: 0;
    }
    .bac-calc-page .faq-question {
        padding: 15px 14px;
        line-height: 1.65;
        font-size: 1rem;
        white-space: normal;
    }
    .bac-calc-page .faq-answer {
        padding: 14px;
        line-height: 1.8;
        overflow: visible;
    }
    .formulas-page .formula-card {
        padding-inline: 14px;
    }
    .formulas-page .formula-display-wrap {
        width: 100%;
        align-items: stretch;
    }
    .formulas-page .formula-box {
        width: 100%;
        max-width: 100%;
        font-size: 1rem;
    }
    .formulas-page .formula-vars-list li {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
}

@media (max-width: 420px) {
    .bac-calc-container,
    .formulas-container {
        padding-inline: 10px;
    }
    .formulas-page .formulas-title {
        font-size: clamp(1.35rem, 6vw, 1.7rem);
        overflow-wrap: anywhere;
    }
    .formulas-page .formulas-subtitle {
        font-size: .98rem;
        line-height: 1.85;
    }
}


/* =========================================================
   Rich content styling: pages and articles (RTL + responsive)
   Safe presentation layer; does not permit embedded page CSS.
   ========================================================= */
.article-body,
.page-content,
.static-page-content,
.content-body {
    direction: rtl;
    text-align: right;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 2;
    font-size: 1.05rem;
    color: var(--text-color, #334155);
}
.article-body > *:first-child,
.page-content > *:first-child,
.static-page-content > *:first-child,
.content-body > *:first-child { margin-top: 0; }
.article-body h1, .article-body h2, .article-body h3,
.article-body h4, .page-content h1, .page-content h2,
.page-content h3, .page-content h4,
.static-page-content h1, .static-page-content h2,
.static-page-content h3, .static-page-content h4,
.content-body h1, .content-body h2, .content-body h3, .content-body h4 {
    color: var(--primary-color, #087f5b);
    line-height: 1.55;
    font-weight: 800;
    margin: 1.7em 0 .65em;
}
.article-body h1, .page-content h1, .static-page-content h1, .content-body h1 {font-size: 2rem;}
.article-body h2, .page-content h2, .static-page-content h2, .content-body h2 {
    font-size: 1.65rem;
    padding-bottom: .45em;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}
.article-body h3, .page-content h3, .static-page-content h3, .content-body h3 {font-size: 1.3rem;}
.article-body p, .page-content p, .static-page-content p, .content-body p {margin: 0 0 1.15em;}
.article-body ul, .article-body ol, .page-content ul, .page-content ol,
.static-page-content ul, .static-page-content ol, .content-body ul, .content-body ol {
    padding-right: 1.7rem;
    padding-left: 0;
    margin: .6em 0 1.3em;
}
.article-body li, .page-content li, .static-page-content li, .content-body li {margin: .35em 0;padding-right: .2em;}
.article-body blockquote, .page-content blockquote, .static-page-content blockquote, .content-body blockquote {
    margin: 1.4em 0;
    padding: 1em 1.2em;
    border-right: 4px solid var(--primary-color, #087f5b);
    border-left: 0;
    border-radius: 10px;
    background: var(--light-bg, #f0fdf4);
}
.article-body a, .page-content a, .static-page-content a, .content-body a {text-decoration: underline;text-underline-offset: 3px;}
.article-body img, .page-content img, .static-page-content img, .content-body img {
    max-width: 100%;height: auto;border-radius: 12px;
}
.article-body figure, .page-content figure, .static-page-content figure, .content-body figure {margin: 1.4em 0;text-align:center;}
.article-body figcaption, .page-content figcaption, .static-page-content figcaption, .content-body figcaption {font-size:.9rem;color:#64748b;margin-top:.5em;}
.article-body table, .page-content table, .static-page-content table, .content-body table {
    width:100%;border-collapse:collapse;margin:1.4em 0;display:block;overflow-x:auto;
}
.article-body th, .article-body td, .page-content th, .page-content td,
.static-page-content th, .static-page-content td, .content-body th, .content-body td {
    border:1px solid #dbe5e0;padding:10px 12px;vertical-align:top;min-width:100px;
}
.article-body th, .page-content th, .static-page-content th, .content-body th {background:#eaf7f0;font-weight:800;}
.article-body hr, .page-content hr, .static-page-content hr, .content-body hr {border:0;border-top:1px solid #dbe5e0;margin:2em 0;}
.article-body pre, .page-content pre, .static-page-content pre, .content-body pre {
    white-space:pre-wrap;overflow-wrap:anywhere;padding:1rem;border-radius:10px;background:#f1f5f9;direction:ltr;text-align:left;
}
.article-body code, .page-content code, .static-page-content code, .content-body code {overflow-wrap:anywhere;}
.article-body iframe, .page-content iframe, .static-page-content iframe, .content-body iframe {max-width:100%;}
@media(max-width:600px){
 .article-body,.page-content,.static-page-content,.content-body {font-size:1rem;line-height:1.9}
 .article-body h1,.page-content h1,.static-page-content h1,.content-body h1 {font-size:1.65rem}
 .article-body h2,.page-content h2,.static-page-content h2,.content-body h2 {font-size:1.4rem}
 .article-body h3,.page-content h3,.static-page-content h3,.content-body h3 {font-size:1.2rem}
}

/* Compact homepage article cards; keep other grids and article pages unchanged. */
#news > .grid-3,
#guidance > .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
    align-items: stretch;
}

#news .article-card,
#guidance .article-card {
    min-width: 0;
    border: 1px solid #e2e8ee;
    border-radius: 14px;
    box-shadow: 0 3px 10px rgba(15, 40, 60, 0.06);
}

#news .article-img,
#guidance .article-img {
    height: auto;
    aspect-ratio: 1200 / 630;
}

#news .article-img img,
#guidance .article-img img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#news .article-content,
#guidance .article-content {
    padding: 18px;
    gap: 12px;
}

#news .article-content h3,
#guidance .article-content h3 {
    order: 0;
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

#news .article-content .date,
#guidance .article-content .date {
    order: 1;
    margin: 0;
    font-size: 0.875rem;
}

#news .article-content .btn,
#guidance .article-content .btn {
    order: 2;
    min-height: 44px;
}

@media (max-width: 1024px) {
    #news > .grid-3,
    #guidance > .grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    #news > .grid-3,
    #guidance > .grid-3 {
        grid-template-columns: minmax(0, 1fr);
        max-width: 400px;
        margin-inline: auto;
        gap: 20px;
    }
}
