/* Mobile & Responsive UI/UX Styles for PerpusPro */

@media (max-width: 991.98px) {
    /* Mobile body bottom padding for fixed bottom nav bar */
    body {
        padding-bottom: 75px;
    }

    /* Main container padding for bottom navigation bar */
    main, .main-content {
        padding-bottom: 80px;
    }

    /* Full width content */
    .col-lg-10 {
        width: 100%;
    }
}

/* Global Mobile Responsiveness Enhancements */
@media (max-width: 767.98px) {
    /* Responsive Header Navbar */
    .navbar-clean .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .navbar-brand span {
        max-width: 130px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Breadcrumb Mobile Optimization (No wrapping breakage, horizontal scrollable if long) */
    .breadcrumb {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        margin-bottom: 0.75rem !important;
    }
    .breadcrumb::-webkit-scrollbar {
        display: none;
    }
    .breadcrumb-item {
        flex-shrink: 0;
        font-size: 0.78rem !important;
    }
    .breadcrumb-item.active {
        max-width: 170px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-block;
        vertical-align: bottom;
    }
    
    /* Truncate badges and text inside cards on mobile */
    .card .badge, 
    .book-cover-frame .badge,
    .extra-small {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Card Padding & Sizing Optimization for Smartphones */
    .rounded-5 {
        border-radius: 1.25rem !important;
    }

    .p-4, .p-md-5 {
        padding: 1.15rem !important;
    }
    
    .display-6 {
        font-size: 1.3rem !important;
        line-height: 1.3 !important;
    }

    /* 3D Floating Book Showcase sizing on mobile */
    .detail-cover-wrapper {
        max-width: 220px !important;
        margin: 0 auto 1.25rem auto !important;
    }

    /* Meta Cards Grid on Mobile */
    .meta-card-modern {
        padding: 10px 12px !important;
        border-radius: 14px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left !important;
    }
    .meta-icon-box {
        width: 36px !important;
        height: 36px !important;
        border-radius: 10px !important;
        margin-bottom: 8px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    .meta-icon-box i, .meta-icon-box svg {
        width: 16px !important;
        height: 16px !important;
    }

    /* Stack CTA Buttons Full Width on Mobile for native app touch experience */
    .detail-action-group,
    .card .d-flex.flex-wrap.align-items-center.gap-3.pt-3 {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 0.65rem !important;
    }

    .detail-action-group .btn,
    .card .d-flex.flex-wrap.align-items-center.gap-3.pt-3 .btn {
        width: 100% !important;
        justify-content: center !important;
        padding: 12px 20px !important;
        font-size: 0.9rem !important;
    }

    /* Horizontal scrollable tab pills on mobile */
    .nav-pills.mobile-scroll,
    .nav-pills.nav-fill {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .nav-pills.mobile-scroll .nav-item,
    .nav-pills.nav-fill .nav-item {
        flex: 0 0 auto !important;
    }
    .nav-pills.mobile-scroll::-webkit-scrollbar,
    .nav-pills.nav-fill::-webkit-scrollbar {
        display: none;
    }

    /* Align DataTables controls (entries & search) to the left on mobile screens */
    div.dataTables_wrapper div.dataTables_length,
    div.dataTables_wrapper div.dataTables_filter,
    div.dataTables_wrapper div.dataTables_info,
    div.dataTables_wrapper div.dataTables_paginate {
        float: none !important;
        text-align: left !important;
        width: 100% !important;
        margin: 0 0 12px 0 !important;
        padding: 0 !important;
    }

    div.dataTables_wrapper div.dataTables_length label,
    div.dataTables_wrapper div.dataTables_filter label {
        display: flex !important;
        align-items: center !important;
        width: 100% !important;
        justify-content: flex-start !important;
        text-align: left !important;
        margin: 0 !important;
        padding: 0 !important;
        gap: 8px !important;
    }

    div.dataTables_wrapper div.dataTables_length select {
        margin: 0 4px !important;
        display: inline-block !important;
        width: auto !important;
    }

    div.dataTables_wrapper div.dataTables_filter input {
        margin: 0 0 0 4px !important;
        flex-grow: 1 !important;
        width: 100% !important;
        display: inline-block !important;
    }
}

@media (max-width: 575.98px) {
    /* Extra Small Screen Adjustments (320px - 480px) */
    .navbar-brand {
        max-width: 55% !important;
    }

    .navbar-brand span.fw-bold {
        font-size: 0.88rem !important;
    }

    .breadcrumb-item.active {
        max-width: 130px;
    }

    .meta-card-modern strong {
        font-size: 0.78rem !important;
    }

    /* Gutter optimization for mobile grids */
    .row.g-3 {
        --bs-gutter-x: 0.5rem !important;
        --bs-gutter-y: 0.5rem !important;
    }
    .row.g-4, .row.g-5 {
        --bs-gutter-x: 0.75rem !important;
        --bs-gutter-y: 0.75rem !important;
    }
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(224, 230, 237, 0.8);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1050;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}

.mobile-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #888ea8;
    text-decoration: none !important;
    font-size: 0.72rem;
    font-weight: 500;
    transition: all 0.2s ease;
    padding: 6px 12px;
    border-radius: 12px;
}

.mobile-bottom-nav-item i {
    font-size: 1.25rem;
    margin-bottom: 3px;
    transition: transform 0.2s ease;
}

.mobile-bottom-nav-item.active,
.mobile-bottom-nav-item:hover {
    color: var(--primary, #4361ee);
    font-weight: 600;
}

.mobile-bottom-nav-item.active i {
    transform: translateY(-2px);
}

/* Floating Action Camera Scan Button */
.mobile-fab-scan {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--bg-gradient, linear-gradient(135deg, #4361ee 0%, #805dca 100%));
    color: #fff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(67, 97, 238, 0.4);
    margin-top: -24px;
    border: 3px solid #fff;
    transition: transform 0.2s ease;
}

.mobile-fab-scan:active {
    transform: scale(0.92);
}

.mobile-fab-scan i {
    font-size: 1.4rem;
    margin-bottom: 0 !important;
}

/* E-Book Mobile Touch Reader */
.touch-reader-container {
    width: 100%;
    min-height: calc(100vh - 120px);
    background: #1a1a2e;
    color: #e0e0e0;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.touch-reader-header {
    padding: 12px 18px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.touch-reader-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    overflow-x: auto;
}

.touch-reader-body iframe,
.touch-reader-body canvas {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.touch-reader-toolbar {
    padding: 12px 18px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    gap: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Mobile Digital Card View */
.digital-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.digital-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(67, 97, 238, 0.3) 0%, transparent 70%);
    border-radius: 50%;
}

.digital-card-barcode {
    background: #fff;
    padding: 12px;
    border-radius: 12px;
    display: inline-block;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Responsive Grid / Touch Card list */
.book-card-mobile {
    border-radius: 14px;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
    overflow: hidden;
}

.book-card-mobile:active {
    transform: scale(0.98);
}

.book-card-cover-wrapper {
    position: relative;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: #f1f2f3;
}

.book-card-cover-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 6px;
    backdrop-filter: blur(4px);
}
