/* ==========================================================================
   Mobile-Friendly Styles for ResponsiveWorks Integration Hub
   These styles ONLY apply to mobile devices and do not affect desktop layout.
   ========================================================================== */

/* ==========================================================================
   CSS Custom Properties for Mobile
   ========================================================================== */
:root {
    --mobile-nav-height: 60px;
    --mobile-header-height: 56px;
    --mobile-fab-size: 56px;
    --mobile-drawer-width: 280px;
    --mobile-touch-target: 44px;
}

/* ==========================================================================
   Mobile Bottom Navigation Bar
   Fixed navigation at the bottom of the screen for quick access
   ========================================================================== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1040;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-bottom-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mobile-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: var(--mobile-touch-target);
    padding: 4px 0;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 10px;
    transition: color 0.2s ease;
}

.mobile-bottom-nav-item:hover,
.mobile-bottom-nav-item:focus,
.mobile-bottom-nav-item.active {
    color: #fff;
    text-decoration: none;
}

.mobile-bottom-nav-item.active {
    color: #0d6efd;
}

.mobile-bottom-nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
}

.mobile-bottom-nav-item span {
    font-weight: 500;
}

/* ==========================================================================
   Mobile Slide-Out Drawer
   Full navigation drawer that slides in from the left
   ========================================================================== */
.mobile-drawer-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1045;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-drawer-backdrop.show {
    display: block;
    opacity: 1;
}

.mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--mobile-drawer-width);
    height: 100%;
    background: #f8f9fa;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-drawer.show {
    transform: translateX(0);
}

.mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
}

.mobile-drawer-header h5 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.mobile-drawer-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    padding: 0;
    line-height: 1;
    cursor: pointer;
    min-width: var(--mobile-touch-target);
    min-height: var(--mobile-touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-drawer-body {
    padding: 8px 0;
}

.mobile-drawer-section {
    padding: 8px 16px;
}

.mobile-drawer-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #6c757d;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.mobile-drawer-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #212529;
    text-decoration: none;
    border-radius: 8px;
    margin: 2px 8px;
    min-height: var(--mobile-touch-target);
    transition: background-color 0.2s ease;
}

.mobile-drawer-link:hover,
.mobile-drawer-link:focus {
    background-color: #e9ecef;
    color: #212529;
    text-decoration: none;
}

.mobile-drawer-link.active {
    background-color: #0d6efd;
    color: white;
}

.mobile-drawer-link i {
    font-size: 18px;
    width: 24px;
    margin-right: 12px;
    text-align: center;
}

.mobile-drawer-divider {
    height: 1px;
    background: #dee2e6;
    margin: 8px 16px;
}

/* ==========================================================================
   Floating Action Button (FAB)
   Quick actions button in bottom-right corner
   ========================================================================== */
.mobile-fab {
    display: none;
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + 16px + env(safe-area-inset-bottom, 0));
    right: 16px;
    width: var(--mobile-fab-size);
    height: var(--mobile-fab-size);
    border-radius: 50%;
    background: #0d6efd;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.4);
    z-index: 1030;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mobile-fab:hover,
.mobile-fab:focus {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(13, 110, 253, 0.5);
}

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

.mobile-fab i {
    font-size: 24px;
}

.mobile-fab.expanded i {
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

/* FAB Menu */
.mobile-fab-menu {
    display: none;
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + var(--mobile-fab-size) + 24px + env(safe-area-inset-bottom, 0));
    right: 16px;
    z-index: 1029;
    flex-direction: column;
    gap: 8px;
}

.mobile-fab-menu.show {
    display: flex;
}

.mobile-fab-menu-item {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    animation: fabMenuItemIn 0.2s ease forwards;
    opacity: 0;
    transform: translateY(10px);
}

.mobile-fab-menu-item:nth-child(1) { animation-delay: 0ms; }
.mobile-fab-menu-item:nth-child(2) { animation-delay: 50ms; }
.mobile-fab-menu-item:nth-child(3) { animation-delay: 100ms; }
.mobile-fab-menu-item:nth-child(4) { animation-delay: 150ms; }

@keyframes fabMenuItemIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mobile-fab-menu-label {
    background: #212529;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.mobile-fab-menu-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: white;
    color: #212529;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.mobile-fab-menu-btn:hover {
    background: #f8f9fa;
    color: #212529;
    text-decoration: none;
}

.mobile-fab-menu-btn i {
    font-size: 18px;
}

/* ==========================================================================
   Mobile Table to Cards Transformation
   Convert tables to stacked cards on mobile for better readability
   ========================================================================== */
.mobile-card-view {
    display: none;
}

/* ==========================================================================
   Mobile Form Optimizations
   Better touch targets and layout for forms on mobile
   ========================================================================== */
@media (max-width: 767.98px) {
    /* Larger touch targets for form controls */
    .form-control,
    .form-select {
        min-height: var(--mobile-touch-target);
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Stack form labels on top */
    .form-label {
        margin-bottom: 4px;
    }

    /* Better button sizing */
    .btn {
        min-height: var(--mobile-touch-target);
        padding-left: 16px;
        padding-right: 16px;
    }

    .btn-sm {
        min-height: 36px;
    }

    /* Full-width buttons in button groups */
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    .d-flex.gap-2 > .btn {
        flex: 1 1 auto;
        min-width: 80px;
    }
}

/* ==========================================================================
   Mobile Card Grid Optimizations
   Better spacing and sizing for cards on mobile
   ========================================================================== */
@media (max-width: 767.98px) {
    /* Single column cards on mobile */
    .row > [class*="col-md-"],
    .row > [class*="col-lg-"] {
        margin-bottom: 12px;
    }

    /* Tighter card padding */
    .card-body {
        padding: 12px;
    }

    .card-header,
    .card-footer {
        padding: 10px 12px;
    }

    /* Summary stat cards - horizontal scroll */
    .summary-cards-scroll {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        gap: 12px;
        padding-bottom: 8px;
        margin: 0 -12px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .summary-cards-scroll > .card {
        flex: 0 0 140px;
        scroll-snap-align: start;
    }

    .summary-cards-scroll::-webkit-scrollbar {
        display: none;
    }
}

/* ==========================================================================
   Mobile Header Adjustments
   Optimize header for mobile screens
   ========================================================================== */
@media (max-width: 767.98px) {
    /* Adjust header title/subtitle */
    .main-content h1 {
        font-size: 1.5rem;
    }

    .main-content h4 {
        font-size: 1.25rem;
    }

    /* Stack header actions */
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 > .d-flex {
        width: 100%;
        justify-content: flex-start;
    }

    /* Breadcrumbs smaller */
    .breadcrumb {
        font-size: 0.85rem;
    }
}

/* ==========================================================================
   Mobile Filter Panel
   Collapsible filter section for mobile
   ========================================================================== */
.mobile-filter-toggle {
    display: none;
}

@media (max-width: 767.98px) {
    .mobile-filter-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 12px 16px;
        background: #f8f9fa;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        cursor: pointer;
        margin-bottom: 12px;
    }

    .mobile-filter-toggle-text {
        display: flex;
        align-items: center;
        gap: 8px;
        font-weight: 500;
    }

    .mobile-filter-badge {
        background: #0d6efd;
        color: white;
        font-size: 11px;
        padding: 2px 6px;
        border-radius: 10px;
        min-width: 20px;
        text-align: center;
    }

    .mobile-filter-toggle i.bi-chevron-down {
        transition: transform 0.2s ease;
    }

    .mobile-filter-toggle.expanded i.bi-chevron-down {
        transform: rotate(180deg);
    }

    /* Hide filters by default on mobile */
    .mobile-filters-collapsible {
        display: none;
        padding-top: 12px;
    }

    .mobile-filters-collapsible.show {
        display: block;
    }
}

/* ==========================================================================
   Mobile Table Responsive Enhancements
   Better table handling on mobile screens
   ========================================================================== */
@media (max-width: 767.98px) {
    /* Make table-responsive work better */
    .table-responsive {
        margin: 0 -12px;
        padding: 0 12px;
    }

    /* Alternative: Card-based table view */
    .table-mobile-cards thead {
        display: none;
    }

    .table-mobile-cards tbody tr {
        display: block;
        background: white;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 12px;
    }

    .table-mobile-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 6px 0;
        border: none;
        border-bottom: 1px solid #f0f0f0;
    }

    .table-mobile-cards tbody td:last-child {
        border-bottom: none;
    }

    .table-mobile-cards tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6c757d;
        font-size: 12px;
        flex: 0 0 100px;
    }

    .table-mobile-cards tbody td:last-child {
        justify-content: center;
        padding-top: 12px;
    }

    /* Order cards specific styling */
    .order-mobile-card {
        background: white;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        padding: 12px;
        margin-bottom: 12px;
    }

    .order-mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 8px;
    }

    .order-mobile-card-order-num {
        font-weight: 600;
        font-size: 1rem;
    }

    .order-mobile-card-total {
        font-weight: 600;
        color: #198754;
    }

    .order-mobile-card-customer {
        color: #495057;
        margin-bottom: 4px;
    }

    .order-mobile-card-date {
        font-size: 0.85rem;
        color: #6c757d;
        margin-bottom: 8px;
    }

    .order-mobile-card-badges {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-bottom: 8px;
    }

    .order-mobile-card-actions {
        display: flex;
        justify-content: flex-end;
        padding-top: 8px;
        border-top: 1px solid #f0f0f0;
    }
}

/* ==========================================================================
   Mobile Modal Adjustments
   Full-screen modals on mobile for better usability
   ========================================================================== */
@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }

    .modal-content {
        height: 100%;
        border: none;
        border-radius: 0;
    }

    .modal-body {
        overflow-y: auto;
    }
}

/* ==========================================================================
   Mobile Pagination
   Simplified pagination for mobile
   ========================================================================== */
@media (max-width: 767.98px) {
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    .pagination .page-link {
        min-width: var(--mobile-touch-target);
        min-height: var(--mobile-touch-target);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px 12px;
    }

    /* Hide extra page numbers on mobile */
    .pagination .page-item:not(:first-child):not(:last-child):not(.active) {
        display: none;
    }

    .pagination .page-item:first-child,
    .pagination .page-item:last-child,
    .pagination .page-item.active {
        display: flex;
    }
}

/* ==========================================================================
   Mobile Body Padding for Fixed Navigation
   Prevent content from being hidden behind fixed elements
   ========================================================================== */
@media (max-width: 767.98px) {
    body.has-mobile-nav {
        padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0));
    }

    .main-content {
        padding-bottom: 24px;
    }
}

/* ==========================================================================
   Mobile Visibility Utilities
   Show/hide elements based on mobile view
   ========================================================================== */
.mobile-only {
    display: none !important;
}

.desktop-only {
    display: block;
}

@media (max-width: 767.98px) {
    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }

    /* Flex variant */
    .mobile-only-flex {
        display: flex !important;
    }
}

/* ==========================================================================
   Mobile Alert/Toast Positioning
   Move toasts above bottom nav
   ========================================================================== */
@media (max-width: 767.98px) {
    .toast-container {
        bottom: calc(var(--mobile-nav-height) + 16px + env(safe-area-inset-bottom, 0)) !important;
    }
}

/* ==========================================================================
   Mobile Store Cards
   Optimized store card display for mobile
   ========================================================================== */
@media (max-width: 767.98px) {
    .store-card .card-footer .d-flex {
        flex-direction: column;
        gap: 8px !important;
    }

    .store-card .card-footer .btn {
        width: 100%;
    }
}

/* ==========================================================================
   Print Styles - Hide Mobile Elements
   ========================================================================== */
@media print {
    .mobile-bottom-nav,
    .mobile-fab,
    .mobile-fab-menu,
    .mobile-drawer,
    .mobile-drawer-backdrop {
        display: none !important;
    }
}
