/* === ROOT VARIABLES === */
:root {
    /* Colors */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --secondary: #475569;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #0f172a;
    --light: #f8fafc;
    --white: #ffffff;
    --black: #000000;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    --spacing-3xl: 4rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Border Radius */
    --radius-sm: 0.125rem;
    --radius: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;
    --radius-full: 9999px;

    /* Typography */
    --font-family: 'Plus Jakarta Sans', 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* === GLOBAL STYLES === */
body {
    font-family: var(--font-family);
    color: var(--gray-800);
    background-color: var(--light);
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: all 0.3s ease;
}

a:hover {
    color: var(--primary-dark);
}

::selection {
    background-color: var(--primary);
    color: var(--white);
}

/* === NAVBAR === */
.navbar {
    padding-top: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    transition: all 0.3s ease;
}

.navbar.sticky-top {
    background-color: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px);
}

.navbar-brand img {
    height: 65px;
    max-height: 70px;
    width: auto;
    object-fit: contain;
    transition: transform 0.2s ease;
}

.navbar-brand:hover img {
    transform: scale(1.03);
}

.navbar-brand span {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--gray-900);
}

.nav-link {
    font-weight: 500;
    color: var(--gray-600);
    padding: 0.5rem 1rem !important;
    margin: 0 0.25rem;
    border-radius: var(--radius-md);
    position: relative;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary) !important;
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 50%;
    background-color: var(--primary);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::after, .nav-link.active::after {
    width: 80%;
}

.navbar .form-control {
    background-color: var(--gray-100);
    border-color: transparent;
}

.navbar .form-control:focus {
    background-color: var(--white);
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem rgba(37, 99, 235, 0.25);
}

/* === HERO SLIDER / CAROUSEL === */
.hero-carousel {
    position: relative;
}

.hero-carousel .carousel-item {
    height: 600px;
    background-color: var(--dark);
}

.hero-carousel .carousel-item img {
    object-fit: cover;
    height: 100%;
    width: 100%;
    opacity: 0.6;
}

.hero-carousel .carousel-caption {
    bottom: 0;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: var(--spacing-3xl);
    background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0.2));
}

.hero-carousel .carousel-caption h2,
.hero-carousel .carousel-caption h5 {
    color: var(--white);
    font-size: 3rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: var(--spacing-md);
    animation: slideUp 0.8s ease forwards;
}

.hero-carousel .carousel-caption p {
    font-size: 1.2rem;
    max-width: 800px;
    margin: 0 auto var(--spacing-xl);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    animation: slideUp 1s ease forwards;
}

.hero-carousel .carousel-indicators {
    bottom: var(--spacing-xl);
}

.hero-carousel .carousel-indicators [data-bs-target] {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--white);
    opacity: 0.5;
    margin: 0 6px;
    border: none;
    transition: all 0.3s ease;
}

.hero-carousel .carousel-indicators .active {
    opacity: 1;
    width: 30px;
    border-radius: var(--radius-full);
    background-color: var(--primary);
}

.carousel-control-prev-icon,
.carousel-control-next-icon {
    width: 3rem;
    height: 3rem;
    background-color: rgba(255,255,255,0.2);
    border-radius: 50%;
    background-size: 50%;
    transition: all 0.3s ease;
}

.carousel-control-prev:hover .carousel-control-prev-icon,
.carousel-control-next:hover .carousel-control-next-icon {
    background-color: var(--primary);
}

/* === SECTION STYLING === */
.section-padding {
    padding-top: 5rem;
    padding-bottom: 5rem;
}

.section-heading {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

.section-heading h2 {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 1rem;
}

.section-heading::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background-color: var(--primary);
    margin: 0 auto;
    border-radius: var(--radius-full);
}

.section-heading p {
    color: var(--gray-600);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 1rem auto 0;
}

/* === BOOK CARDS === */
.book-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.book-cover-container {
    position: relative;
    overflow: hidden;
    height: 280px;
    background-color: var(--gray-100);
}

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

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

.book-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background-color: var(--primary);
    color: var(--white);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 2;
    box-shadow: var(--shadow-sm);
}

.book-card-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.book-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.book-author {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.book-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: auto;
    margin-bottom: 1rem;
}

.book-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-whatsapp {
    background-color: #25D366;
    color: white;
    border: none;
}
.btn-whatsapp:hover {
    background-color: #128C7E;
    color: white;
}

.btn-tokopedia {
    background-color: #42B549;
    color: white;
    border: none;
}
.btn-tokopedia:hover {
    background-color: #03930b;
    color: white;
}

.btn-shopee {
    background-color: #EE4D2D;
    color: white;
    border: none;
}
.btn-shopee:hover {
    background-color: #d73211;
    color: white;
}

/* === CATEGORY CARDS === */
.category-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    color: var(--white);
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-decoration: none;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    color: var(--white);
}

.category-card i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.category-card h3 {
    color: var(--white);
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.category-card span {
    background-color: rgba(255,255,255,0.2);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
}

/* Alternating Category Colors */
.col-md-4:nth-child(2n) .category-card {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
.col-md-4:nth-child(3n) .category-card {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}
.col-md-4:nth-child(4n) .category-card {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}
.col-md-4:nth-child(5n) .category-card {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
}

/* === ABOUT SECTION === */
.about-img-wrapper {
    position: relative;
    padding: 1rem;
}
.about-img-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 50%;
    border-top: 4px solid var(--primary);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-lg) 0 0 0;
}
.about-img-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 50%;
    height: 50%;
    border-bottom: 4px solid var(--primary);
    border-right: 4px solid var(--primary);
    border-radius: 0 0 var(--radius-lg) 0;
}
.about-img {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* === BLOG CARDS === */
.blog-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    height: 100%;
    overflow: hidden;
}

.blog-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.blog-thumbnail {
    height: 220px;
    object-fit: cover;
    width: 100%;
}

.blog-card-body {
    padding: 1.5rem;
}

.blog-meta {
    display: flex;
    gap: 1rem;
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.blog-meta i {
    color: var(--primary);
    margin-right: 0.25rem;
}

.blog-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--gray-900);
}

.blog-title a {
    color: inherit;
}
.blog-title a:hover {
    color: var(--primary);
}

.blog-excerpt {
    color: var(--gray-600);
    margin-bottom: 1.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* === CATALOG PAGE === */
.filter-sidebar {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.filter-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.filter-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.filter-list li {
    margin-bottom: 0.5rem;
}

.filter-list a {
    color: var(--gray-600);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.filter-list a:hover, .filter-list a.active {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

/* === BOOK DETAIL PAGE === */
.book-detail-cover {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    display: block;
}

.detail-table {
    margin-bottom: 2rem;
}

.detail-table th {
    width: 35%;
    color: var(--gray-500);
    font-weight: 500;
    border-bottom: 1px solid var(--gray-200);
    padding: 0.75rem 0;
}

.detail-table td {
    color: var(--gray-900);
    font-weight: 600;
    border-bottom: 1px solid var(--gray-200);
    padding: 0.75rem 0;
}

/* === CONTACT PAGE === */
.contact-info-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    height: 100%;
    transition: all 0.3s;
}

.contact-info-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-5px);
}

.contact-icon-wrapper {
    width: 60px;
    height: 60px;
    background-color: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1.5rem;
}

.contact-form-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 3rem;
    box-shadow: var(--shadow-md);
}

/* === LOGIN PAGE === */
.login-bg {
    background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    border: none;
}

.login-header {
    background: var(--primary);
    color: var(--white);
    padding: 2rem;
    text-align: center;
}

/* === FOOTER === */
footer {
    background-color: var(--gray-900) !important;
    color: var(--gray-300);
}

.footer-links a {
    color: var(--gray-400) !important;
    transition: all 0.3s ease;
    display: inline-block;
}

.footer-links a:hover {
    color: var(--white) !important;
    padding-left: 5px;
}

.social-links a {
    border-color: rgba(255,255,255,0.2) !important;
    color: var(--gray-300);
    transition: all 0.3s;
}

.social-links a:hover {
    background-color: var(--primary);
    border-color: var(--primary) !important;
    color: var(--white);
    transform: translateY(-3px);
}

/* (Admin layout styles are consolidated in the dedicated section at the bottom of this file) */

/* === ADMIN STAT CARDS === */
.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin-right: 1.5rem;
}

.bg-blue-light { background-color: #e0f2fe; color: #0284c7; }
.bg-green-light { background-color: #dcfce7; color: #16a34a; }
.bg-purple-light { background-color: #f3e8ff; color: #9333ea; }
.bg-orange-light { background-color: #ffedd5; color: #ea580c; }

.stat-info h3 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0;
    color: var(--gray-900);
}

.stat-info p {
    color: var(--gray-500);
    margin-bottom: 0;
    font-weight: 500;
}

/* === ADMIN TABLES === */
.table-responsive {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.table th {
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
    background-color: var(--gray-50);
}

.table td {
    vertical-align: middle;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-200);
}

.table tbody tr:hover {
    background-color: var(--gray-50);
}

.table-thumbnail {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    object-fit: cover;
}

.action-btns {
    display: flex;
    gap: 0.25rem;
}
.action-btns .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* === ADMIN FORMS === */
.form-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

.form-label {
    font-weight: 500;
    color: var(--gray-700);
}

.form-control, .form-select {
    border-color: var(--gray-300);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem rgba(37, 99, 235, 0.25);
}

.is-invalid {
    border-color: var(--danger) !important;
}

.invalid-feedback {
    color: var(--danger);
    font-size: 0.875rem;
}

.image-preview {
    max-width: 200px;
    margin-top: 1rem;
    border-radius: var(--radius-md);
    border: 1px dashed var(--gray-400);
    padding: 0.25rem;
}

/* === ADMIN ALERTS === */
.alert {
    border-radius: var(--radius-md);
    border: none;
    box-shadow: var(--shadow-sm);
    animation: slideInLeft 0.5s ease;
}

/* === FLOATING WHATSAPP & BACK TO TOP BUTTONS === */
.floating-whatsapp {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background-color: #25D366;
    color: #ffffff !important;
    padding: 10px 18px;
    border-radius: 50px;
    z-index: 999;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.floating-whatsapp:hover {
    background-color: #1ebe5d;
    color: #ffffff !important;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5);
}

.floating-whatsapp i {
    font-size: 20px;
    line-height: 1;
}

#btn-back-to-top,
.back-to-top {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 42px;
    height: 42px;
    background-color: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 50%;
    z-index: 998;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    align-items: center;
    justify-content: center;
}

#btn-back-to-top:hover,
.back-to-top:hover {
    background-color: var(--primary-dark);
    color: var(--white);
    transform: translateY(-3px);
}

/* === PAGINATION === */
.pagination {
    margin-top: 2rem;
}

.page-link {
    color: var(--gray-600);
    border: none;
    margin: 0 0.25rem;
    border-radius: var(--radius-md) !important;
    padding: 0.5rem 1rem;
    transition: all 0.2s;
}

.page-link:hover {
    background-color: var(--gray-200);
    color: var(--primary);
}

.page-item.active .page-link {
    background-color: var(--primary);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

/* === BREADCRUMBS === */
.breadcrumb-item a {
    color: var(--gray-500);
}
.breadcrumb-item.active {
    color: var(--primary);
    font-weight: 500;
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

.fade-in { animation: fadeIn 0.8s ease forwards; }
.slide-up { animation: slideUp 0.8s ease forwards; opacity: 0; }

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--gray-300);
}

.empty-state i {
    font-size: 4rem;
    color: var(--gray-400);
    margin-bottom: 1rem;
}

.empty-state h4 {
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

/* === UTILITY CLASSES === */
.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }
.bg-primary-light { background-color: var(--primary-light) !important; }
.text-accent { color: var(--accent) !important; }
.shadow-hover { transition: box-shadow 0.3s; }
.shadow-hover:hover { box-shadow: var(--shadow-lg); }
.img-cover { object-fit: cover; }

/* === RESPONSIVE === */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background: var(--white);
        padding: 1rem;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-md);
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 1000;
    }
    
    .hero-carousel .carousel-caption h2 {
        font-size: 2rem;
    }
    
    .hero-carousel .carousel-item {
        height: 400px;
    }
}

@media (max-width: 767.98px) {
    .section-padding {
        padding-top: 3rem;
        padding-bottom: 3rem;
    }
    
    .book-cover-container {
        height: 220px;
    }
    
    .contact-form-card {
        padding: 1.5rem;
    }
}

/* ============================================
   ADMIN DASHBOARD STYLES (MODERN, UNIFIED & FULLY RESPONSIVE)
   ============================================ */

/* --- Admin Document & Smooth Scroll --- */
html.admin-html,
body.admin-body {
    height: auto !important;
    min-height: 100vh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    background-color: #f1f5f9 !important;
    color: #0f172a;
    font-family: var(--font-family);
}

/* When mobile sidebar is open, lock body scroll */
body.admin-body.sidebar-open {
    overflow: hidden !important;
}

/* --- Admin Wrapper Layout --- */
#admin-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
    position: relative;
    background-color: #f1f5f9;
    overflow-x: hidden;
}

/* --- Admin Sidebar (Desktop Default >= 992px) --- */
#sidebar {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    background-color: #0f172a !important;
    color: #ffffff;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.08);
}

/* Custom scrollbar for sidebar */
#sidebar::-webkit-scrollbar {
    width: 5px;
}
#sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Desktop Collapsed Sidebar (PC & Laptop) */
/* Sets margin-left: -260px so outer flex width is exactly 260px - 260px = 0px, content-wrapper starts at exactly 0px with no clipping */
#sidebar.collapsed {
    margin-left: -260px !important;
    box-shadow: none !important;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background-color: rgba(0, 0, 0, 0.25);
    text-align: center;
}

.sidebar-header h5 {
    color: #ffffff !important;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.sidebar-menu {
    flex-grow: 1;
    padding: 1rem 0.75rem 2rem 0.75rem;
}

.sidebar-menu .nav-link {
    color: #cbd5e1 !important;
    padding: 0.65rem 0.875rem !important;
    border-radius: var(--radius-md);
    margin-bottom: 3px;
    font-size: 0.925rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
}

.sidebar-menu .nav-link i {
    width: 24px;
    text-align: center;
    margin-right: 0.5rem;
    font-size: 1rem;
}

.sidebar-menu .nav-link:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.12) !important;
    transform: translateX(3px);
}

.sidebar-menu .nav-link.active {
    color: #ffffff !important;
    background-color: var(--primary) !important;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

/* Sidebar Backdrop for Mobile/Tablet */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* --- Content Wrapper & Main Scroll Area --- */
#content-wrapper {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    background-color: #f1f5f9;
}

/* --- Topbar --- */
.topbar {
    min-height: 64px;
    background-color: #ffffff !important;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.topbar .btn-link {
    color: #334155;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.topbar .btn-link:hover {
    background-color: #f1f5f9;
    color: var(--primary);
}

.topbar .nav-link {
    color: #334155 !important;
    font-weight: 500;
}

.topbar .dropdown-toggle::after {
    display: none;
}

/* --- Text Utility Colors (admin) --- */
.text-gray-400 { color: #64748b !important; }
.text-gray-600 { color: #334155 !important; }
.text-gray-800 { color: #0f172a !important; }

/* --- Admin Cards --- */
.admin-body .card {
    border: 1px solid #e2e8f0 !important;
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08) !important;
    background-color: #ffffff;
    margin-bottom: 1.5rem;
}

.admin-body .card-header {
    background-color: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
    font-weight: 700;
    color: #0f172a !important;
    padding: 1rem 1.25rem;
}

.admin-body .card-body {
    padding: 1.5rem;
}

/* --- Admin Tables --- */
.admin-body .table {
    color: #0f172a !important;
    font-size: 0.925rem;
    margin-bottom: 0;
}

.admin-body .table th {
    font-weight: 700 !important;
    color: #0f172a !important;
    background-color: #f1f5f9 !important;
    border-bottom: 2px solid #cbd5e1 !important;
    white-space: nowrap;
    padding: 0.75rem 1rem;
}

.admin-body .table td {
    vertical-align: middle;
    color: #1e293b !important;
    padding: 0.75rem 1rem;
}

.admin-body .table tbody tr:hover {
    background-color: #f8fafc;
}

/* --- Admin Form Labels & Inputs --- */
.admin-body .form-label {
    font-weight: 600 !important;
    color: #0f172a !important;
    font-size: 0.925rem;
    margin-bottom: 0.5rem;
}

.admin-body .form-control,
.admin-body .form-select {
    color: #0f172a !important;
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    font-weight: 500;
    padding: 0.6rem 0.875rem;
    border-radius: var(--radius-md);
}

.admin-body .form-control:focus,
.admin-body .form-select:focus {
    color: #0f172a !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.2) !important;
}

/* --- Form Action Buttons (Save / Cancel) --- */
.admin-body .form-actions,
.admin-body form > .mt-4 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding-top: 1.5rem;
    margin-top: 1.5rem !important;
    border-top: 1px solid #e2e8f0;
}

.admin-body .form-actions .btn,
.admin-body form > .mt-4 .btn {
    padding: 0.625rem 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* --- Main Content Area: Generous Bottom Padding for Guaranteed Scrollability --- */
.main-content {
    flex: 1 0 auto;
    width: 100%;
    padding: 1.75rem 2rem 6rem 2rem !important;
}

/* --- Stat Cards (Dashboard) --- */
.stat-card {
    border-radius: var(--radius-lg) !important;
    border: none !important;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card .card-body {
    padding: 1.25rem 1.5rem;
}

.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* --- Admin Nav Tabs --- */
.admin-body .nav-tabs {
    border-bottom: 2px solid #e2e8f0;
}

.admin-body .nav-tabs .nav-link {
    color: var(--gray-600) !important;
    font-weight: 600;
    border: none;
    padding: 0.75rem 1.25rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.admin-body .nav-tabs .nav-link.active {
    color: var(--primary) !important;
    border-bottom: 3px solid var(--primary);
    background: transparent;
}

.admin-body .nav-tabs .nav-link:hover {
    color: var(--primary) !important;
}

/* --- Admin Alert --- */
.admin-body .alert {
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

/* --- Thumbnail in Table --- */
.table .img-thumbnail {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: var(--radius-md);
    padding: 2px;
}

/* --- Badge improvements --- */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* --- SweetAlert2 custom --- */
.swal2-popup {
    font-family: var(--font-family) !important;
    border-radius: var(--radius-lg) !important;
}

/* --- Footer --- */
footer.border-top {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
    padding: 1rem 0;
}

/* ================================================================
   RESPONSIVE MEDIA QUERIES (PC, Laptop, Tablet, Mobile, iPhone)
   ================================================================ */

/* Tablet & Mobile Screens (< 992px) */
@media (max-width: 991.98px) {
    /* Mobile / Tablet Drawer Sidebar */
    #sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        height: 100vh !important;
        height: 100dvh !important; /* Mobile dynamic viewport */
        width: 270px !important;
        min-width: 270px !important;
        max-width: 270px !important;
        z-index: 1050 !important;
        transform: translateX(-100%) !important;
        margin-left: 0 !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.3);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    #sidebar.show {
        transform: translateX(0) !important;
    }

    #content-wrapper {
        width: 100% !important;
        margin-left: 0 !important;
    }

    .main-content {
        padding: 1rem 1rem 6rem 1rem !important;
    }

    .topbar {
        padding: 0.5rem 1rem !important;
        min-height: 56px !important;
    }

    /* --- Compact Cards on Tablet --- */
    .admin-body .card,
    .card {
        margin-bottom: 0.85rem !important;
        border-radius: 8px !important;
    }

    .admin-body .card-header,
    .card-header {
        padding: 0.5rem 0.85rem !important;
        font-size: 0.875rem !important;
    }

    .admin-body .card-body,
    .card-body {
        padding: 0.85rem !important;
    }

    .form-card {
        padding: 1rem !important;
    }

    /* Stat Cards (Tablet) */
    .stat-card {
        padding: 0.75rem 0.85rem !important;
        margin-bottom: 0.75rem !important;
    }

    .stat-card .card-body {
        padding: 0.65rem 0.85rem !important;
    }

    .stat-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.15rem !important;
        margin-right: 0.75rem !important;
    }

    .stat-info h3 {
        font-size: 1.25rem !important;
    }

    .stat-info p {
        font-size: 0.75rem !important;
    }

    /* Public Book & Category Cards (Tablet) */
    .book-card .book-cover {
        height: 200px !important;
    }

    .book-card-body {
        padding: 0.75rem !important;
    }

    .book-title {
        font-size: 0.875rem !important;
        margin-bottom: 0.25rem !important;
    }

    .book-price {
        font-size: 1rem !important;
        margin-bottom: 0.5rem !important;
    }

    .category-card {
        padding: 1.25rem 0.75rem !important;
    }

    .category-card i {
        font-size: 1.75rem !important;
        margin-bottom: 0.5rem !important;
    }

    .category-card h3 {
        font-size: 0.95rem !important;
    }

    /* --- Compact Buttons on Tablet --- */
    .btn,
    .admin-body .btn {
        font-size: 0.8125rem !important;
        padding: 0.35rem 0.75rem !important;
        border-radius: 5px !important;
        line-height: 1.4 !important;
    }

    .btn-sm,
    .admin-body .btn-sm {
        font-size: 0.75rem !important;
        padding: 0.22rem 0.55rem !important;
        border-radius: 4px !important;
    }

    .btn-lg,
    .admin-body .btn-lg {
        font-size: 0.875rem !important;
        padding: 0.45rem 1rem !important;
    }

    /* Form Action Buttons: compact row layout, no bloated full-width stacking */
    .admin-body .form-actions,
    .admin-body form > .mt-4 {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 0.5rem !important;
        margin-top: 1rem !important;
        padding-top: 0.75rem !important;
        width: 100% !important;
    }

    .admin-body .form-actions .btn,
    .admin-body form > .mt-4 .btn {
        width: auto !important;
        flex: 0 1 auto !important;
        padding: 0.38rem 0.85rem !important;
        font-size: 0.8125rem !important;
        gap: 0.35rem !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
    }

    /* Override Bootstrap px-4 py-2 utility classes on buttons */
    .btn.px-4,
    .admin-body .btn.px-4 {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }

    .btn.py-2,
    .admin-body .btn.py-2 {
        padding-top: 0.38rem !important;
        padding-bottom: 0.38rem !important;
    }

    /* Form Inputs (Tablet) */
    .admin-body .form-label {
        font-size: 0.8125rem !important;
        margin-bottom: 0.25rem !important;
    }

    .admin-body .form-control,
    .admin-body .form-select {
        font-size: 0.85rem !important;
        padding: 0.38rem 0.65rem !important;
        min-height: 36px !important;
    }

    /* Tables (Tablet) */
    .admin-body .table th,
    .admin-body .table td {
        padding: 0.45rem 0.65rem !important;
        font-size: 0.8125rem !important;
    }

    .admin-body .table .btn {
        padding: 0.2rem 0.45rem !important;
        font-size: 0.75rem !important;
    }

    .table .img-thumbnail {
        width: 40px !important;
        height: 40px !important;
        max-height: 40px !important;
    }

    /* Floating WhatsApp on Tablet: Compact pill */
    .floating-whatsapp {
        bottom: 20px !important;
        right: 20px !important;
        padding: 8px 14px !important;
        font-size: 13px !important;
    }
}

/* Small Smartphone / iPhone Screens (< 576px) */
@media (max-width: 575.98px) {
    #sidebar {
        width: 250px !important;
        min-width: 250px !important;
        max-width: 250px !important;
    }

    .main-content {
        padding: 0.85rem 0.65rem 6.5rem 0.65rem !important;
    }

    /* --- Extra Compact Cards on Mobile & iPhone --- */
    .admin-body .card,
    .card {
        margin-bottom: 0.65rem !important;
        border-radius: 6px !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
    }

    .admin-body .card-header,
    .card-header {
        padding: 0.4rem 0.65rem !important;
        font-size: 0.8125rem !important;
    }

    .admin-body .card-body,
    .card-body {
        padding: 0.65rem !important;
    }

    .form-card {
        padding: 0.75rem 0.65rem !important;
    }

    /* Compact Stat Cards (Mobile / iPhone) */
    .stat-card {
        padding: 0.5rem 0.6rem !important;
        margin-bottom: 0.5rem !important;
    }

    .stat-card .card-body {
        padding: 0.5rem 0.55rem !important;
    }

    .stat-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 0.95rem !important;
        margin-right: 0.4rem !important;
    }

    .stat-info h3 {
        font-size: 1.1rem !important;
    }

    .stat-info p {
        font-size: 0.6875rem !important;
    }

    /* Public Book Cards (Mobile / iPhone) */
    .book-card .book-cover {
        height: 160px !important;
    }

    .book-card-body {
        padding: 0.5rem !important;
    }

    .book-title {
        font-size: 0.785rem !important;
        margin-bottom: 0.2rem !important;
    }

    .book-author {
        font-size: 0.6875rem !important;
        margin-bottom: 0.25rem !important;
    }

    .book-price {
        font-size: 0.85rem !important;
        margin-bottom: 0.35rem !important;
    }

    .book-badge {
        font-size: 0.625rem !important;
        padding: 0.15rem 0.35rem !important;
    }

    /* Public Category Cards (Mobile / iPhone) */
    .category-card {
        padding: 0.65rem 0.45rem !important;
        border-radius: 6px !important;
    }

    .category-card i {
        font-size: 1.25rem !important;
        margin-bottom: 0.25rem !important;
    }

    .category-card h3 {
        font-size: 0.8rem !important;
        margin-bottom: 0.2rem !important;
    }

    .category-card span {
        font-size: 0.65rem !important;
        padding: 0.12rem 0.4rem !important;
    }

    /* Public Contact Cards (Mobile / iPhone) */
    .contact-info-card {
        padding: 0.85rem 0.5rem !important;
    }

    .contact-icon-wrapper {
        width: 36px !important;
        height: 36px !important;
        font-size: 1rem !important;
        margin-bottom: 0.5rem !important;
    }

    .contact-form-card {
        padding: 1rem 0.75rem !important;
    }

    /* --- Extra Compact Buttons on Mobile & iPhone --- */
    /* Prevents giant full-width buttons that waste page height */
    .btn,
    .admin-body .btn {
        font-size: 0.775rem !important;
        padding: 0.28rem 0.6rem !important;
        border-radius: 4px !important;
        line-height: 1.35 !important;
    }

    .btn-sm,
    .admin-body .btn-sm {
        font-size: 0.7rem !important;
        padding: 0.16rem 0.42rem !important;
        border-radius: 3px !important;
    }

    .btn-lg,
    .admin-body .btn-lg {
        font-size: 0.825rem !important;
        padding: 0.35rem 0.75rem !important;
    }

    /* Form Action Buttons: neat horizontal row, never giant stacked blocks */
    .admin-body .form-actions,
    .admin-body form > .mt-4 {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 0.4rem !important;
        margin-top: 0.75rem !important;
        padding-top: 0.6rem !important;
        width: 100% !important;
    }

    .admin-body .form-actions .btn,
    .admin-body form > .mt-4 .btn {
        width: auto !important;
        flex: 0 1 auto !important;
        padding: 0.32rem 0.7rem !important;
        font-size: 0.775rem !important;
        gap: 0.25rem !important;
    }

    .btn.px-4,
    .admin-body .btn.px-4 {
        padding-left: 0.7rem !important;
        padding-right: 0.7rem !important;
    }

    .btn.py-2,
    .admin-body .btn.py-2 {
        padding-top: 0.32rem !important;
        padding-bottom: 0.32rem !important;
    }

    /* Inputs & Form Controls (Mobile / iPhone) */
    .admin-body .form-label {
        font-size: 0.775rem !important;
        margin-bottom: 0.18rem !important;
    }

    .admin-body .form-control,
    .admin-body .form-select {
        font-size: 0.8125rem !important;
        padding: 0.32rem 0.55rem !important;
        min-height: 32px !important;
        border-radius: 4px !important;
    }

    .admin-body .form-text,
    .admin-body .invalid-feedback {
        font-size: 0.7rem !important;
    }

    /* Tables (Mobile / iPhone) */
    .admin-body .table th,
    .admin-body .table td {
        padding: 0.35rem 0.5rem !important;
        font-size: 0.775rem !important;
    }

    .table .img-thumbnail {
        width: 32px !important;
        height: 32px !important;
        max-height: 32px !important;
    }

    .action-btns .btn,
    .admin-body .table .btn {
        padding: 0.18rem 0.35rem !important;
        font-size: 0.7rem !important;
    }

    .badge {
        font-size: 0.6875rem !important;
        padding: 0.2em 0.45em !important;
    }

    /* Typography scale down for compact view */
    h2, .h2 { font-size: 1.25rem !important; }
    h4, .h4 { font-size: 1.05rem !important; }
    h5, .h5 { font-size: 0.95rem !important; }
    h6, .h6 { font-size: 0.85rem !important; }
    .breadcrumb { font-size: 0.785rem !important; margin-bottom: 0.4rem !important; }

    /* Floating WhatsApp Button (Mobile & iPhone: Compact Circular Icon-Only, No Wasted Space) */
    .floating-whatsapp {
        bottom: 16px !important;
        right: 16px !important;
        width: 46px !important;
        height: 46px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        justify-content: center !important;
        align-items: center !important;
        box-shadow: 0 4px 12px rgba(37, 211, 102, 0.45) !important;
    }

    .floating-whatsapp .floating-whatsapp-text {
        display: none !important;
    }

    .floating-whatsapp i {
        font-size: 24px !important;
        line-height: 1 !important;
        margin: 0 !important;
    }

    #btn-back-to-top,
    .back-to-top {
        bottom: 70px !important;
        right: 16px !important;
        width: 38px !important;
        height: 38px !important;
        font-size: 14px !important;
    }
}
