/* ========================================
   Centralized OPAC MD3 Style Token & Rules
   ======================================== */

/* --- From layout.php --- */
/* ========================================
           MD3 Global Design Tokens
           ======================================== */
:root {
    --md-primary: #1c64f2;
    --md-primary-container: #dbeafe;
    --md-on-primary: #ffffff;
    --md-on-primary-container: #1e40af;
    --md-secondary: #60a5fa;
    --md-surface: #f8fafc;
    --md-surface-container: #eff6ff;
    --md-surface-container-low: #f1f5f9;
    --md-surface-variant: #e2e8f0;
    --md-on-surface: #0f172a;
    --md-on-surface-variant: #475569;
    --md-outline: #94a3b8;
    --md-outline-variant: #cbd5e1;
    --md-shadow-ambient: 0px 4px 20px rgba(0, 0, 0, 0.05);
    --md-radius-lg: 16px;
    --md-radius-md: 12px;
    --md-radius-sm: 8px;

    /* Legacy compat aliases */
    --primary-green: var(--md-primary);
    --brand-500: var(--md-primary);
    --brand-100: var(--md-on-primary-container);
    --slate-50: var(--md-surface);
    --slate-100: var(--md-surface-variant);
    --slate-500: var(--md-outline);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--md-surface);
    color: var(--md-on-surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
           Top App Bar (Header)
           ======================================== */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    background: rgba(249, 249, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 10px 0;
    border-bottom: 1px solid var(--md-surface-variant);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    max-width: 1400px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    flex: 1;
    min-width: 0;
    margin-right: 12px;
}

.logo-icon-wrap {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-icon-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-icon-wrap i {
    color: var(--md-on-primary-container);
    width: 20px;
    height: 20px;
}

.logo-text {
    flex: 1;
    min-width: 0;
}

.logo-text h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: var(--md-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Desktop Navigation */
.nav-links {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 4px;
}

.nav-links a {
    color: var(--md-on-surface-variant);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: var(--md-radius-sm);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-links a i {
    width: 16px;
    height: 16px;
}

.nav-links a:hover {
    background: var(--md-surface-container);
    color: var(--md-primary);
}

.nav-links a.active {
    background: var(--md-primary-container);
    color: var(--md-on-primary-container);
}

/* ========================================
           Bottom Navigation Bar
           ======================================== */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    background: rgba(255, 255, 255, 0.96);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.08), 0 -1px 0 rgba(0, 0, 0, 0.04);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: none;
    align-items: center;
    justify-content: space-around;
    padding-top: 8px;
    padding-left: 6px;
    padding-right: 6px;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 16px));
    min-height: 68px;
    box-sizing: border-box;
}

.mobile-nav-item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #64748b;
    padding: 2px 0;
    border-radius: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.mobile-nav-item .nav-icon-indicator {
    width: 54px;
    height: 32px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    margin-bottom: 3px;
}

.mobile-nav-item i,
.mobile-nav-item svg {
    width: 22px;
    height: 22px;
    color: #64748b;
    stroke: currentColor;
    stroke-width: 1.8;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-nav-item span {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: #64748b;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.mobile-nav-item:hover {
    color: var(--md-on-surface, #1e293b);
}

.mobile-nav-item:hover .nav-icon-indicator {
    background: rgba(0, 0, 0, 0.04);
}

/* Active State */
.mobile-nav-item.active {
    background: transparent;
    transform: none;
}

.mobile-nav-item.active .nav-icon-indicator {
    background: #dbeafe;
}

.mobile-nav-item.active i,
.mobile-nav-item.active svg {
    color: #1d4ed8;
    stroke: #1d4ed8;
    stroke-width: 2.2;
}

.mobile-nav-item.active span {
    color: #1e3a8a;
    font-weight: 700;
}

.mobile-nav-item:active .nav-icon-indicator {
    transform: scale(0.92);
}

/* ========================================
           Legacy Compatibility Classes
           ======================================== */
.hero-section {
    background: linear-gradient(135deg, #e6f4ee 0%, #e6f4ee 100%);
    color: white;
    padding: 80px 0;
}

.search-box {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.catalog-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.catalog-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.browse-letter {
    display: inline-block;
    padding: 8px 12px;
    margin: 2px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    text-decoration: none;
    color: #495057;
    transition: all 0.3s ease;
}

.browse-letter:hover,
.browse-letter.active {
    background: var(--md-primary);
    color: white;
    text-decoration: none;
}

.badge-custom {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

/* Brand buttons */
.btn-brand {
    background: var(--md-primary);
    color: var(--md-on-primary);
    border: 1px solid transparent;
}

.btn-brand:hover {
    background: white;
    color: var(--md-primary) !important;
    border-color: var(--md-primary);
}

.bg-brand {
    background-color: var(--md-primary) !important;
}

.text-brand {
    color: var(--md-primary) !important;
}

/* Rounded utilities */
.rounded-xl {
    border-radius: var(--md-radius-md) !important;
}

.rounded-2xl {
    border-radius: var(--md-radius-lg) !important;
}

.shadow-soft {
    box-shadow: var(--md-shadow-ambient) !important;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========================================
           Footer
           ======================================== */
.main-footer {
    background: #1c64f2;
    color: rgba(255, 255, 255, 0.9);
    padding: 48px 0 20px;
    margin-top: 40px;
}

.footer-section h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    position: relative;
    padding-bottom: 10px;
}

.footer-section h4::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 40px;
    height: 2px;
    background: #f7b924;
}

.footer-section p {
    line-height: 1.6;
    opacity: 0.85;
    margin-bottom: 12px;
    font-size: 14px;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li {
    margin-bottom: 8px;
}

.footer-section ul li a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
}

.footer-section ul li a:hover {
    opacity: 1;
    color: var(--md-on-primary-container);
    padding-left: 4px;
}

.footer-contact p {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.footer-contact i {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    color: var(--md-on-primary-container);
    flex-shrink: 0;
}

.footer-bottom {
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    margin-top: 24px;
    opacity: 0.6;
    font-size: 13px;
}

/* ========================================
           Responsive: Mobile
           ======================================== */
@media (max-width: 768px) {
    body {
        padding-bottom: 0 !important;
    }

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

    .logo-icon-wrap {
        width: 32px;
        height: 32px;
    }

    .logo-text h1 {
        font-size: 15px;
    }

    /* Hide Desktop Nav */
    .desktop-nav {
        display: none !important;
    }

    /* Show Mobile Bottom Nav */
    .mobile-bottom-nav {
        display: flex !important;
    }

    .hero-section {
        padding: 40px 0;
    }

    .main-footer {
        margin-bottom: 0 !important;
        padding: 32px 0 calc(32px + 80px) !important;
        margin-top: 0;
    }
}

@media (min-width: 769px) {
    .main-header {
        padding: 8px 0;
    }

    .header-inner {
        padding: 0 24px;
    }

    .mobile-bottom-nav {
        display: none !important;
    }
}

/* ========================================
           Mobile Scroll Snap Utility
           ======================================== */
@media (max-width: 768px) {
    .mobile-scroll-snap {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none !important;
        padding: 10px 4px 15px 4px !important;
        gap: 12px !important;
        margin-left: -8px !important;
        margin-right: -8px !important;
    }

    .mobile-scroll-snap::-webkit-scrollbar {
        display: none !important;
    }

    .mobile-scroll-snap>.mobile-snap-item {
        flex: 0 0 78% !important;
        width: 78% !important;
        max-width: 78% !important;
        scroll-snap-align: start !important;
        margin: 0 !important;
        min-width: unset !important;
    }

    .mobile-snap-item .card {
        height: 100% !important;
    }
}

/* --- From member_list.php --- */
/* DataTables Premium Styling Overrides */
div.dataTables_wrapper {
    padding: 10px 0;
}

table.dataTable {
    border-collapse: collapse !important;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--md-outline-variant) !important;
}

table.dataTable thead {
    background-color: var(--md-primary) !important;
    color: white !important;
}

table.dataTable thead th {
    border-bottom: none !important;
    font-weight: 600;
    padding: 14px 12px !important;
}

table.dataTable tbody td {
    padding: 12px !important;
    border-color: var(--md-surface-variant) !important;
}

/* Button design matching MD3 */
.dt-buttons .dt-button {
    background: white !important;
    color: var(--md-primary) !important;
    border: 1.5px solid var(--md-primary) !important;
    border-radius: 8px !important;
    padding: 6px 14px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
}

.dt-buttons .dt-button:hover {
    background: var(--md-primary) !important;
    color: white !important;
}

.dataTables_filter input {
    border: 1.5px solid var(--md-outline-variant) !important;
    border-radius: 8px !important;
    padding: 6px 12px !important;
    outline: none !important;
}

.dataTables_filter input:focus {
    border-color: var(--md-primary) !important;
}

/* --- From recommendations.php --- */
.book-card {
    border: none;
    border-radius: 16px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    background: #ffffff;
    overflow: hidden;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(28, 100, 242, 0.08);
}

.book-cover-wrap {
    position: relative;
    aspect-ratio: 2/3;
    overflow: hidden;
    background: var(--md-surface-container);
}

.book-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.book-card:hover .book-cover {
    transform: scale(1.05);
}

.metric-card {
    background-color: var(--md-surface-container-low) !important;
    border: 1px solid var(--md-outline-variant) !important;
    border-left: 4px solid var(--md-primary) !important;
    border-radius: 12px;
    transition: all 0.25s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--md-shadow-ambient);
}

.cold-start-banner {
    background: linear-gradient(135deg, var(--md-primary) 0%, var(--md-secondary) 100%);
    color: white;
    border: none;
    border-radius: 16px;
}

.custom-search-card {
    border-radius: 16px;
    box-shadow: var(--md-shadow-ambient);
    border: 1px solid var(--md-outline-variant);
}

.custom-input-group {
    border: 1.5px solid var(--md-outline-variant);
    border-radius: 12px;
    overflow: hidden;
    background: white;
    transition: all 0.2s ease;
}

.custom-input-group:focus-within {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 4px rgba(28, 100, 242, 0.12);
}

.rounded-xl {
    border-radius: 12px !important;
}

.rounded-2xl {
    border-radius: 16px !important;
}

.border-1-5 {
    border-width: 1.5px !important;
}

/* --- From visitor_list.php --- */
/* DataTables Premium Styling Overrides */
div.dataTables_wrapper {
    padding: 10px 0;
}

table.dataTable {
    border-collapse: collapse !important;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--md-outline-variant) !important;
}

table.dataTable thead {
    background-color: var(--md-primary) !important;
    color: white !important;
}

table.dataTable thead th {
    border-bottom: none !important;
    font-weight: 600;
    padding: 14px 12px !important;
}

table.dataTable tbody td {
    padding: 12px !important;
    border-color: var(--md-surface-variant) !important;
}

/* Date range button & search button styling */
.btn-theme-action {
    border-radius: 10px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 14px;
    border: 1.5px solid var(--md-primary);
    background: white;
    color: var(--md-primary);
    transition: all 0.2s ease;
}

.btn-theme-action:hover {
    background: var(--md-primary);
    color: white;
}

.btn-theme-search {
    background: var(--md-primary) !important;
    color: white !important;
    border: none !important;
    border-radius: 10px !important;
    padding: 8px 20px !important;
    font-weight: 600;
}

.btn-theme-search:hover {
    background: var(--md-secondary) !important;
}

/* Export Button design matching MD3 */
.btn-export-excel {
    background: #10b981 !important;
    color: white !important;
    border: none !important;
    border-radius: 10px !important;
    padding: 8px 18px !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
}

.btn-export-excel:hover {
    background: #059669 !important;
}

.dataTables_filter input {
    border: 1.5px solid var(--md-outline-variant) !important;
    border-radius: 8px !important;
    padding: 6px 12px !important;
    outline: none !important;
}

.dataTables_filter input:focus {
    border-color: var(--md-primary) !important;
}