/* Mobile App-like Styling for User Section */

/* Hide web navbar on mobile for all users */
@media (max-width: 991.98px) {
    .header,
    .header .navbar,
    .header .navbar-collapse,
    .header .navbar-toggler {
        display: none !important;
    }
}

/* Show web navbar only on desktop */
@media (min-width: 992px) {
    .header,
    .header.navbar,
    .user-authenticated .header,
    html:not(.user-authenticated) .header {
        display: block !important;
    }
    .header .navbar {
        display: flex !important;
    }
    .header .navbar-collapse {
        display: flex !important;
    }
    .mobile-header {
        display: none !important;
    }
    .mobile-bottom-nav {
        display: none !important;
    }
}

/* App-like Container */
@media (max-width: 991.98px) {
    body {
        background: #f5f5f5;
        padding-bottom: 80px; /* Space for bottom navigation */
    }


    .navbar-brand img {
        height: 50px !important;
    }

    /* App-like Cards */
    .card {
        border-radius: 16px !important;
        border: none !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
        margin-bottom: 1rem;
    }

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

    /* App-like Buttons */
    .btn {
        border-radius: 12px !important;
        font-weight: 500;
        padding: 0.75rem 1.5rem;
        min-height: 48px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-primary {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border: none;
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    }

    .btn-success {
        background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
        border: none;
        box-shadow: 0 4px 12px rgba(17, 153, 142, 0.3);
    }

    /* Bottom Navigation Bar (App-like) */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 1000;
        padding: 0.5rem 0;
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    .mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: #666;
        padding: 0.5rem;
        min-width: 60px;
        transition: all 0.3s;
        position: relative;
    }

    .mobile-bottom-nav a.active {
        color: #667eea;
    }

    .mobile-bottom-nav a i {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }

    .mobile-bottom-nav a span {
        font-size: 0.7rem;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    
    .mobile-bottom-nav a {
        min-width: 0;
        padding: 0.4rem 0.25rem;
    }

    .mobile-bottom-nav a .badge {
        position: absolute;
        top: 0;
        right: 0;
        background: #ff4757;
        color: white;
        border-radius: 50%;
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.7rem;
        font-weight: bold;
    }
    
    /* Mobile Notifications Panel */
    .mobile-notifications-panel {
        position: fixed;
        bottom: 70px;
        left: 0;
        right: 0;
        background: #fff;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
        z-index: 999;
        max-height: 50vh;
        border-radius: 16px 16px 0 0;
        overflow: hidden;
    }
    
    .mobile-notifications-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
        border-bottom: 1px solid #e9ecef;
        background: #f8f9fa;
    }
    
    .mobile-notifications-body {
        max-height: calc(50vh - 60px);
        overflow-y: auto;
        padding: 0.5rem;
    }
    
    .mobile-notifications-body .notification-item {
        padding: 0.75rem;
        border-bottom: 1px solid #e9ecef;
        cursor: pointer;
        transition: background 0.2s;
    }
    
    .mobile-notifications-body .notification-item:last-child {
        border-bottom: none;
    }
    
    .mobile-notifications-body .notification-item:hover,
    .mobile-notifications-body .notification-item:active {
        background: #f8f9fa;
    }

    /* App-like Product Cards */
    .product-item .card {
        transition: transform 0.2s, box-shadow 0.2s;
    }

    .product-item .card:active {
        transform: scale(0.98);
    }

    /* App-like Forms */
    .form-control {
        border-radius: 12px;
        border: 1px solid #e0e0e0;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    .form-control:focus {
        border-color: #667eea;
        box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.15);
    }

    /* App-like Tables - Fully Responsive */
    .table-responsive {
        border-radius: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        display: block;
        width: 100%;
    }

    .table {
        margin-bottom: 0;
        width: 100%;
        min-width: 600px; /* Minimum width to prevent cramping */
    }

    .table thead {
        background: #f8f9fa;
    }
    
    .table thead th {
        white-space: nowrap;
        font-size: 0.875rem;
        padding: 0.75rem 0.5rem;
        font-weight: 600;
    }
    
    .table tbody td {
        white-space: nowrap;
        font-size: 0.875rem;
        padding: 0.75rem 0.5rem;
        vertical-align: middle;
    }
    
    /* Stack table on very small screens */
    @media (max-width: 575.98px) {
        .table-responsive {
            display: block;
            overflow-x: visible;
        }
        
        .table {
            display: block;
            width: 100%;
            min-width: 100%;
        }
        
        .table thead {
            display: none;
        }
        
        .table tbody {
            display: block;
            width: 100%;
        }
        
        .table tr {
            display: block;
            width: 100%;
            border: 1px solid #dee2e6;
            border-radius: 8px;
            margin-bottom: 1rem;
            padding: 1rem;
            background: #fff;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        
        .table td {
            display: block;
            width: 100%;
            border: none;
            padding: 0.75rem 0;
            text-align: left;
            position: relative;
            padding-left: 0;
            padding-right: 0;
            word-wrap: break-word;
            overflow-wrap: break-word;
        }
        
        .table td:before {
            content: attr(data-label);
            display: block;
            font-weight: 600;
            margin-bottom: 0.25rem;
            color: #495057;
            font-size: 0.875rem;
        }
        
        .table td:not(:last-child) {
            border-bottom: 1px solid #e9ecef;
            padding-bottom: 0.75rem;
            margin-bottom: 0.5rem;
        }
        
        /* Ensure buttons and inputs don't overflow */
        .table td .btn,
        .table td .input-group,
        .table td input {
            width: 100%;
            max-width: 100%;
        }
        
        .table td .input-group {
            flex-wrap: nowrap;
        }
    }
    
    /* Better table scrolling on mobile */
    .table-responsive::-webkit-scrollbar {
        height: 8px;
    }
    
    .table-responsive::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 10px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 10px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb:hover {
        background: #555;
    }

    /* App-like Sections */
    .hero-section {
        padding-top: 0 !important;
        padding-bottom: 1rem !important;
    }
    
    /* Reduce spacing in containers for all users on mobile */
    .hero-section .container.pt-5,
    .hero-section .container {
        padding-top: 0.25rem !important;
    }
    
    .hero-section .row.pt-3,
    .hero-section .row.pt-5 {
        padding-top: 0.25rem !important;
    }
    
    .hero-section .row .pt-5,
    .hero-section .row .pt-lg-5 {
        padding-top: 0.5rem !important;
    }
    
    /* Welcome page specific - reduce slider padding */
    .sliding-wrapper {
        padding-top: 0.5rem !important;
        padding-bottom: 1rem !important;
    }
    
    .sliding-wrapper .py-5 {
        padding-top: 0.5rem !important;
        padding-bottom: 1rem !important;
    }
    
    /* Reduce spacing in containers for authenticated users */
    .user-authenticated .hero-section .container.pt-5 {
        padding-top: 0.5rem !important;
    }
    
    .user-authenticated .hero-section .row.pt-3 {
        padding-top: 0.5rem !important;
    }
    
    .user-authenticated .card.shadow-none.mb-4 {
        margin-bottom: 1rem !important;
    }

    /* Hide footer on mobile (replaced by bottom nav) */
    .footer-part {
        display: none;
    }

    /* App-like Offcanvas Menu */
    .offcanvas {
        border-radius: 0;
    }

    .offcanvas-header {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        padding: 1.5rem;
    }

    .offcanvas-body {
        padding: 1rem;
    }

    .offcanvas-body .nav-link {
        padding: 1rem;
        border-radius: 12px;
        margin-bottom: 0.5rem;
        font-size: 1.1rem;
        font-weight: 500;
    }

    .offcanvas-body .nav-link:hover {
        background: #f5f5f5;
    }

    /* App-like Badges */
    .badge {
        border-radius: 12px;
        padding: 0.35em 0.65em;
        font-weight: 600;
    }

    /* Touch-friendly spacing */
    .mb-4 {
        margin-bottom: 1.5rem !important;
    }

    .mt-4 {
        margin-top: 1.5rem !important;
    }

    /* App-like Container */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Smooth scrolling */
    html {
        scroll-behavior: smooth;
    }

    /* App-like Loading States */
    .spinner-border {
        width: 2rem;
        height: 2rem;
    }

    /* App-like Alerts */
    .alert {
        border-radius: 12px;
        border: none;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }

    /* Hide desktop-only elements */
    .d-none.d-lg-flex,
    .d-none.d-lg-block {
        display: none !important;
    }
    
    /* Hide main header on mobile when user is authenticated */
    .user-authenticated .header {
        display: none !important;
    }
    
    /* Mobile Header for All Users */
    .mobile-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: #fff;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        border-bottom: 1px solid #e9ecef;
    }
    
    .mobile-header .container-fluid {
        padding: 0.3rem 1rem;
    }
    
    .mobile-header .navbar-brand {
        display: flex;
        align-items: center;
    }
    
    .mobile-header .navbar-brand img {
        height: 60px !important;
        width: auto !important;
        max-width: 200px !important;
    }
    
    .mobile-header .btn {
        min-height: 44px;
        font-size: 1rem;
        padding: 0.5rem 1rem;
        font-weight: 500;
    }
    
    .mobile-header .btn i {
        font-size: 1.1rem;
    }
    
    /* Ensure body has no extra padding when mobile header is shown */
    .body-wrapper,
    #main-content {
        padding-top: 0 !important;
    }
    
    /* Remove all extra padding from sections when mobile header is shown */
    .hero-section {
        padding-top: 0 !important;
    }
    
    .hero-section .container,
    .hero-section .container.pt-5 {
        padding-top: 0.25rem !important;
    }
    
    .hero-section .row.pt-3,
    .hero-section .row.pt-5 {
        padding-top: 0.25rem !important;
    }
    
    section.hero-section.pt-5 {
        padding-top: 0 !important;
    }
    
    /* Specific spacing for authenticated users */
    .user-authenticated .hero-section .container,
    .user-authenticated .hero-section .container.pt-5 {
        padding-top: 0.5rem !important;
    }
    
    .user-authenticated .hero-section .row.pt-3,
    .user-authenticated .hero-section .row.pt-5 {
        padding-top: 0.5rem !important;
    }
    
    /* Auth pages (Login, OTP, Reset Password) mobile spacing */
    .radial-gradient {
        padding-top: 1rem !important;
        padding-bottom: 80px; /* Space for bottom nav */
        min-height: calc(100vh - 60px) !important; /* Account for mobile header */
        align-items: center !important;
        justify-content: center !important;
    }
    
    .auth-login-shape-box {
        padding-top: 0 !important;
        width: 100%;
        margin-top: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100%;
    }
    
    .auth-card {
        margin-top: 0 !important;
        margin-bottom: 0.5rem !important;
        margin-left: auto;
        margin-right: auto;
    }
    
    .auth-card .card-body.pt-5 {
        padding-top: 0.5rem !important;
    }
    
    .auth-card .mb-5 {
        margin-bottom: 0.75rem !important;
    }
    
    /* Reduce logo spacing in auth cards */
    .auth-card .logo-img.mb-5 {
        margin-bottom: 0.5rem !important;
    }
    
    .auth-card .light-logo.mb-5 {
        margin-bottom: 0.5rem !important;
    }
    
    /* Reduce mobile header padding on auth pages */
    .mobile-header .container-fluid.px-3 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    /* Reduce spacing in auth card content */
    .auth-card .my-4 {
        margin-top: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* Ensure minimal gap between header and content */
    #main-wrapper.flex-column .radial-gradient {
        margin-top: 0 !important;
    }
    
    /* Hamburger button should only show on mobile when navbar is collapsed */
    /* Bootstrap's navbar-expand-lg already handles this, but ensure it's hidden on desktop */
    @media (min-width: 992px) {
        .navbar-toggler {
            display: none !important;
        }
    }
    
    /* Ensure body wrapper has proper padding when header is hidden */
    .user-authenticated .body-wrapper,
    .user-authenticated #main-content {
        padding-top: 0 !important;
    }
    
    /* Add top padding for first section when header is hidden */
    .user-authenticated .hero-section:first-child {
        padding-top: 1rem !important;
    }
    
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 991.98px) {
    .mobile-bottom-nav {
        display: none;
    }
    
    .footer-part {
        display: block;
    }
}

/* Admin Panel Mobile Styling */
@media (max-width: 991.98px) {
    /* Hide sidebar on mobile */
    .left-sidebar {
        display: none !important;
    }
    
    /* Remove margin from page wrapper on mobile */
    .page-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    /* Hide desktop header on mobile */
    .topbar {
        display: none !important;
    }
    
    /* Admin Mobile Header */
    .admin-mobile-header {
        background: #fff;
        border-bottom: 1px solid #e0e0e0;
        position: sticky;
        top: 0;
        z-index: 1000;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .admin-mobile-header .container-fluid {
        padding: 0.5rem 1rem;
    }
    
    .admin-mobile-header .navbar-brand img {
        height: 60px !important;
        width: auto;
        max-width: 200px;
    }
    
    .admin-mobile-header .btn {
        min-height: 44px;
        font-size: 1rem;
        padding: 0.5rem 1rem;
        font-weight: 500;
    }
    
    .admin-mobile-header .btn i {
        font-size: 1.1rem;
    }
    
    /* Admin Mobile Bottom Navigation (5 items) */
    .admin-mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 1px solid #e0e0e0;
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 0.75rem 0;
        z-index: 1000;
        box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    }
    
    .admin-mobile-bottom-nav .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: #6c757d;
        padding: 0.5rem;
        flex: 1;
        transition: all 0.3s ease;
        position: relative;
        min-width: 0;
    }
    
    .admin-mobile-bottom-nav .nav-item i {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
    
    .admin-mobile-bottom-nav .nav-item span {
        font-size: 0.75rem;
        text-align: center;
        line-height: 1.2;
        white-space: nowrap;
    }
    
    .admin-mobile-bottom-nav .nav-item.active {
        color: #0d6efd;
    }
    
    .admin-mobile-bottom-nav .nav-item.active i {
        color: #0d6efd;
    }
    
    .admin-mobile-bottom-nav .nav-item .badge {
        position: absolute;
        top: 0;
        right: 0.25rem;
        font-size: 0.6rem;
        padding: 0.15rem 0.3rem;
    }
    
    /* Add padding to body for bottom nav */
    body {
        padding-bottom: 70px;
    }
    
    /* Container adjustments for admin pages */
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Card adjustments */
    .card {
        margin-bottom: 1rem;
    }
    
    /* Table responsiveness for admin - only scroll when needed */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        -ms-overflow-style: -ms-autohiding-scrollbar;
    }
    
    /* Only force min-width for very complex tables with many columns (8+ columns) */
    .table-responsive table:not(.dashboard-table):not(.simple-table) {
        min-width: 600px;
        width: 100%;
    }
    
    /* Dashboard and simple tables - responsive without forced width */
    .table-responsive .dashboard-table,
    .table-responsive .simple-table {
        width: 100%;
        min-width: auto;
        max-width: 100%;
    }
    
    /* Ensure simple table containers don't force scroll */
    .table-responsive:has(.dashboard-table),
    .table-responsive:has(.simple-table) {
        overflow-x: visible;
    }
    
    /* Fallback for browsers that don't support :has() */
    @supports not selector(:has(*)) {
        .table-responsive.dashboard-table-container,
        .table-responsive.simple-table-container {
            overflow-x: visible;
        }
    }
    
    .table-responsive table th,
    .table-responsive table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Allow text wrapping in simple tables on mobile */
    .table-responsive .dashboard-table th,
    .table-responsive .dashboard-table td,
    .table-responsive .simple-table th,
    .table-responsive .simple-table td {
        white-space: normal;
        word-wrap: break-word;
    }
    
    /* Simple tables - make columns more compact on mobile */
    .table-responsive .dashboard-table th,
    .table-responsive .dashboard-table td,
    .table-responsive .simple-table th,
    .table-responsive .simple-table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
    }
    
    /* Make table headers sticky on scroll (only when scrolling) */
    .table-responsive table:not(.dashboard-table):not(.simple-table) thead th {
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 10;
        box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
    }
    
    /* Simple table - optimize column widths on mobile */
    .table-responsive .simple-table th:nth-child(1),
    .table-responsive .simple-table td:nth-child(1) {
        width: 60px;
        min-width: 60px;
        max-width: 60px;
    }
    
    .table-responsive .simple-table th:nth-child(2),
    .table-responsive .simple-table td:nth-child(2) {
        min-width: 100px;
    }
    
    .table-responsive .simple-table th:nth-child(3),
    .table-responsive .simple-table td:nth-child(3) {
        min-width: 80px;
    }
    
    /* Price input group - responsive on mobile */
    .price-input-group {
        width: 100%;
        min-width: 120px;
        max-width: 180px;
    }
    
    /* Ensure price inputs are visible and functional on mobile */
    .table-responsive .simple-table td .price-input-group {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 100% !important;
    }
    
    .table-responsive .simple-table td .price-input {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 100% !important;
    }
    
    .table-responsive .simple-table td .price-input-group .form-control {
        width: 100% !important;
        min-width: 80px;
        flex: 1;
    }
    
    .table-responsive .simple-table td .price-input-group .input-group-text {
        flex-shrink: 0;
    }
    
    /* Hide less important columns on very small screens for dashboard */
    @media (max-width: 576px) {

        /* Price input group - full width on very small screens */
        .price-input-group {
            width: 100% !important;
            min-width: 100px;
            max-width: 100%;
        }

    }
    
    /* Button groups */
    .btn-group {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .btn-group .btn {
        margin-bottom: 0.25rem;
        flex: 1;
    }
    
    /* Nav pills - responsive */
    .nav-pills {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .nav-pills .nav-item {
        flex: 1;
        min-width: calc(50% - 0.25rem);
    }
    
    .nav-pills .nav-link {
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 0.5rem 0.75rem;
    }
    
    /* Bulk actions - responsive (mobile only) */
    .d-flex.gap-2 {
        width: 100%;
    }
    
    .d-flex.gap-2 .form-select,
    .d-flex.gap-2 .btn {
        width: 100%;
    }
    
    /* Admin page spacing */
    .hero-section {
        padding-top: 1rem !important;
    }
    
    /* Admin card adjustments */
    .card-body {
        padding: 1rem;
    }
    
    /* Admin page headers - responsive layout (mobile only) */
    .card-body.d-flex.align-items-center.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }
    
    /* Buttons in admin headers - full width on mobile only */
    .card-body.d-flex.align-items-center.justify-content-between .btn {
        width: 100%;
    }
    
    /* Form adjustments */
    .form-group,
    .mb-3,
    .mb-4 {
        margin-bottom: 1rem !important;
    }
    
    /* Button Responsiveness - MOBILE ONLY */
    /* Exception: Don't affect navbar buttons, header buttons, or buttons in specific contexts */
    .btn:not(.navbar .btn):not(.mobile-header .btn):not(.admin-mobile-header .btn):not(.card-body.d-flex.align-items-center.justify-content-between .btn):not(.table-responsive table td:last-child .btn):not(.table-responsive .simple-table td:last-child .btn) {
        width: 100%;
        margin-bottom: 0.5rem;
        padding: 0.75rem 1rem;
        font-size: 1rem;
        white-space: nowrap;
    }
    
    /* Exception: Table action buttons - keep inline and visible (HIGH PRIORITY) */
    /* Must come AFTER the general .btn rule to override it */
    .table-responsive table td:last-child .btn,
    .table-responsive table td:last-child .btn-sm,
    .table-responsive .simple-table td:last-child .btn,
    .table-responsive .simple-table td:last-child .btn-sm,
    table.table-hover td:last-child .btn,
    table.table-hover td:last-child .btn-sm,
    .simple-table td:last-child .btn,
    .simple-table td:last-child .btn-sm,
    .table-responsive table td:last-child a.btn,
    .table-responsive .simple-table td:last-child a.btn,
    .table-responsive table td:last-child button.btn,
    .table-responsive .simple-table td:last-child button.btn {
        width: auto !important;
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
        margin-right: 0.25rem !important;
        margin-bottom: 0.25rem !important;
        padding: 0.375rem 0.75rem !important;
        max-width: none !important;
        min-width: auto !important;
        flex: none !important;
    }
    
    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Exception: Small buttons in table action columns */
    .table-responsive table td:last-child .btn-sm,
    .table-responsive .simple-table td:last-child .btn-sm {
        padding: 0.375rem 0.75rem !important;
    }
    
    /* Exception: Navbar and header buttons - keep normal size */
    .navbar .btn,
    .mobile-header .btn,
    .admin-mobile-header .btn,
    .topbar .btn {
        width: auto !important;
        margin-bottom: 0;
    }
    
    .btn-group {
        width: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .btn-group .btn {
        width: 100%;
        margin-bottom: 0.5rem;
        margin-right: 0 !important;
    }
    
    /* Button groups in tables */
    .table-responsive .btn-group {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .table-responsive .btn-group .btn {
        flex: 1;
        min-width: auto;
        margin-right: 0.25rem;
        margin-bottom: 0.25rem;
    }
    
    /* Inline buttons - stack on mobile (but not in navbar/headers) */
    .d-inline .btn:not(.navbar .btn):not(.mobile-header .btn):not(.admin-mobile-header .btn),
    .d-inline-block .btn:not(.navbar .btn):not(.mobile-header .btn):not(.admin-mobile-header .btn) {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Exception: Inline buttons in table action columns */
    .table-responsive table td:last-child .d-inline .btn,
    .table-responsive table td:last-child .d-inline-block .btn,
    .table-responsive .simple-table td:last-child .d-inline .btn,
    .table-responsive .simple-table td:last-child .d-inline-block .btn {
        display: inline-block !important;
        width: auto !important;
        margin-bottom: 0;
        margin-right: 0.25rem;
    }
    
    /* Form buttons - but not in table action columns or navbar */
    form .btn:not(.navbar form .btn):not(.table-responsive table td:last-child form .btn):not(.table-responsive .simple-table td:last-child form .btn) {
        width: 100%;
    }
    
    /* Exception: Forms in table action columns */
    .table-responsive table td:last-child form .btn,
    .table-responsive .simple-table td:last-child form .btn {
        width: auto !important;
        display: inline-block !important;
        margin-bottom: 0;
        margin-right: 0.25rem;
    }
    
    /* Action buttons in cards - but not in navbar/headers */
    .card-body .btn:not(.navbar .card-body .btn):not(.table-responsive table td:last-child .btn):not(.table-responsive .simple-table td:last-child .btn),
    .card-footer .btn:not(.navbar .card-footer .btn) {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Exception: Buttons in table action columns inside cards */
    .card-body .table-responsive table td:last-child .btn,
    .card-body .table-responsive .simple-table td:last-child .btn,
    .card-body .table-responsive table td:last-child .btn-sm,
    .card-body .table-responsive .simple-table td:last-child .btn-sm {
        width: auto !important;
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
        margin-bottom: 0.25rem !important;
        margin-right: 0.25rem;
    }
    
    /* Multiple buttons in a row - stack on mobile */
    .d-flex.gap-2 .btn:not(.navbar .d-flex .btn),
    .d-flex.gap-3 .btn:not(.navbar .d-flex .btn) {
        flex: 1;
    }
    
    /* Badge adjustments */
    .badge {
        font-size: 0.75rem;
        padding: 0.35em 0.65em;
    }
    
    /* DataTables buttons */
    .dt-buttons {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .dt-buttons .btn,
    .dt-buttons button,
    .dt-buttons .dt-button {
        flex: 1;
        min-width: 120px;
        margin: 0 !important;
    }
    
    /* Simple table action buttons - ensure visibility (VERY HIGH PRIORITY) */
    .table-responsive .simple-table td:last-child .btn,
    .table-responsive .simple-table td:last-child .btn-sm,
    .table-responsive .simple-table td:last-child a.btn,
    .table-responsive .simple-table td:last-child button.btn,
    .table-responsive table td:last-child .btn,
    .table-responsive table td:last-child .btn-sm,
    .table-responsive table td:last-child a.btn,
    .table-responsive table td:last-child button.btn {
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: auto !important;
        margin-right: 0.25rem !important;
        margin-bottom: 0.25rem !important;
        padding: 0.375rem 0.75rem !important;
        flex: none !important;
        max-width: none !important;
        min-width: auto !important;
    }
    
    /* Forms in table cells - don't make buttons full width */
    .table-responsive .simple-table td:last-child form.d-inline .btn,
    .table-responsive .simple-table td:last-child form.d-inline button,
    .table-responsive table td:last-child form.d-inline .btn,
    .table-responsive table td:last-child form.d-inline button,
    .table-responsive .simple-table td:last-child form .btn,
    .table-responsive .simple-table td:last-child form button,
    .table-responsive table td:last-child form .btn,
    .table-responsive table td:last-child form button {
        display: inline-block !important;
        width: auto !important;
        margin-bottom: 0 !important;
        margin-right: 0.25rem !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex: none !important;
    }
    
    /* Links in table action columns */
    .table-responsive .simple-table td:last-child a.btn,
    .table-responsive table td:last-child a.btn,
    .table-responsive .simple-table td:last-child a.btn-sm,
    .table-responsive table td:last-child a.btn-sm {
        display: inline-block !important;
        width: auto !important;
        margin-bottom: 0 !important;
        margin-right: 0.25rem !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex: none !important;
    }
    
    /* Orders table actions - stack buttons on mobile */
    .table-responsive .simple-table td:last-child .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
    }
    
    .table-responsive .simple-table td:last-child .btn-group .btn {
        width: 100%;
        margin-bottom: 0.25rem;
    }
    
    @media (min-width: 576px) {
        .table-responsive .simple-table td:last-child .btn-group {
            flex-direction: row;
            width: auto;
        }
        
        .table-responsive .simple-table td:last-child .btn-group .btn {
            width: auto;
            margin-bottom: 0;
        }
    }
    
    /* Exception: Keep inline buttons in badges or small containers */
    .badge .btn,
    .small .btn,
    td .btn-sm:only-child {
        width: auto;
        display: inline-block;
    }
    
    /* Form actions - stack buttons (but not in navbar) */
    .form-actions .btn:not(.navbar .form-actions .btn),
    .modal-footer .btn,
    .card-footer .btn:not(.navbar .card-footer .btn) {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Exception: Modal footer buttons side by side on larger mobile */
    @media (min-width: 576px) {
        .modal-footer .btn {
            width: auto;
            margin-bottom: 0;
        }
    }
    
    /* CRITICAL: Slider table action buttons - MUST be visible (highest priority) */
    .table-responsive.simple-table-container table.simple-table td:last-child a.btn,
    .table-responsive.simple-table-container table.simple-table td:last-child button.btn,
    .table-responsive.simple-table-container table.simple-table td:last-child form.d-inline button.btn,
    .table-responsive.simple-table-container table.simple-table td:last-child form.d-inline .btn,
    .table-responsive.simple-table-container table.table-hover td:last-child a.btn,
    .table-responsive.simple-table-container table.table-hover td:last-child button.btn,
    .table-responsive.simple-table-container table.table-hover td:last-child form.d-inline button.btn,
    .table-responsive.simple-table-container table.table-hover td:last-child form.d-inline .btn {
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: auto !important;
        min-width: auto !important;
        max-width: none !important;
        flex: none !important;
        margin-right: 0.25rem !important;
        margin-bottom: 0.25rem !important;
        padding: 0.375rem 0.75rem !important;
        font-size: 0.875rem !important;
        line-height: 1.5 !important;
    }
}

/* Show admin mobile nav only on mobile */
@media (min-width: 992px) {
    .admin-mobile-header,
    .admin-mobile-bottom-nav {
        display: none !important;
    }
    
    .left-sidebar {
        display: block !important;
    }
    
    .topbar {
        display: block !important;
    }
    
    /* Desktop view - keep original header layout */
    .card-body.d-flex.align-items-center.justify-content-between,
    .card-body.d-flex.flex-column.flex-sm-row {
        flex-direction: row !important;
        align-items: center !important;
    }
    
    .card-body.d-flex.align-items-center.justify-content-between .btn,
    .card-body.d-flex.flex-column.flex-sm-row .btn {
        width: auto !important;
    }
    
    /* Override Bootstrap w-100 class on desktop */
    .card-body .btn.w-100 {
        width: auto !important;
    }
    
    /* Desktop - ensure bulk action buttons are visible and properly sized */
    .d-flex.gap-2 {
        width: auto !important;
        display: flex !important;
    }
    
    .d-flex.gap-2 .form-select,
    .d-flex.gap-2 .btn {
        width: auto !important;
        display: inline-block !important;
    }
    
    #bulkUpdateBtn {
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: auto !important;
    }
    
    /* Desktop - ensure all buttons are normal size (not full-width) */
    .btn:not(.w-100) {
        width: auto !important;
    }
    
    /* Desktop - navbar buttons normal size */
    .navbar .btn,
    .header .btn,
    .topbar .btn {
        width: auto !important;
        margin-bottom: 0 !important;
    }
    
    /* Desktop - card buttons normal size (unless explicitly w-100) */
    .card-body .btn:not(.w-100),
    .card-footer .btn:not(.w-100) {
        width: auto !important;
        margin-bottom: 0 !important;
    }
    
    /* Desktop - form buttons normal size */
    form .btn:not(.w-100) {
        width: auto !important;
        margin-bottom: 0 !important;
    }
    
    /* Desktop - inline buttons normal size */
    .d-inline .btn:not(.w-100),
    .d-inline-block .btn:not(.w-100) {
        width: auto !important;
        display: inline-block !important;
        margin-bottom: 0 !important;
    }
    
    /* Desktop - button groups normal size */
    .btn-group {
        width: auto !important;
        display: inline-flex !important;
    }
    
    .btn-group .btn {
        width: auto !important;
        margin-bottom: 0 !important;
    }
}

