/* 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);
    color: var(--text-dark);
}

body[data-theme="dark"] {
    background-color: var(--background-dark);
    color: var(--text-light);
}

/* Dark theme header styling */
body[data-theme="dark"] header {
    background: linear-gradient(to right, #1a1a1a, #2d2d2d);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Dark theme button styling - white outlines */
/* Dark theme category buttons styled like header nav buttons */
body[data-theme="dark"] .category-button {
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.45);
    color: #fff;
    font-weight: 700;
    border-radius: 10px;
    backdrop-filter: saturate(120%) blur(4px);
    -webkit-backdrop-filter: saturate(120%) blur(4px);
    box-shadow: 0 4px 10px -2px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.25);
    transition: background-color .2s ease, color .2s ease, box-shadow .2s ease, transform .15s ease, border-color .2s ease;
}
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 */
}

/* Header Styling */
header {
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 0.55em 1.5em; /* reduced height */
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo {
    font-size: 1.8em;
    font-weight: bold;
    flex-shrink: 0; /* Prevent logo from shrinking */
    display: flex;
    align-items: center;
    gap: 0.5em;
    direction: rtl; /* Ensure proper RTL layout */
}

.header-logo {
    height: 56px; /* enlarged */
    width: auto;
    object-fit: contain;
}

header nav ul {
    list-style: none;
    display: flex;
    gap: 1.5em;
    flex-wrap: wrap;
    justify-content: center;
    margin-inline-start: auto;
    /* Push nav to the left/right in RTL/LTR */
    margin-inline-end: 1em;
    /* Space between nav and toggle */
}

/* Mobile menu toggle (hamburger) */
.mobile-menu-toggle {
    display: none;
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.5);
    padding: .6rem .65rem;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    gap: 4px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: background .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.mobile-menu-toggle .bar {
    width: 24px; height: 3px; border-radius: 2px; background:#fff; display:block; transition: transform .4s cubic-bezier(.68,-0.55,.27,1.55), opacity .25s ease, width .25s ease;
}
.mobile-menu-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* Transform into X when open */
body.nav-open .mobile-menu-toggle .bar:nth-child(1){ transform: translateY(6px) rotate(45deg); }
body.nav-open .mobile-menu-toggle .bar:nth-child(2){ opacity:0; width:12px; }
body.nav-open .mobile-menu-toggle .bar:nth-child(3){ transform: translateY(-6px) rotate(-45deg); }
body.nav-open .mobile-menu-toggle { background: #fff; border-color:#fff; }
body.nav-open .mobile-menu-toggle .bar { background: var(--primary-color); }

/* Mobile nav panel */
@media (max-width: 860px){
    /* Reposition hamburger to fixed top-right (in RTL: inline-end) */
    .mobile-menu-toggle { 
        display:flex; 
        position:absolute; 
        top:.5rem; 
        inset-inline-end:.85rem; /* right in LTR, left in RTL automatically */
        margin: 0.7rem 0 0 0; 
        order:initial; 
        z-index:1300; 
    }
    header { align-items: center; position:sticky; } /* ensure positioning context */
    /* Add padding on logo row so button doesn't overlap text */
    header .logo { width:100%; justify-content:center; padding-inline-end:3.1rem; }
    header nav { width:100%; order:3; }
    header nav ul#primary-nav { 
        flex-direction: column; 
        align-items: stretch; 
        gap:.75rem; 
        margin:0; 
        padding:1rem 1.1rem 1.4rem; 
        background: rgba(0,0,0,0.72); 
        backdrop-filter: blur(14px) saturate(160%); 
        -webkit-backdrop-filter: blur(14px) saturate(160%);
        border:1px solid rgba(255,255,255,0.18);
        border-radius:18px; 
        position:absolute; 
        inset-inline:1rem; 
        top: calc(100% + .65rem); 
        z-index:1200; 
        box-shadow:0 18px 38px -12px rgba(0,0,0,0.55), 0 4px 14px rgba(0,0,0,0.35);
        transform:translateY(-8px) scale(.97); 
        opacity:0; 
        pointer-events:none; 
        transition: opacity .35s ease, transform .4s cubic-bezier(.68,-0.55,.27,1.55);
    }
    header nav ul#primary-nav.open { 
        opacity:1; 
        transform:translateY(0) scale(1); 
        pointer-events:auto; 
    }
    header nav ul#primary-nav li a.nav-link { 
        display:block; 
        text-align:center; 
        padding:.85rem 1rem; 
        font-size:1.05rem; 
        font-weight:700; 
        border-radius:12px; 
        border:1px solid rgba(255,255,255,0.2); 
        background:rgba(255,255,255,0.08); 
    }
    header nav ul#primary-nav li a.nav-link.active { background:#fff; color:var(--primary-color); }
    header nav ul#primary-nav li a.nav-link:hover { background:rgba(255,255,255,0.22); }
    body.nav-open { overflow:hidden; } /* prevent body scroll when menu open */
}

header nav ul li a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.3s;
}

header nav ul li a:hover {
    opacity: 0.8;
}

.theme-toggle {
    background: none;
    border: 2px solid white;
    color: white;
    padding: 0.4em 0.8em;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* 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-color: var(--card-bg-light);
    color: var(--text-dark);
    transition: background-color 0.3s ease, color 0.3s ease;
    text-align: center;
}

body[data-theme="dark"] .content-card {
    background-color: var(--card-bg-dark);
    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-color: var(--card-bg-light);
    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-color: var(--card-bg-dark);
    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-color: var(--card-bg-light);
    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-color: var(--card-bg-dark);
    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.15);
    background: var(--pg-bg-light);
    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: var(--pg-bg-dark);
    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: var(--card-bg-light);
    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: var(--card-bg-dark);
    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: white;
    color: black;
    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;
}

.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) {
    header {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.75em 1em; /* slightly reduced on mobile */
    }

    .logo {
        font-size: 1.4em;
        direction: rtl;
    }

    .header-logo {
        height: 44px; /* bigger logo on mobile */
    }

    header nav ul {
        width: 100%;
        justify-content: flex-start;
        margin-top: 1em;
        margin-inline-end: 0;
    }

    .theme-toggle {
        margin-top: 1em;
        width: 100%;
    }

    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-color: #2a2a2a;
    border-radius: 12px;
    color: #eee;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

[data-theme="dark"] .visitor-stats {
    background-color: #1a1a1a;
    color: #fff;
}

[data-theme="light"] .visitor-stats {
    background-color: #2a2a2a;
    color: #eee;
}

.visitor-stats h4 {
    font-size: 1.2em;
    margin-bottom: 1.2em;
    color: #fff;
    border-bottom: 2px solid #444;
    padding-bottom: 0.5em;
    text-align: right;
}

.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: #bbb;
}

.count-value {
    font-weight: bold;
    color: #fff;
}

/* Country Statistics Styles */
.country-stats {
    padding: 1.5em;
    background-color: #2a2a2a;
    border-radius: 12px;
    color: #eee;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

[data-theme="dark"] .country-stats {
    background-color: #1a1a1a;
    color: #fff;
}

.country-stats h4 {
    font-size: 1.2em;
    margin-bottom: 1.2em;
    color: #fff;
    border-bottom: 2px solid #444;
    padding-bottom: 0.5em;
    text-align: right;
}

.country-list {
    display: flex;
    flex-direction: column;
    gap: 1em;
}

.country-list::-webkit-scrollbar {
    width: 6px;
}

.country-list::-webkit-scrollbar-track {
    background: transparent;
}

.country-list::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

.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: #fff;
}

.country-stats-numbers {
    font-size: 0.9em;
    color: #bbb;
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.visitor-percentage {
    margin-left: 0.5em;
    font-size: 0.8em;
    opacity: 0.9;
}

.progress-bar-container {
    width: 100%;
    background-color: #333;
    border-radius: 10px;
    height: 6px;
    overflow: hidden;
    margin-top: 0.5em;
}

.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; }
}