/* CSS Variables */
:root {
    --primary-color: #d32f2f;
    --secondary-color: #ff6f61;
    --secondary-color-rgb: 255, 111, 97;
    --background-light: #f5f5f5;
    --background-dark: #121212;
    --text-light: #ffffff;
    --text-dark: #000000;
    --card-bg-light: #ffffff;
    --card-bg-dark: #1e1e1e;
    --button-bg: #d32f2f;
    --button-hover: #b71c1c;
    --primary-color-rgb: 211, 47, 47;
    /* New Category Colors - These will be dynamically generated by PHP */
    --category-all-color: var(--primary-color);
    --category-all-hover: var(--button-hover);
    --category-all-rgb: 183, 28, 28; /* Changed to use originalButtonHoverColor for RGB */
}

* {
    font-family: 'Cairo', sans-serif;
    font-family: 'Noto Sans Arabic', sans-serif;  
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base body styles for light and dark themes */
body[data-theme="light"] {
    background-color: var(--background-light);
    --bg-pattern-color: rgba(0, 0, 0, 0.06);
    --bg-pattern-opacity: 0.9;
    color: var(--text-dark);
}

body[data-theme="dark"] {
    background-color: var(--background-dark);
    --bg-pattern-color: rgba(255, 255, 255, 0.05);
    --bg-pattern-opacity: 0.85;
    color: var(--text-light);
}

/* Dark theme header styling */
body[data-theme="dark"] header {
    background: rgba(18, 18, 18, 0.55);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border-bottom: 1px solid rgba(255,255,255,0.12);
    color: var(--text-light);
    position: sticky;
    top: 0;
    z-index: 1000;
}

body[data-theme="dark"] header nav ul li a.nav-link {
    color: #fff !important;
}

body[data-theme="dark"] header nav ul li a {
    color: #fff;
}

body[data-theme="dark"] header .logo,
body[data-theme="dark"] header .logo span {
    color: #fff;
}

/* Ensure active nav link uses primary red in dark theme */
body[data-theme="dark"] header nav ul li a.nav-link.active {
    color: var(--primary-color) !important;
}

body[data-theme="dark"] .category-button:hover:not(.active) {
    background: rgba(255,255,255,0.30);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.45);
}
body[data-theme="dark"] .category-button.active {
    background: #fff;
    color: var(--primary-color);
    border-color: #fff;
    box-shadow: 0 6px 14px rgba(0,0,0,0.5);
    transform: translateY(-1px) scale(1.02);
}

 body { 
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh; /* Ensure body takes full viewport height */
    display: flex;
    flex-direction: column;
    padding-top: 0; /* Header is now sticky, so no need for extra padding */
    position: relative;
    z-index: 0;
 }

 body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background-image: url('../images/BG-1.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.25;
    filter: blur(4px);
    transform: scale(1.02);
    background-color: #2a2a2a;
  }

  body::after {
     content: '';
     position: fixed;
     inset: 0;
     pointer-events: none;
     z-index: -2;
     background-image: radial-gradient(var(--bg-pattern-color, rgba(0, 0, 0, 0.05)) 1px, transparent 1px);
     background-size: 30px 30px;
     opacity: var(--bg-pattern-opacity, 0.85);
 }

/* Header Styling */
header {
    background: rgba(255, 255, 255, 0.78);
    color: var(--text-dark);
    padding: 0.6rem clamp(1rem, 3vw, 2rem);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(18px) saturate(170%);
    -webkit-backdrop-filter: blur(18px) saturate(170%);
    border-bottom: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 10px 28px rgba(0,0,0,0.10);
}

/* RTL swap: logo on visual left, profile on visual right */
header .logo {
    order: 3;
}
header .mobile-menu-toggle {
    order: 2;
}
header .site-nav {
    order: 1;
}

.logo {
    font-size: clamp(1.15rem, 2.2vw, 1.65rem);
    font-weight: 900;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    line-height: 1;
    min-width: 0;
}

.logo span {
    white-space: nowrap;
}

.header-logo {
    height: 52px;
    width: auto;
    object-fit: contain;
}

.site-nav {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between; 
}

header nav ul {
    list-style: none;
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    margin: 0;
}

header nav ul li a {
    color: inherit;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.3s;
}

header nav ul li a:hover {
    opacity: 0.8;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-shrink: 0;
}

.user-display {
    max-width: 8.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
    font-size: 0.86rem;
    color: var(--text-dark);
}

.header-link {
    background: linear-gradient(135deg, var(--primary-color), var(--button-hover));
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 0.86rem;
    padding: 0.5rem 0.95rem;
    border-radius: 8px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.2s ease;
    box-shadow: 0 8px 18px rgba(var(--primary-color-rgb), 0.28);
}

.header-link:hover {
    filter: brightness(0.96);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(var(--primary-color-rgb), 0.34);
}

body[data-theme="dark"] .user-display,
body[data-theme="dark"] .header-link {
    color: #fff;
}

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    background: rgba(var(--primary-color-rgb), 0.08);
    border: 1px solid rgba(var(--primary-color-rgb), 0.24);
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    gap: 5px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: background .22s ease, border-color .22s ease, box-shadow .22s ease;
}

.mobile-menu-toggle .bar {
    width: 21px;
    height: 2px;
    border-radius: 2px;
    background: var(--primary-color);
    display: block;
    transition: transform .28s ease, opacity .18s ease, width .18s ease;
}

.mobile-menu-toggle:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

body.nav-open .mobile-menu-toggle {
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 8px 18px rgba(var(--primary-color-rgb), 0.28);
}

body.nav-open .mobile-menu-toggle .bar {
    background: #fff;
}

body.nav-open .mobile-menu-toggle .bar:nth-child(1){ transform: translateY(7px) rotate(45deg); }
body.nav-open .mobile-menu-toggle .bar:nth-child(2){ opacity:0; width:10px; }
body.nav-open .mobile-menu-toggle .bar:nth-child(3){ transform: translateY(-7px) rotate(-45deg); }

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.08);
    border: 1px solid currentColor;
    color: inherit;
    width: 2.35rem;
    height: 2.35rem;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s;
    flex-shrink: 0;
}

.theme-toggle svg {
    width: 1.15rem;
    height: 1.15rem;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.lang-dropdown {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255,255,255,0.08);
    border: 1px solid currentColor;
    color: inherit;
    min-width: 5.6rem;
    height: 2.35rem;
    padding: 0 2rem 0 0.6rem;
    border-radius: 50px;
    cursor: pointer;
    transition: background 0.3s;
    flex-shrink: 0;
    font-weight: 800;
    font-size: 0.8rem;
    font-family: inherit;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 0.7rem;
}

.lang-dropdown:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.lang-dropdown option {
    color: #333;
    background: #fff;
}

.lang-dropdown option:disabled {
    color: #999;
    background: #f0f0f0;
    cursor: not-allowed;
    font-style: italic;
}

/* User Menu Dropdown */
.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 50px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    transition: background 0.3s, border-color 0.3s;
    font-weight: 600;
    font-size: 0.85rem;
    color: inherit;
}

.user-menu-trigger:hover {
    background: rgba(255, 255, 255, 0.3);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    font-size: 0.85rem;
    font-weight: 700;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-arrow {
    transition: transform 0.3s;
}

.user-menu-trigger[aria-expanded="true"] .dropdown-arrow {
    transform: rotate(180deg);
}

/* Guest Menu Dropdown (when not logged in) */
.guest-menu {
    position: relative;
}

.guest-menu-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.2);
    color: inherit;
    cursor: pointer;
    transition: background 0.25s;
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1;
    outline: none;
}

.guest-menu-trigger:hover {
    background: rgba(255, 255, 255, 0.3);
}

.guest-menu-trigger .guest-icon {
    width: 22px;
    height: 22px;
}

.guest-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 220px;
    max-width: 90vw;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 0.75rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.96);
    transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
    z-index: 200;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    direction: rtl;
    text-align: right;
}

.guest-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.guest-dropdown .dropdown-login {
    color: #67c2ff;
}

.guest-dropdown .dropdown-login:hover {
    background: rgba(103, 194, 255, 0.15);
    border-color: rgba(103, 194, 255, 0.3);
}

body[data-theme="dark"] .guest-menu-trigger {
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
}

body[data-theme="dark"] .guest-menu-trigger:hover {
    background: rgba(255, 255, 255, 0.14);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 260px;
    max-width: 90vw;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 0.75rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.97);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
    z-index: 1000;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.user-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dropdown-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
}

.dropdown-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    overflow: hidden;
    flex-shrink: 0;
}

.dropdown-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dropdown-user-info {
    flex: 1;
    overflow: hidden;
}

.dropdown-username {
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
    margin: 0.5rem 0;
}

.dropdown-section {
    padding: 0.25rem 0;
}

.dropdown-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.35rem;
    padding: 0 0.5rem;
}

.dropdown-lang {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 0.5rem;
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
}

.dropdown-lang option {
    color: #333;
    background: #fff;
}

.dropdown-lang option:disabled {
    color: #999;
    background: #f0f0f0;
    cursor: not-allowed;
    font-style: italic;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: #fff;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.25);
}

.dropdown-item.theme-toggle {
    width: 100%;
    border: none;
    background: rgba(255, 255, 255, 0.08);
}

.dropdown-logout {
    color: #ff6b6b;
}

.dropdown-logout:hover {
    background: rgba(255, 107, 107, 0.15);
    border-color: rgba(255, 107, 107, 0.3);
}

@media (max-width: 860px){
    header {
        padding: 0.55rem 0.8rem;
        flex-wrap: wrap;
        gap: 0.55rem;
    }

    header .logo {
        flex: 1;
        justify-content: flex-start;
        font-size: 1.12rem;
        padding-inline-end: 0;
    }

    .header-logo {
        height: 42px;
    }

    .mobile-menu-toggle {
        display: flex;
        order: 2;
    }

    .site-nav {
        order: 3;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: auto;
        display: block;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        pointer-events: none;
        background: rgba(255,255,255,0.92);
        backdrop-filter: blur(18px) saturate(170%);
        -webkit-backdrop-filter: blur(18px) saturate(170%);
        border: 1px solid rgba(0,0,0,0.10); 
        box-shadow: 0 18px 34px rgba(0,0,0,0.18);
        padding: 0 0.55rem;
        transition: max-height .32s ease, opacity .2s ease;
    }

    body.nav-open .site-nav,
    .site-nav.open {
        max-height: 560px !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        padding-block: 0.55rem;
    }

    header nav ul#primary-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 0.45rem;
        margin: 0;
        padding: 0;
    }

    body.nav-open .site-nav ul#primary-nav,
    .site-nav.open ul#primary-nav {
        padding-top: 0;
    }

    header nav ul#primary-nav li a.nav-link {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        text-align: center;
        padding: 0.62rem 0.8rem;
        font-size: 0.94rem;
        font-weight: 800;
        border-radius: 8px;
        border: 1px solid rgba(0,0,0,0.10);
        background: rgba(255,255,255,0.72);
        color: inherit !important;
    }

    header nav ul#primary-nav li a.nav-link.active {
        background: #fff;
        color: var(--primary-color) !important;
        border-color: rgba(var(--primary-color-rgb), 0.30);
    }

    header nav ul#primary-nav li a.nav-link:hover {
        background: rgba(var(--primary-color-rgb), 0.08);
    }

    body[data-theme="dark"] .site-nav {
        background: rgba(18,18,18,0.94);
        border-color: rgba(255,255,255,0.14);
        box-shadow: 0 18px 34px rgba(0,0,0,0.48);
    }

    body[data-theme="dark"] header nav ul#primary-nav li a.nav-link {
        background: rgba(255,255,255,0.08);
        border-color: rgba(255,255,255,0.14);
    }

    .header-actions {
        order: 4;
        width: 100%;
        display: none;
        grid-template-columns: 1fr auto auto;
        align-items: center;
        gap: 0.5rem;
        padding-top: 0.2rem;
    }

    body.nav-open .header-actions {
        display: grid;
    }

    .header-actions .header-link {
        text-align: center;
        min-height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .user-display {
        grid-column: 1 / -1;
        max-width: none;
        text-align: center;
    }

    .theme-toggle,
    .lang-dropdown {
        margin-top: 0;
    }

    header nav.site-nav.open,
    body.nav-open header nav.site-nav {
        max-height: 560px !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        padding-block: 0.55rem;
    }

    .user-dropdown {
        left: 0.5rem;
        right: 0.5rem;
        min-width: auto;
        max-width: none;
        top: calc(100% + 0.35rem);
    }

    .guest-dropdown {
        left: 0.5rem;
        right: 0.5rem;
        min-width: auto;
        max-width: none;
        top: calc(100% + 0.35rem);
    }

    .user-name {
        max-width: 80px;
    }
}

/* Main Content Styling */
main {
    padding: 3em 2em;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2em;
    flex-grow: 1;
    /* Allow main to grow and push footer down */
    width: 100%;
    /* Ensure main takes full width */
    max-width: 1200px;
    /* Limit width for large screens */
    margin: 0 auto;
    /* Center main content */
}

h1 {
    font-size: 2.5em;
    text-align: center;
    color: var(--primary-color); /* Use primary color for headings */
}

/* Hero title container with logo */
.hero-title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.hero-logo {
    height: 5rem;
    max-width: 300px;
    width: auto;
    object-fit: contain;
}

.hero-title-container h1 {
    margin: 0;
    text-align: center;
}

/* Overlay hero (logo + heading) inside slider top-left */
.office-slider .hero-overlay {
    position: absolute;
    top: -3.5rem; /* raised a bit more per request */
    left: 0.0;
    right: 0.0; /* stretch across width with side margin */
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center; /* center content horizontally */
    gap: .75rem;
    z-index: 10;
    background: linear-gradient(90deg, rgba(0,0,0,0.55), rgba(0,0,0,0.35));
    padding: 0;
    border-radius: 12px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.30);
    border: 1px solid rgba(255,255,255,0.18);
}

.hero-logo-overlay {
    height: 6.3rem; /* 50% larger than previous 4.2rem */
    width: 6.3rem;
    object-fit: contain;
    background: transparent; /* remove white box */
    border: none;
    padding: 0; /* no inner padding so artwork fills natural space */
    box-shadow: none; /* remove shadow per request to remove framed look */
    flex-shrink: 0;
}

.hero-heading {
    font-size: 2.35rem;
    line-height: 1.05;
    color: var(--primary-color);
    text-shadow: 0 2px 8px rgba(0,0,0,0.55);
    margin: 0;
    white-space: nowrap;
    font-weight: 800;
    letter-spacing: .5px;
}

@media (max-width: 640px) {
    .hero-logo-overlay { height: 4.5rem; width: 4.5rem; padding: 0; }
    .hero-heading { font-size: 1.55rem; }
    .office-slider .hero-overlay { top: -1.9rem; left: 0; right: 0; padding: .6rem .8rem .7rem; gap: .55rem; }
}

/* Content Card (for description and category filters) */
.content-card {
    max-width: 900px;
    /* Slightly wider for categories/books overview */
    width: 100%;
    padding: 2em; 
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(0,0,0,0.10);
    color: var(--text-dark);
    transition: background-color 0.3s ease, color 0.3s ease;
    text-align: center;
}

body[data-theme="dark"] .content-card {
    background: rgba(18, 18, 18, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-light);
}

/* Category Button Specifics */
.category-button-group {
    margin-top: 1.2em;
    display: flex;
    gap: 0.5em;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.category-button {
    padding: 0.45em 1.1em;
    font-size: 0.98em;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.15s;
    min-width: 80px;
    background-color: transparent;
    color: var(--button-hover);
    border: 1.2px solid var(--button-hover);
    margin-bottom: 0.2em;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    font-weight: 500;
}

.category-button:hover:not(.active) {
    background-color: var(--button-hover);
    color: #fff;
    border-color: var(--button-hover);
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 2px 8px rgba(var(--button-hover-rgb), 0.10);
}

.category-button.active {
    background-color: var(--button-hover);
    color: #fff;
    border-color: var(--button-hover);
    font-weight: 700;
    box-shadow: 0 3px 7px rgba(var(--button-hover-rgb), 0.18);
    transform: scale(1.04);
}

/* Book Card Specific Styles */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* Adjusted min-width for better spacing */
    gap: 1.5em; /* Increased gap for better visual separation */
    width: 100%;
    justify-content: center;
    padding: 1em; /* Add some padding around the grid */
}

.book-card {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(0,0,0,0.10);
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12); /* Slightly more pronounced shadow */
    padding: 1.2em;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, background-color 0.3s ease, color 0.3s ease;
    height: 100%; /* Ensure cards in a row have equal height */
    position: relative;
    overflow: hidden; /* Hide overflow for image and description */
    cursor: pointer; /* Indicate interactivity */
}

body[data-theme="dark"] .book-card {
    background: rgba(18, 18, 18, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-light);
}

.book-card:hover {
    transform: translateY(-8px); /* More pronounced lift effect */
    box-shadow: 0 12px 28px rgba(0,0,0,0.2); /* Stronger shadow on hover */
}

.book-card img {
    width: 100%;
    max-width: 150px; /* Increased image size for better visibility */
    height: 200px; /* Increased fixed height */
    object-fit: cover;
    border-radius: 12px; /* Nicely rounded corners for the image */
    box-shadow: 0 4px 10px rgba(0,0,0,0.15); /* Improved image shadow */
}

/* Style for hidden image on error */
.book-image.hide-on-error {
    display: none;
}

.book-card h3 {
    font-size: 1.2em; /* Increased font size for title */
    color: var(--primary-color);
    margin-bottom: 0.5em;
    line-height: 1.3;
    font-weight: 700; /* Bolder title */
}

.book-card p {
    font-size: 0.85em; /* Increased font size for author/year */
    color: inherit;
    line-height: 1.4;
    margin-bottom: 0.3em;
}

.book-card .book-author {
    color: #555; /* A slightly softer color for author */
}

body[data-theme="dark"] .book-card .book-author {
    color: #bbb;
}

.book-card .book-year {
    font-style: italic;
    color: #777; /* A distinct color for year */
}

body[data-theme="dark"] .book-card .book-year {
    color: #999;
}

/* Footer Styling */
footer {
    background-color: #222;
    color: #ccc;
    padding: 3em 2em;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2em;
    font-size: 0.9em;
    margin-top: auto;
    /* Push footer to the bottom */
}

footer h4 {
    color: #fff;
    margin-bottom: 1em;
}

footer ul {
    list-style: none;
    padding: 0;
}

footer ul li {
    margin-bottom: 0.5em;
}

footer ul li a {
    color: #ccc;
    text-decoration: none;
}

footer ul li a:hover {
    text-decoration: underline;
}

.footer-bottom {
    text-align: center;
    padding-top: 2em;
    border-top: 1px solid #444;
    color: #888;
    grid-column: 1 / -1;
    /* Span full width in grid */
}

/* Custom class for the books section width */
.books-section-width {
    width: 100%;
}

/* Modal Pop-up Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.7); /* Black w/ opacity */
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px); /* Blur background */
}

.modal-content {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(0,0,0,0.10);
    margin: auto;
    padding: 2em;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 600px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: fadeIn 0.3s ease-out;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body[data-theme="dark"] .modal-content {
    background: rgba(18, 18, 18, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-light);
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 15px;
    left: 15px; /* Position on the left for RTL */
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close-button:hover,
.close-button:focus {
    color: var(--primary-color);
    text-decoration: none;
}

.modal-title {
    font-size: 2em;
    color: var(--primary-color);
    margin-bottom: 0.2em; /* Decreased margin-bottom for title */
    font-weight: 700;
}

.modal-author {
    font-size: 1.1em;
    color: #555;
    margin-bottom: 0.3em; /* Adjusted margin-bottom for author */
}

body[data-theme="dark"] .modal-author {
    color: #bbb;
}

.modal-description {
    font-size: 1em;
    line-height: 1.6;
    margin-bottom: 1.5em;
    color: inherit;
    text-align: justify; /* Justify text for better readability */
}

.modal-image {
    max-width: 375px; /* Increased by 1.5 times (250px * 1.5 = 375px) */
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    margin-top: 1em; /* Space between description and image */
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Specific styling for the Categories heading */
#categories h2 {
    font-size: 2.8em; /* Significantly increased font size */
    margin-bottom: 0.8em; /* Increased margin for more space */
}

/* --- Header nav as tabs --- */
header nav ul li a.nav-link {
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.45);
    font-weight: 700;
    padding: .5em 1em;
    border-radius: 10px;
    transition: background-color .2s ease, color .2s ease, box-shadow .2s ease, transform .15s ease;
    position: relative;
    backdrop-filter: saturate(120%) blur(4px);
}

header nav ul li a.nav-link:hover {
    background: rgba(255,255,255,0.30);
    transform: translateY(-1px);
}

header nav ul li a.nav-link.active {
    background: #fff;
    color: var(--primary-color);
    border-color: #fff;
    box-shadow: 0 6px 14px rgba(0,0,0,0.18);
}

/* underline indicator */
header nav ul li a.nav-link::after {
    content: "";
    position: absolute;
    left: 15%;
    right: 15%;
    bottom: -6px;
    height: 3px;
    border-radius: 3px;
    background: var(--secondary-color);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform .25s ease;
}

header nav ul li a.nav-link.active::after,
header nav ul li a.nav-link:hover::after {
    transform: scaleX(1);
}

/* Smooth in-page scrolling */
html { 
    scroll-behavior: smooth; 
}

/* Pagination controls (theme-adapted compact pills) */
.pagination-controls {
    display: inline-flex;
    gap: .35rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.75rem;
    padding: .25rem .4rem; /* tiny breathing space for focus ring bleed */
    direction: rtl; /* numbers flow right->left */
    width: 100%;
}

.pagination-controls .page-btn,
#pagination-controls .page-btn {
    --pg-bg-light: #fafafa; /* subtle neutral to contrast white cards */
    --pg-bg-dark: #2a2d31;  /* dark neutral */
    --pg-text-light: #222;
    --pg-text-dark: #e9ecef;
    --pg-hover-tint-light: rgba(var(--primary-color-rgb), 0.10);
    --pg-hover-tint-dark: rgba(var(--primary-color-rgb), 0.25);
    --pg-active-shadow: 0 4px 14px -2px rgba(var(--primary-color-rgb),0.45), 0 2px 4px rgba(var(--primary-color-rgb),0.25);
    position: relative;
    appearance: none;
    border: 1px solid rgba(var(--primary-color-rgb),0.18);
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    color: var(--pg-text-light);
    font: 600 .83rem/1 'Cairo','Noto Sans Arabic',sans-serif;
    padding: .52rem .85rem;
    min-width: 40px;
    min-height: 38px;
    border-radius: 12px; /* align with card + site rounded style */
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color .18s ease, color .18s ease, box-shadow .25s ease, transform .18s ease, border-color .18s ease;
    user-select: none;
    letter-spacing: .25px;
    font-variant-numeric: tabular-nums;
    outline: none;
}

/* Dark theme pills */
body[data-theme='dark'] .pagination-controls .page-btn,
body[data-theme='dark'] #pagination-controls .page-btn {
    background: rgba(18, 18, 18, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    color: var(--pg-text-dark);
    border-color: rgba(255,255,255,0.12);
}

/* Hover (non-active) */
.pagination-controls .page-btn:not(.active):not(:disabled):hover,
#pagination-controls .page-btn:not(.active):not(:disabled):hover {
    background: var(--pg-hover-tint-light);
    border-color: rgba(var(--primary-color-rgb),0.35);
    color: var(--primary-color);
}
body[data-theme='dark'] .pagination-controls .page-btn:not(.active):not(:disabled):hover,
body[data-theme='dark'] #pagination-controls .page-btn:not(.active):not(:disabled):hover {
    background: var(--pg-hover-tint-dark);
    color: #fff;
    border-color: rgba(var(--primary-color-rgb),0.55);
}

/* Active state */
.pagination-controls .page-btn.active,
#pagination-controls .page-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: #fff;
    font-weight: 700;
    box-shadow: var(--pg-active-shadow);
    transform: translateY(-1px);
    border-color: transparent;
}

/* Focus ring (accessible) */
.pagination-controls .page-btn:focus-visible,
#pagination-controls .page-btn:focus-visible {
    box-shadow: 0 0 0 2px #fff, 0 0 0 5px rgba(var(--primary-color-rgb),0.55);
}
body[data-theme='dark'] .pagination-controls .page-btn:focus-visible,
body[data-theme='dark'] #pagination-controls .page-btn:focus-visible {
    box-shadow: 0 0 0 2px #1e1e1e, 0 0 0 5px rgba(var(--primary-color-rgb),0.55);
}

/* Disabled state */
.pagination-controls .page-btn:disabled,
#pagination-controls .page-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Subtle press feedback */
.pagination-controls .page-btn:not(:disabled):active,
#pagination-controls .page-btn:not(:disabled):active {
    transform: translateY(0);
    box-shadow: none;
}

/* Ellipsis */
.pagination-controls .ellipsis {
    padding: 0 .4rem;
    font-size: .85rem;
    color: rgba(var(--primary-color-rgb),0.65);
    letter-spacing: 1px;
    user-select: none;
}
body[data-theme='dark'] .pagination-controls .ellipsis { color: rgba(var(--primary-color-rgb),0.55); }

/* Prev / Next narrower */
.pagination-controls .page-btn.prev,
.pagination-controls .page-btn.next,
#pagination-controls .page-btn.prev,
#pagination-controls .page-btn.next { min-width: 38px; padding-inline: .55rem; }

/* Compact when many pages wrap */
@media (max-width: 520px) {
  .pagination-controls .page-btn,
  #pagination-controls .page-btn { 
      min-width: 36px; 
      min-height: 36px; 
      padding: .5rem .65rem; 
      font-size: .78rem; 
  }
  .pagination-controls { gap: .3rem; }
}

/* Book cover wrapper (no blur) */
.book-image-wrapper {
    position: relative;
    display: inline-block; /* shrink to image size */
    border-radius: 14px;
    overflow: hidden;
    /* spacing between cover and title */
    margin-bottom: 0.8em;
}

.book-image-wrapper img.book-image {
    position: relative;
    z-index: 1;
    display: block; /* sizing comes from global .book-card img styles */
}

/* Extra book filters */
.book-filters { 
    font-size: .85rem; 
}

.book-filters select, 
.book-filters button { 
    font-family: inherit; 
}

.book-filters select.filter-select {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    color: var(--text-dark);
    border: 1px solid rgba(0,0,0,0.18);
    padding: .5em .75em;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, background .3s;
}

[data-theme='dark'] .book-filters select.filter-select {
    background: rgba(18, 18, 18, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    color: var(--text-light);
    border: 1px solid rgba(255,255,255,0.25);
}

.book-filters select.filter-select:focus { 
    outline: none; 
    border-color: var(--primary-color); 
    box-shadow: 0 0 0 2px rgba(211,47,47,0.25); 
}

.book-filters button#clear-filters { 
    line-height: 1; 
}

/* Custom search bar style */
.search-bar-custom {
    width: 340px;
    padding: 0.5em 1em;
    border-radius: 7px;
    border: 1.5px solid #ccc;
    font-size: 1em;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    color: var(--text-dark);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    margin-left: .25em;
}

body[data-theme="dark"] .search-bar-custom {
    background: rgba(18, 18, 18, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border-color: rgba(255,255,255,0.25);
    color: var(--text-light);
}

.search-bar-custom:focus {
    border-color: var(--primary-color);
    box-shadow: 0 2px 12px rgba(211,47,47,0.10);
}

.books-toolbar { 
    row-gap: .65em; 
}

/* Office slider styles */
.office-slider {
    width: 100%;
    max-width: 900px;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: visible; /* outer can show overlay */
    box-shadow: 0 6px 18px rgba(0,0,0,0.15);
    background: #000;
    margin: 0.75rem auto 1rem;
    margin-top: 2rem;
    position: relative;
}

/* Inner clip wrapper to preserve rounded corners on images */
.office-slider-track {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden; /* clip slides to rounded radius */
    border-radius: inherit;
}

.office-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 600ms ease;
}

.office-slide.active { 
    opacity: 1; 
}

.office-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: inherit; /* match container corners */
}

.office-slider:hover::after {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.08);
    pointer-events: none;
    border-radius: inherit; /* ensure outline follows rounded corners */
}

.office-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.35);
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    z-index: 3;
}

.office-nav:hover { 
    background: rgba(0,0,0,0.55); 
    transform: translateY(-50%) scale(1.05); 
}

.office-nav.prev { 
    right: 8px; 
}

.office-nav.next { 
    left: 8px; 
}

.office-dots {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 8px;
    display: flex;
    gap: 8px;
    z-index: 3;
}

.office-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    border: 1px solid rgba(0,0,0,0.25);
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease;
}

.office-dot.active { 
    background: #fff; 
    transform: scale(1.15); 
}



/* Responsive adjustments */
@media (max-width: 768px) {
    main {
        padding: 1.5em 1em;
    }

    h1 {
        font-size: 2em;
    }

    .content-card {
        padding: 1.5em;
    }

    .category-button-group {
        flex-direction: column;
        align-items: center;
    }

    .category-button {
        width: 80%;
        /* Make buttons wider on small screens */
    }

    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); /* Adjust for smaller screens */
        gap: 1em;
    }

    .book-card img {
        max-width: 120px;
        height: 180px;
    }

    .book-card h3 {
        font-size: 1.1em;
    }

    .book-card p {
        font-size: 0.8em;
    }

    footer {
        padding: 2em 1em;
        grid-template-columns: 1fr; /* Stack columns on small screens */
        text-align: center;
    }

    /* Responsive adjustment for Categories heading on smaller screens */
    #categories h2 {
        font-size: 2em; /* Adjust font size for smaller screens */
        margin-bottom: 0.5em;
    }

    /* Responsive adjustments for modal */
    .modal-content {
        padding: 1.5em;
        width: 95%;
    }
    
    .modal-title {
        font-size: 1.5em;
    }
    
    .modal-author {
        font-size: 1em;
    }
    
    .modal-description {
        font-size: 0.9em;
    }
    
    .modal-image {
        max-width: 270px; /* Adjusted for smaller screens (180px * 1.5 = 270px) */
    }

    .search-bar-custom { 
        width: 100%; 
        order: 2; 
    }
    
    .books-toolbar { 
        justify-content: stretch; 
    }
    
    #book-extra-filters { 
        order: 1; 
        width: 100%; 
    }
}

@media (max-width: 800px) {
    .search-bar-custom { 
        width: 100%; 
        order: 2; 
    }
    
    .books-toolbar { 
        justify-content: stretch; 
    }
    
    #book-extra-filters { 
        order: 1; 
        width: 100%; 
    }
}

@media (max-width: 600px) {
    .modal-content {
        padding: 1.5em;
        width: 95%;
    }
    
    .modal-title {
        font-size: 1.5em;
    }
    
    .modal-author {
        font-size: 1em;
    }
    
    .modal-description {
        font-size: 0.9em;
    }
    
    .modal-image {
        max-width: 270px; /* Adjusted for smaller screens (180px * 1.5 = 270px) */
    }
}

/* Visitor Counter Styles */
.visitor-stats {
    padding: 1.5em;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(0,0,0,0.10);
    border-radius: 12px;
    color: var(--text-dark);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

[data-theme="dark"] .visitor-stats {
    background: rgba(18, 18, 18, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-light);
}

.visitor-stats h4 {
    font-size: 1.2em;
    margin-bottom: 1.2em;
    color: var(--primary-color);
    border-bottom: 2px solid rgba(0,0,0,0.18);
    padding-bottom: 0.5em;
    text-align: right;
}

[data-theme="dark"] .visitor-stats h4 {
    border-bottom-color: rgba(255,255,255,0.16);
}

.visitor-counts {
    display: flex;
    flex-direction: column;
    gap: 1em;
}

.visitor-count-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.95em;
}

.count-label {
    color: rgba(0,0,0,0.65);
}

.count-value {
    font-weight: bold;
    color: inherit;
}

[data-theme="dark"] .count-label {
    color: rgba(255,255,255,0.70);
}

/* Country Statistics Styles */
.country-stats {
    padding: 1.5em;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(0,0,0,0.10);
    border-radius: 12px;
    color: var(--text-dark);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

[data-theme="dark"] .country-stats {
    background: rgba(18, 18, 18, 0.55);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-light);
}

.country-stats h4 {
    font-size: 1.2em;
    margin-bottom: 1.2em;
    color: var(--primary-color);
    border-bottom: 2px solid rgba(0,0,0,0.18);
    padding-bottom: 0.5em;
    text-align: right;
}

[data-theme="dark"] .country-stats h4 {
    border-bottom-color: rgba(255,255,255,0.16);
}

.country-list {
    display: flex;
    flex-direction: column;
    gap: 1em;
}

.country-item {
    display: flex;
    align-items: center;
    gap: 1em;
}

.country-flag {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.country-details {
    flex-grow: 1;
}

.country-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3em;
}

.country-name {
    font-weight: bold;
    color: inherit;
}

.country-stats-numbers {
    font-size: 0.9em;
    color: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    gap: 0.5em;
}

[data-theme="dark"] .country-stats-numbers {
    color: rgba(255,255,255,0.70);
}

.visitor-percentage {
    margin-left: 0.5em;
    font-size: 0.8em;
    opacity: 0.9;
}

.progress-bar-container {
    width: 100%;
    background-color: rgba(0,0,0,0.15);
    border-radius: 10px;
    height: 6px;
    overflow: hidden;
    margin-top: 0.5em;
}

[data-theme="dark"] .progress-bar-container {
    background-color: rgba(255,255,255,0.12);
}

.progress-bar {
    height: 100%;
    background: #6c757d;
    border-radius: 10px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Responsive adjustments for visitor counter */
@media (max-width: 768px) {
    .visitor-stats,
    .country-stats {
        padding: 1em;
    }
    
    .visitor-count-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3em;
    }
    
    .country-item {
        padding: 0.5em;
    }
    
    .country-flag {
        width: 28px;
        height: 21px;
    }
    
    .country-name {
        font-size: 0.85em;
    }
    
    .visitor-count {
        font-size: 0.9em;
    }
    
    .visitor-percentage {
        font-size: 0.75em;
    }
}

/* Maintenance banner below header */
.maintenance-banner {
    --warning-color: #ffb300; /* amber */
    --banner-bg: rgba(255,179,0,0.18);
    margin: 0.45rem auto 0.65rem; /* space below header */
    padding: .32rem .75rem .4rem;
    /* Expanded width to align visually with .office-slider (max-width:900px) */
    max-width: 900px; /* previously 420px */
    width: calc(100% - 2rem); /* keeps side breathing space on wide screens */
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .78rem;
    line-height: 1.35;
    background: var(--banner-bg);
    backdrop-filter: blur(10px) saturate(160%);
    -webkit-backdrop-filter: blur(10px) saturate(160%);
    border: 1px solid rgba(255,179,0,0.45);
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    letter-spacing: .3px;
    box-shadow: 0 4px 14px -6px rgba(0,0,0,0.55), 0 2px 5px rgba(0,0,0,0.35);
    position: relative;
    direction: rtl;
    overflow: hidden;
}
.maintenance-banner::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,179,0,0.35) 0%, rgba(255,179,0,0.05) 70%);
    pointer-events: none;
}
.maintenance-banner::after {
    content:"";
    position:absolute;
    right:8px; top:50%; transform:translateY(-50%);
    width:6px; height:60%;
    background:linear-gradient(to bottom,#ffd54f,#ffb300);
    border-radius:3px;
    opacity:.85;
}
body[data-theme='light'] .maintenance-banner {
    --banner-bg: rgba(255,179,0,0.20);
    color: #302400;
    border-color: rgba(255,179,0,0.45);
}
body[data-theme='dark'] .maintenance-banner { 
    --banner-bg: rgba(255,179,0,0.12); 
}
.maintenance-banner .maint-icon { 
    flex-shrink:0;
    color: var(--warning-color);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.45));
}
@media (max-width:640px){
    /* Keep full available width on small screens (minus global side spacing) */
    .maintenance-banner { font-size:.7rem; padding:.28rem .6rem .34rem; gap:.4rem; margin:0.4rem auto 0.55rem; }
}
