/* ==========================================================================
   SLiMS Multi-Tenant Modern Responsive OPAC Design System
   Bootstrap 4.2 + Modern Utility Shim (Desktop, Tablet, Mobile)
   ========================================================================== */

:root {
    --primary-color: #2563eb;
    --secondary-color: #0f172a;
    --accent-color: #f59e0b;
    --surface: #ffffff;
    --surface-muted: #f1f5f9;
    --canvas: #f8fafc;
    --ink: #0f172a;
    --ink-soft: #475569;
    --ink-muted: #64748b;
    --border-hairline: rgba(15, 23, 42, 0.08);
    --shadow-xs: 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.16);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-pill: 999px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Base & Typography ---------- */
html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--canvas) !important;
    color: var(--ink);
    font-family: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif !important;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ---------- Bootstrap 5 -> Bootstrap 4.2 Compatibility Utilities ---------- */
.ms-auto { margin-left: auto !important; }
.me-auto { margin-right: auto !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.me-3 { margin-right: 1rem !important; }
@media (min-width: 992px) { .ms-lg-2 { margin-left: 0.5rem !important; } }

.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }

.fw-medium { font-weight: 500 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }
.fs-5 { font-size: 1.125rem !important; }
.fs-6 { font-size: 0.95rem !important; }
.d-grid { display: grid !important; }
.text-start { text-align: left !important; }
.border-start { border-left: 3px solid #cbd5e1 !important; }
.opacity-25 { opacity: 0.25 !important; }
.opacity-50 { opacity: 0.5 !important; }
.rounded-pill { border-radius: var(--radius-pill) !important; }
.rounded-3 { border-radius: var(--radius-md) !important; }
.text-decoration-none { text-decoration: none !important; }

.row.g-3 { margin-left: -0.6rem; margin-right: -0.6rem; }
.row.g-3 > [class*="col"] { padding-left: 0.6rem; padding-right: 0.6rem; margin-bottom: 1.2rem; }
.row.g-4 { margin-left: -0.75rem; margin-right: -0.75rem; }
.row.g-4 > [class*="col"] { padding-left: 0.75rem; padding-right: 0.75rem; margin-bottom: 1.5rem; }

.form-select {
    display: inline-block;
    width: 100%;
    padding: 0.42rem 2rem 0.42rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--ink);
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23475569' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px 12px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
    outline: 0;
}
.form-select-sm { padding: 0.34rem 1.85rem 0.34rem 0.65rem; font-size: 0.85rem; }

.btn-close {
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23475569'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/0.85rem auto no-repeat;
    opacity: 0.65;
    cursor: pointer;
}
.btn-close:hover { opacity: 1; }

.badge.bg-primary { background-color: #2563eb !important; color: #fff !important; }
.badge.bg-success { background-color: #059669 !important; color: #fff !important; }
.badge.bg-warning { background-color: #f59e0b !important; color: #0f172a !important; }
.badge.bg-secondary { background-color: #475569 !important; color: #fff !important; }
.badge.bg-light { background-color: #f1f5f9 !important; color: #334155 !important; }
.badge.bg-glass {
    background: rgba(255, 255, 255, 0.16) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(8px);
}

/* ---------- Modern Glassmorphic Sticky Navbar (100% Unified Across All OPAC Pages) ---------- */
.navbar-custom-library {
    background: linear-gradient(90deg, var(--primary-color), color-mix(in srgb, var(--primary-color) 78%, var(--secondary-color))) !important;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.14) !important;
    padding: 0.6rem 0 !important;
    min-height: 62px !important;
    z-index: 1030;
}

.navbar-custom-library .navbar-brand {
    font-weight: 700 !important;
    font-size: 1rem !important;
    line-height: 1.22 !important;
    letter-spacing: -0.02em !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    max-width: calc(100% - 62px);
    min-width: 0;
    padding-top: 0.15rem !important;
    padding-bottom: 0.15rem !important;
    margin-right: 0.75rem !important;
    white-space: normal !important;
}

.navbar-custom-library .brand-logo {
    max-height: 36px !important;
    width: auto !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.94) !important;
    padding: 3px 5px !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
    flex-shrink: 0 !important;
}

.navbar-custom-library .brand-text {
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal !important;
    line-height: 1.22 !important;
    max-width: 340px !important;
    word-break: break-word;
}

@media (max-width: 1199.98px) and (min-width: 992px) {
    .navbar-custom-library .navbar-brand { font-size: 0.92rem !important; }
    .navbar-custom-library .brand-text { max-width: 240px !important; }
    .navbar-custom-library .nav-link { font-size: 0.85rem !important; padding: 0.4rem 0.55rem !important; }
}

@media (max-width: 991.98px) {
    .navbar-custom-library .navbar-brand { font-size: 0.94rem !important; }
    .navbar-custom-library .brand-text { max-width: none !important; -webkit-line-clamp: 3; }
}

.navbar-custom-library .nav-link {
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    color: rgba(255, 255, 255, 0.9) !important;
    padding: 0.44rem 0.72rem !important;
    border-radius: 10px !important;
    white-space: nowrap !important;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.navbar-custom-library .nav-link:hover,
.navbar-custom-library .nav-item.active .nav-link {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.18);
    font-weight: 600;
}

.navbar-custom-library .lib-select-btn {
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.32);
    color: #fff !important;
    border-radius: var(--radius-pill) !important;
    padding: 0.42rem 1rem !important;
}
.navbar-custom-library .lib-select-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

.navbar-custom-library .dropdown-menu {
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.45rem;
    min-width: 270px;
    max-height: 360px;
    overflow-y: auto;
}

.navbar-custom-library .dropdown-item {
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--ink);
}
.navbar-custom-library .dropdown-item:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

/* ---------- Modern Hero Header ---------- */
.landing-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%) !important;
    padding: 3.25rem 0 3.75rem !important;
    margin-bottom: 2rem !important;
    border-radius: 0 0 28px 28px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.16);
}

.landing-header::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.16) 0%, transparent 42%),
        radial-gradient(circle at 88% 82%, rgba(56, 189, 248, 0.18) 0%, transparent 45%);
    pointer-events: none;
}

.landing-header .container { position: relative; z-index: 2; }

.header-brand .header-logo {
    max-height: 62px;
    width: auto;
    background: rgba(255, 255, 255, 0.96);
    padding: 6px;
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.header-title {
    font-size: clamp(1.45rem, 3.2vw, 2.25rem) !important;
    font-weight: 800 !important;
    letter-spacing: -0.025em;
    line-height: 1.22;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.hero-subtitle {
    color: rgba(255, 255, 255, 0.85);
    font-size: clamp(0.92rem, 1.4vw, 1.08rem);
    max-width: 680px;
    margin: 0.45rem auto 0;
}

/* ---------- Modern Responsive Pill Search Bar ---------- */
.integrated-search-box {
    display: flex;
    align-items: center;
    background: #ffffff;
    border-radius: var(--radius-pill);
    padding: 6px 6px 6px 18px;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.22);
    border: 2px solid rgba(255, 255, 255, 0.4);
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.integrated-search-box:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.28);
}

.search-input-group {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
}

.search-input-group .form-control {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    font-size: 1rem;
    padding: 0.55rem 0.75rem;
    color: var(--ink);
    height: auto;
}

.btn-search {
    background: var(--primary-color) !important;
    color: #fff !important;
    border: none !important;
    border-radius: var(--radius-pill) !important;
    padding: 0.65rem 1.75rem !important;
    font-weight: 700 !important;
    font-size: 0.95rem;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
    transition: filter 0.2s ease, transform 0.2s ease;
}
.btn-search:hover { filter: brightness(0.92); transform: translateY(-1px); }

.hero-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1rem;
}

.btn-adv-search {
    background: rgba(255, 255, 255, 0.16) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.35) !important;
    backdrop-filter: blur(8px);
    border-radius: var(--radius-pill) !important;
    padding: 0.42rem 1.1rem !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: background-color 0.2s ease;
}
.btn-adv-search:hover { background: rgba(255, 255, 255, 0.28) !important; color: #fff !important; }

/* ---------- Modern Section Headers ---------- */
.section-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1.35rem;
}

.section-title {
    font-size: 1.25rem !important;
    font-weight: 800 !important;
    color: var(--ink) !important;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding-left: 0 !important;
    margin: 0;
}
.section-title::before { display: none !important; }

/* ---------- Responsive DDC Topic Grid ---------- */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.topic-grid li a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px 10px;
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-hairline);
    box-shadow: var(--shadow-xs);
    color: var(--ink-soft);
    text-decoration: none;
    height: 100%;
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.2s ease, color 0.2s ease;
}

.topic-grid li a:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: rgba(37, 99, 235, 0.35);
    color: var(--primary-color);
}

.topic-grid li a img {
    width: 38px;
    height: 38px;
    object-fit: contain;
    margin-bottom: 8px;
    transition: transform 0.25s var(--ease);
}
.topic-grid li a:hover img { transform: scale(1.1); }
.topic-grid li a span { font-size: 0.8rem; font-weight: 600; line-height: 1.25; }

/* ---------- Modern School Directory Cards & Filter Toolbar ---------- */
.school-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    background: var(--surface);
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-hairline);
    box-shadow: var(--shadow-xs);
}

.school-filter-bar .btn-group .btn {
    border-radius: 8px !important;
    margin-right: 4px;
    font-weight: 600;
    font-size: 0.82rem;
    padding: 0.36rem 0.78rem;
}

.unit-lib-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-hairline);
    box-shadow: var(--shadow-xs);
    position: relative;
    overflow: hidden;
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.2s ease;
}
.unit-lib-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--card-accent, var(--primary-color));
}
.unit-lib-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: rgba(37, 99, 235, 0.25);
}

.unit-lib-icon {
    width: 46px;
    height: 46px;
    min-width: 46px;
    border-radius: 12px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.14);
}

/* ---------- Modern Book & Content Cards ---------- */
.card-modern {
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-hairline);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.2s ease;
}
.card-modern:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: rgba(37, 99, 235, 0.22);
}

.book-cover {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f6 100%);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0.75rem;
}

.book-cover img {
    height: 170px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    border-radius: 6px;
    transition: transform 0.3s var(--ease);
}
.card-modern:hover .book-cover img { transform: scale(1.04); }

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.55em;
    line-height: 1.32;
}

.library-badge {
    display: inline-block;
    padding: 0.24rem 0.65rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #1d4ed8;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: var(--radius-pill);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Modern Stat & Rank Cards ---------- */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-hairline);
    border-left: 4px solid var(--primary-color);
    padding: 1.25rem 1.35rem;
    box-shadow: var(--shadow-xs);
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #eff6ff;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.rank-number {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

/* ---------- Modern Filter Sidebar & Mobile Drawer ---------- */
.filter-sidebar {
    background: var(--surface) !important;
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--border-hairline) !important;
    box-shadow: var(--shadow-xs) !important;
    padding: 1.1rem !important;
    position: sticky;
    top: 84px;
}

.mobile-filter-toggle {
    display: none;
    width: 100%;
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* ---------- Modern Footer ---------- */
.landing-footer {
    background: var(--secondary-color);
    color: rgba(255, 255, 255, 0.78);
    padding: 2rem 0;
    margin-top: 3.5rem;
    font-size: 0.9rem;
}
.landing-footer a { color: rgba(255, 255, 255, 0.9); text-decoration: none; }
.landing-footer a:hover { color: #fff; text-decoration: underline; }

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (max-width: 991.98px) {
    .topic-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
    .filter-sidebar { position: static; margin-bottom: 1rem; }
    .mobile-filter-toggle { display: flex; align-items: center; justify-content: space-between; }
    .mobile-filter-panel { display: none; }
    .mobile-filter-panel.is-open { display: block; }
    .navbar-custom-library .navbar-collapse {
        background: rgba(15, 23, 42, 0.22);
        border-radius: var(--radius-md);
        padding: 0.75rem;
        margin-top: 0.65rem;
        backdrop-filter: blur(10px);
    }
    .navbar-custom-library .navbar-nav { gap: 4px; }
    .navbar-custom-library .lib-select-btn { margin-top: 0.35rem; justify-content: center; }
}

@media (max-width: 767.98px) {
    .landing-header { padding: 2.25rem 0 2.5rem !important; border-radius: 0 0 20px 20px; }
    .school-filter-bar { width: 100%; }
    .school-filter-bar > select,
    .school-filter-bar > input { width: 100% !important; min-width: 0 !important; flex: 1 1 100%; }
    .book-cover img { height: 145px; }
}

@media (max-width: 575.98px) {
    .navbar-custom-library .navbar-brand { font-size: 0.88rem !important; }
    .header-brand .header-logo { max-height: 46px; }
    .integrated-search-box {
        flex-direction: column;
        border-radius: var(--radius-md);
        padding: 8px;
        gap: 8px;
    }
    .search-input-group { width: 100%; padding: 0 4px; }
    .btn-search { width: 100%; padding: 0.65rem 1rem !important; }

    /* Horizontal swipeable topic strip on phones */
    .topic-grid {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        gap: 10px;
        padding-bottom: 6px;
    }
    .topic-grid::-webkit-scrollbar { height: 4px; }
    .topic-grid::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
    .topic-grid li { flex: 0 0 118px; scroll-snap-align: start; }
    .topic-grid li a { padding: 12px 8px; }
    .topic-grid li a img { width: 32px; height: 32px; }
}
