/* Mobile-First Responsive Styles for Transportation Vision Web App */

/* ===== MOBILE BREAKPOINTS ===== */
/* xs: <576px (phones) */
/* sm: ≥576px (phones) */
/* md: ≥768px (tablets) */
/* lg: ≥992px (laptops) */
/* xl: ≥1200px (desktops) */

/* ===== MOBILE LOAD BOARD OPTIMIZATIONS ===== */

/* Hide desktop table on mobile */
@media (max-width: 767px) {
    .desktop-load-table {
        display: none !important;
    }
}

/* Show desktop table on tablet+ */
@media (min-width: 768px) {

    .mobile-load-cards,
    .mobile-pagination-section,
    .mobile-cards-viewport {
        display: none !important;
    }
}

/* ===== MOBILE PAGINATION SECTION ===== */
@media (max-width: 767px) {
    .mobile-pagination-section {
        padding: 0 0.5rem;
        /* Keep small padding for pagination */
        margin-bottom: 0.5rem;
    }

    .mobile-pagination-container {
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 0.5rem;
        /* Slightly smaller border radius */
        padding: 0.5rem 0.75rem;
        /* Reduced padding for more compact appearance */
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.375rem;
        /* Reduced gap */
    }

    .mobile-load-badge-container {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        /* Reduced from 0.75rem */
    }

    .mobile-load-badge-container .badge {
        font-size: 0.8rem;
        /* Reduced from 0.9rem */
        padding: 0.375rem 0.625rem;
        /* Reduced padding */
        border-radius: 0.375rem;
        /* Smaller border radius */
        font-weight: 600;
    }

    .mobile-timestamp {
        font-size: 0.7rem;
        /* Reduced from 0.8rem */
        color: #6b7280;
        display: flex;
        align-items: center;
    }

    .mobile-pagination-controls {
        display: flex;
        align-items: center;
        gap: 0.25rem;
        /* Reduced gap between buttons */
    }

    .mobile-pagination-btn {
        min-width: 32px;
        /* Reduced from 38px */
        min-height: 32px;
        /* Reduced from 38px */
        border-radius: 0.375rem;
        /* Slightly smaller border radius */
        border: 1px solid #d1d5db;
        background: #ffffff;
        color: #374151;
        font-size: 0.75rem;
        /* Reduced from 0.85rem */
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        touch-action: manipulation;
    }

    .mobile-pagination-btn:hover:not(:disabled) {
        background: #f3f4f6;
        border-color: #9ca3af;
    }

    .mobile-pagination-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    #mobile-pagination-info {
        font-size: 0.75rem;
        /* Reduced from 0.85rem to match buttons */
        color: #374151;
        font-weight: 500;
        padding: 0 0.375rem;
        /* Reduced padding to match smaller gap */
    }
}

/* ===== MOBILE CARDS VIEWPORT ===== */
@media (max-width: 767px) {
    .mobile-cards-viewport {
        padding: 0 !important;
        /* Force remove all padding */
        margin: 0 !important;
        /* Force remove all margin */
        height: calc(100vh - 200px);
        /* Adjust based on header and pagination height */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Remove Bootstrap container-fluid padding on mobile */
    .mobile-cards-viewport.container-fluid {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Remove Bootstrap row negative margins on mobile */
    .mobile-cards-viewport .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Remove Bootstrap col-12 padding on mobile */
    .mobile-cards-viewport .col-12 {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .mobile-load-cards-container {
        padding: 0 0.25rem 1rem 0.25rem;
        /* Reduced horizontal padding for more space */
    }

    .individual-load-card {
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 0.75rem;
        margin-bottom: 0.75rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease;
        overflow: hidden;
    }

    .individual-load-card:hover {
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
        transform: translateY(-1px);
    }

    /* Last card extra margin for easier scrolling */
    .individual-load-card:last-child {
        margin-bottom: 2rem;
    }
}

/* ===== MOBILE LOAD CARDS ===== */
@media (max-width: 767px) {
    .mobile-load-cards {
        padding: 0.5rem;
    }

    .load-card,
    .individual-load-card {
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 0.75rem;
        margin-bottom: 0.75rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease;
        overflow: hidden;
    }

    .load-card:hover,
    .individual-load-card:hover {
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
        transform: translateY(-1px);
    }

    .load-card-header {
        background: #f8fafc;
        border-bottom: 1px solid #e5e7eb;
        padding: 0.75rem 1rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .order-number {
        font-weight: 600;
        color: #1f2937;
        font-size: 0.95rem;
    }

    .equipment-type {
        background: #4a5568;
        /* Dark grey color */
        color: white;
        padding: 0.25rem 0.5rem;
        border-radius: 0.25rem;
        font-size: 0.75rem;
        font-weight: 500;
    }

    .load-card-body {
        padding: 0.5rem;
        /* Reduced from 1rem to give more space for content */
    }

    /* Enhanced Route Display - Map-like Layout */
    .route-display-enhanced {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        margin-bottom: 0.5rem;
        /* Reduced from 0.75rem */
        gap: 0.1rem;
        /* Reduced from 0.5rem for even tighter layout */
    }

    .origin-section,
    .destination-section {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
        /* Reduced from 0.25rem for tighter spacing */
    }

    .origin-section {
        align-items: flex-start;
    }

    .destination-section {
        align-items: flex-end;
        text-align: right;
    }

    .location-name {
        display: flex;
        align-items: center;
        font-size: 0.8rem;
        color: #374151;
        font-weight: 500;
    }

    .location-name i {
        color: #6b7280;
        margin-right: 0.375rem;
        font-size: 1rem;
    }

    .destination-section .location-name {
        flex-direction: row-reverse;
    }

    .destination-section .location-name i {
        margin-right: 0;
        margin-left: 0.375rem;
    }

    .pickup-date,
    .delivery-date {
        font-size: 0.8rem;
        color: #6b7280;
        font-weight: 500;
    }

    .travel-section {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        gap: 0.25rem;
    }

    .route-arrow {
        font-size: 1.2rem;
        color: #9ca3af;
        font-weight: bold;
        line-height: 1;
    }

    .travel-miles {
        font-size: 0.8rem;
        color: #6b7280;
        font-weight: 600;
        white-space: nowrap;
    }

    /* Legacy route display - keep for backward compatibility */
    .route-display {
        display: flex;
        align-items: center;
        margin-bottom: 0.75rem;
        font-size: 0.9rem;
        color: #374151;
    }

    .route-display i {
        color: #6b7280;
        margin-right: 0.5rem;
        font-size: 1rem;
    }

    .route-display .route-arrow {
        margin: 0 0.5rem;
        color: #9ca3af;
        font-weight: bold;
    }

    .load-meta {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
        font-size: 0.8rem;
        color: #6b7280;
    }

    .load-meta-item {
        display: flex;
        flex-direction: column;
    }

    .load-meta-label {
        font-weight: 500;
        color: #374151;
        margin-bottom: 0.1rem;
    }

    .load-card-footer {
        padding: 0.75rem 1rem;
        background: #f9fafb;
        border-top: 1px solid #e5e7eb;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .view-details-btn {
        background: #3b82f6;
        color: white;
        border: none;
        padding: 0.5rem 1rem;
        border-radius: 0.375rem;
        font-size: 0.875rem;
        font-weight: 500;
        transition: background-color 0.2s ease;
        cursor: pointer;
        touch-action: manipulation;
    }

    .view-details-btn:hover {
        background: #2563eb;
        color: white;
    }

    .load-priority {
        font-size: 0.75rem;
        color: #6b7280;
    }

    /* ===== MOBILE FILTERS OPTIMIZATION ===== */
    @media (max-width: 767px) {
        .filter-section {
            margin-bottom: 1rem;
        }

        .mobile-filter-toggle {
            width: 100%;
            background: #3b82f6;
            color: white;
            border: none;
            padding: 1rem 1.5rem;
            border-radius: 0.75rem;
            font-weight: 600;
            font-size: 1.1rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.5rem;
            touch-action: manipulation;
            box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
            transition: all 0.2s ease;
        }

        .mobile-filter-toggle:hover {
            background: #2563eb;
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
            transform: translateY(-1px);
        }

        .filter-count-badge {
            background: rgba(255, 255, 255, 0.9);
            color: #3b82f6;
            padding: 0.4rem 0.8rem;
            border-radius: 50px;
            font-size: 0.9rem;
            font-weight: 700;
            min-width: 2rem;
            text-align: center;
        }

        /* Mobile Filter Modal Specific Styles */
        .modal-fullscreen .modal-body {
            padding: 1rem;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
        }

        .modal-fullscreen .modal-header {
            padding: 1rem;
            border-bottom: 2px solid #e5e7eb;
            background: #f8fafc;
        }

        .modal-fullscreen .modal-footer {
            padding: 1rem;
            border-top: 2px solid #e5e7eb;
            background: #f8fafc;
        }

        .modal-fullscreen .form-label {
            font-weight: 600;
            color: #374151;
            margin-bottom: 0.375rem;
            font-size: 0.9rem;
        }

        .modal-fullscreen .form-control-lg,
        .modal-fullscreen .form-select-lg {
            padding: 0.6rem 0.75rem;
            font-size: 0.9rem;
            border-radius: 0.75rem;
            border: 2px solid #d1d5db;
            transition: all 0.2s ease;
        }

        .modal-fullscreen .form-control-lg:focus,
        .modal-fullscreen .form-select-lg:focus {
            border-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

        .modal-fullscreen .form-control-lg::placeholder {
            font-size: 0.85rem;
            color: #9ca3af;
        }

        .modal-fullscreen .form-range {
            height: 0.75rem;
            background: #e5e7eb;
            border-radius: 0.5rem;
            margin: 1rem 0;
        }

        .modal-fullscreen .form-range::-webkit-slider-thumb {
            width: 1.5rem;
            height: 1.5rem;
            background: #3b82f6;
            border-radius: 50%;
            border: 3px solid #ffffff;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        .modal-fullscreen .form-range::-moz-range-thumb {
            width: 1.5rem;
            height: 1.5rem;
            background: #3b82f6;
            border-radius: 50%;
            border: 3px solid #ffffff;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        .modal-fullscreen .btn-lg {
            padding: 0.75rem 1.5rem;
            font-size: 0.95rem;
            font-weight: 600;
            border-radius: 0.75rem;
            min-height: 3rem;
            touch-action: manipulation;
        }

        .modal-fullscreen h6 {
            font-size: 1.2rem;
            font-weight: 700;
            margin-bottom: 1rem;
            padding-bottom: 0.5rem;
            border-bottom: 1px solid #e5e7eb;
        }

        /* Remove old mobile filters panel styles */
        .mobile-filters-panel {
            display: none;
        }

        /* Google Places Autocomplete z-index fixes for mobile modal */
        .pac-container {
            z-index: 9999 !important;
            /* Higher than Bootstrap modal (1055) */
        }

        .pac-item {
            cursor: pointer;
            padding: 0.5rem 1rem;
            border-bottom: 1px solid #e5e7eb;
        }

        .pac-item:hover {
            background-color: #f3f4f6;
        }

        .pac-item-selected {
            background-color: #e5e7eb;
        }
    }

    /* ===== MOBILE PAGINATION ===== */
    @media (max-width: 767px) {
        .pagination-controls {
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 1rem;
            gap: 1rem;
        }

        .pagination-btn {
            padding: 0.75rem 1rem;
            font-size: 1rem;
            border-radius: 0.5rem;
            touch-action: manipulation;
            min-width: 44px;
            min-height: 44px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .pagination-info {
            font-size: 0.9rem;
            color: #6b7280;
            padding: 0 0.5rem;
        }
    }

    /* ===== MOBILE MODAL OPTIMIZATIONS ===== */
    @media (max-width: 767px) {
        .modal-dialog {
            margin: 0;
            max-width: 100%;
            height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .modal-content {
            height: 100vh;
            border-radius: 0;
            display: flex;
            flex-direction: column;
        }

        .modal-header {
            flex-shrink: 0;
            padding: 1rem;
            border-bottom: 1px solid #e5e7eb;
        }

        .modal-body {
            flex: 1;
            overflow-y: auto;
            padding: 1rem;
        }

        .modal-footer {
            flex-shrink: 0;
            padding: 1rem;
            border-top: 1px solid #e5e7eb;
        }
    }

    /* ===== TOUCH OPTIMIZATIONS ===== */
    @media (max-width: 767px) {

        /* Ensure all interactive elements meet 44px touch target minimum */
        button,
        .btn,
        a.btn,
        input[type="submit"],
        input[type="button"] {
            min-height: 44px;
            min-width: 44px;
            touch-action: manipulation;
        }

        /* Improve form control sizing for mobile */
        .form-control,
        .form-select {
            min-height: 44px;
            font-size: 16px;
            /* Prevents zoom on iOS */
        }

        /* Better spacing for mobile interactions */
        .btn-group .btn {
            margin-bottom: 0.25rem;
        }
    }

    /* ===== MOBILE LAYOUT IMPROVEMENTS ===== */
    @media (max-width: 767px) {

        /* Adjust content for mobile */
        .brokerage-page {
            padding: 0.5rem;
            padding-top: 3.5rem;
            /* More space for fixed navbar */
        }

        .admin-page {
            padding: 0.5rem;
            padding-top: 2.2rem;
            /* Less space for fixed navbar */
        }

        .page-title {
            margin-bottom: 0;
            line-height: 1.3;
            font-weight: 600;
            color: #1f2937;
        }

        /* Ensure proper spacing for mobile header - no page header to account for */
        .container-fluid.filter-section {
            margin-top: 0;
        }

        .table-section {
            margin-top: 0.5rem;
        }

        .table-card {
            border-radius: 0.5rem;
            overflow: hidden;
            margin-bottom: 1rem;
        }

        .table-card .card-header {
            padding: 0.75rem 1rem;
            background: #f8fafc;
        }

        .table-card .card-header h5 {
            font-size: 1rem;
            margin-bottom: 0;
        }

        .table-card .card-body {
            padding: 0;
        }

        /* Responsive badge sizing */
        .badge {
            font-size: 0.75rem;
            padding: 0.35em 0.65em;
        }
    }

    /* ===== LOADING STATES FOR MOBILE ===== */
    .mobile-loading {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 2rem;
        color: #6b7280;
    }

    .mobile-loading .spinner-border {
        width: 2rem;
        height: 2rem;
        margin-bottom: 1rem;
    }

    /* ===== EMPTY STATE FOR MOBILE ===== */
    .mobile-empty-state {
        text-align: center;
        padding: 2rem;
        color: #6b7280;
    }

    .mobile-empty-state i {
        font-size: 2rem;
        margin-bottom: 1rem;
        opacity: 0.5;
    }
}

/* ===== ENHANCED MOBILE CARDS ===== */
@media (max-width: 767px) {

    /* Brokerage Division Header */
    .brokerage-division-header {
        background: #f8f9fa;
        color: #495057;
        font-weight: 600;
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
        border-bottom: 1px solid #e9ecef;
        border-radius: 0.75rem 0.75rem 0 0;
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }

    /* Enhanced card layout with brokerage header */
    .individual-load-card {
        border-radius: 0.75rem;
        overflow: hidden;
    }

    /* Adjust header when brokerage division is present */
    .individual-load-card .load-card-header {
        border-radius: 0;
        /* Remove top radius since division header has it */
    }

    /* Weight information styling */
    .weight-info {
        font-size: 0.75rem;
        color: #6b7280;
        margin-top: 0.25rem;
        font-weight: 500;
    }

    /* Stops information styling */
    .stops-info {
        font-size: 0.75rem;
        color: #6b7280;
        margin-top: 0.25rem;
        font-weight: 500;
    }

    /* Enhanced footer with dual buttons */
    .load-card-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
        /* Reduced padding for mobile */
        background: #f8f9fa;
        border-top: 1px solid #e9ecef;
    }

    /* Mobile-specific load card optimizations */
    @media (max-width: 767.98px) {

        .distance-info,
        .weight-info,
        .stops-info {
            margin-top: 0.1rem;
            /* Reduced margin for tighter spacing */
            font-size: 0.7rem;
            /* Slightly smaller text */
        }

        .pickup-date,
        .delivery-date {
            font-size: 0.75rem;
            /* Slightly smaller dates */
            margin-top: 0.1rem;
        }

        .badge-distance {
            padding: 0.15rem 0.4rem;
            /* Smaller badges */
            font-size: 0.65rem;
        }

        .travel-miles {
            font-size: 0.75rem;
            /* Smaller miles display */
        }

        .route-arrow {
            font-size: 1.1rem;
            /* Smaller arrow */
        }
    }

    /* Route Map and Contact buttons */
    .route-map-btn,
    .contact-btn {
        flex: 1;
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
        border-radius: 0.5rem;
        font-weight: 500;
        text-align: center;
        border: none;
        transition: all 0.2s ease;
    }

    .route-map-btn {
        background: #0d6efd;
        color: white;
    }

    .route-map-btn:hover {
        background: #0b5ed7;
        transform: translateY(-1px);
    }

    .contact-btn {
        background: #198754;
        color: white;
    }

    .contact-btn:hover {
        background: #157347;
        transform: translateY(-1px);
    }

    /* Button icons */
    .route-map-btn i,
    .contact-btn i {
        margin-right: 0.25rem;
        font-size: 0.875rem;
    }
}

/* ===== MOBILE ROUTE MAP MODAL ===== */
@media (max-width: 767px) {

    /* Mobile route map modal specific styles */
    #mobileRouteMapModal .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100vh;
        width: 100vw;
    }

    #mobileRouteMapModal .modal-content {
        height: 100vh;
        border-radius: 0;
        border: none;
    }

    #mobileRouteMapModal .modal-header {
        background: #f8f9fa;
        border-bottom: 1px solid #dee2e6;
        padding: 1rem;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    #mobileRouteMapModal .modal-title {
        margin-bottom: 0;
        font-size: 1.1rem;
        font-weight: 600;
    }

    /* Mobile travel time badge */
    #mobile-travel-time-info {
        font-size: 0.8rem !important;
        padding: 0.4rem 0.7rem;
        border-radius: 1rem;
        white-space: nowrap;
        margin-left: auto;
        margin-right: 0.5rem;
        background: #0d6efd !important;
        color: white !important;
        border: none;
        font-weight: 500;
    }

    #mobile-travel-time-info .bi-clock {
        font-size: 0.75rem;
    }

    #mobileRouteMapModal .modal-body {
        flex: 1;
        padding: 0;
        overflow: hidden;
    }

    #mobileRouteMapModal .modal-footer {
        background: #f8f9fa;
        border-top: 1px solid #dee2e6;
        padding: 1rem;
        flex-shrink: 0;
    }

    /* Ensure map takes full height */
    #mobile-route-map {
        height: 100% !important;
        min-height: calc(100vh - 120px) !important;
        /* Account for header and footer */
        width: 100% !important;
    }

    /* Error message styling */
    #mobile-map-error {
        margin: 1rem;
        border-radius: 0.5rem;
    }
}

/* ===== MOBILE NAVIGATION SIDEBAR OPTIMIZATIONS ===== */
@media (max-width: 767px) {

    /* Optimize sidebar width for mobile screens */
    .sidebar {
        width: 280px;
        /* Slightly narrower than desktop (320px) */
        left: -280px;
        /* Update to match new width */
    }

    /* Enhanced touch targets for mobile navigation */
    .sidebar .nav-link {
        min-height: 48px;
        /* Apple recommended 44px minimum + extra for comfort */
        padding: 0.75rem 1.5rem;
        font-size: 0.95rem;
        line-height: 1.4;
        display: flex;
        align-items: center;
        transition: all 0.2s ease;
    }

    /* Improved icon spacing for mobile */
    .sidebar .nav-link i {
        width: 24px;
        /* Fixed width for consistent alignment */
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 1rem;
        font-size: 1.1rem;
        flex-shrink: 0;
    }

    /* Better mobile sidebar headings */
    .sidebar-heading {
        font-size: 0.7rem;
        padding: 0.75rem 1.5rem 0.5rem 1.5rem;
        margin-bottom: 0.25rem;
        margin-top: 1rem;
        color: #94a3b8;
        font-weight: 700;
        letter-spacing: 0.1em;
    }

    .sidebar-heading:first-child {
        margin-top: 0;
    }

    /* Enhanced mobile sidebar header */
    .sidebar-header {
        padding: 1rem 1.5rem;
        min-height: 60px;
        background: #0f172a;
    }

    .sidebar-header h5 {
        font-size: 0.9rem;
        font-weight: 600;
    }

    /* Improved close button for mobile touch */
    .sidebar-close {
        min-width: 40px;
        min-height: 40px;
        padding: 0.5rem;
        font-size: 1.1rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Fix navbar link spacing and eliminate ALL movement effects on mobile */
    .sidebar .nav-link {
        margin: 0 !important;
        /* Force no margins to prevent any movement */
        padding: 0.75rem 1rem !important;
        /* Fixed padding - no changes */
        transition: background-color 0.2s ease !important;
        /* Only animate background */
        transform: none !important;
        /* Explicitly prevent any transforms */
        border-radius: 0 !important;
        /* No border radius to avoid layout shifts */
    }

    /* Mobile-specific active state - NO MOVEMENT */
    .sidebar .nav-link.active {
        margin: 0 !important;
        /* Force no margins */
        padding: 0.75rem 1rem !important;
        /* Same padding as normal state */
        border-radius: 0 !important;
        /* No border radius */
        background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
        box-shadow: inset 4px 0 0 #ffffff !important;
        /* Left border indicator */
        transform: none !important;
        /* Force no transform */
    }

    .sidebar .nav-link.active::before {
        display: none !important;
        /* Remove any pseudo elements */
    }

    /* COMPLETELY disable hover movement effects on mobile touch devices */
    .sidebar .nav-link:hover {
        background: rgba(71, 85, 105, 0.4) !important;
        margin: 0 !important;
        /* Force no margin changes */
        padding: 0.75rem 1rem !important;
        /* Keep exact same padding */
        border-radius: 0 !important;
        /* No border radius */
        transform: none !important;
        /* Force no transform */
        box-shadow: none !important;
        /* No shadow changes */
    }

    /* Disable hover pseudo-classes on touch devices */
    @media (hover: none) and (pointer: coarse) {
        .sidebar .nav-link:hover {
            background: transparent !important;
            transform: none !important;
            margin: 0 !important;
            padding: 0.75rem 1rem !important;
        }
    }

    /* Smoother mobile animations - only for sidebar itself */
    .sidebar {
        transition: left 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    .sidebar-overlay {
        transition: opacity 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    /* Better scrolling behavior on mobile */
    .sidebar-body {
        padding: 1rem 0 2rem 0;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Ensure sidebar doesn't interfere with mobile gestures */
    .sidebar {
        touch-action: pan-y;
        /* Allow vertical scrolling but prevent horizontal gestures */
    }
}

/* ===== MOBILE USER ADMIN STEP-BY-STEP INTERFACE ===== */
@media (max-width: 767px) {
    .mobile-add-user-steps {
        position: relative;
    }

    /* Step Navigation */
    .step-navigation {
        background: rgba(var(--bs-primary-rgb), 0.1);
        padding: 1rem;
        border-radius: 0.5rem;
        margin-bottom: 1.5rem;
    }
}

/* Mobile step navigation improvements */
@media (max-width: 767.98px) {
    .step-navigation {
        background: transparent !important;
        padding: 0 !important;
        margin-bottom: 1.5rem !important;
    }

    .progress {
        height: 6px !important;
        background-color: #e5e7eb !important;
        border-radius: 3px !important;
        margin-bottom: 1rem !important;
    }

    .progress-bar {
        background: linear-gradient(90deg, #3b82f6 0%, #1d4ed8 100%) !important;
        border-radius: 3px !important;
        transition: width 0.4s ease !important;
    }

    .step-indicators {
        gap: 0.5rem !important;
    }

    .step-indicator {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        flex: 1 !important;
        padding: 0.5rem !important;
        border-radius: 0.5rem !important;
        transition: all 0.3s ease !important;
        color: #6b7280 !important;
        font-size: 0.75rem !important;
    }

    .step-indicator.active {
        background-color: #3b82f6 !important;
        /* Solid blue background */
        color: white !important;
        font-weight: 600 !important;
        border: 2px solid #3b82f6 !important;
    }

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

    .step-indicator.active i {
        color: white !important;
        /* White icons for visibility */
        font-weight: 900 !important;
        /* Bolder font weight */
        text-shadow: none !important;
    }

    /* Completed step styling */
    .step-indicator.completed {
        background-color: #22c55e !important;
        /* Solid green background */
        color: white !important;
        border: 2px solid #22c55e !important;
    }

    .step-indicator.completed i {
        color: white !important;
        /* White icons for visibility */
        font-weight: 900 !important;
    }
}

.step-indicators {
    position: relative;
}

.step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #6c757d;
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
}

.step-indicator.active {
    color: var(--bs-primary);
    font-weight: 600;
}

.step-indicator.completed {
    color: var(--bs-success);
}

.step-indicator i {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    transition: all 0.3s ease;
}

.step-indicator.active i {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
    color: white;
}

.step-indicator.completed i {
    background: var(--bs-success);
    border-color: var(--bs-success);
    color: white;
}

.step-indicator small {
    font-size: 0.7rem;
    text-align: center;
    line-height: 1.2;
    margin-top: 0.25rem;
}

/* Progress Bar */
.progress {
    height: 0.25rem;
    background-color: #e9ecef;
    border-radius: 0.25rem;
}

.progress-bar {
    background-color: var(--bs-primary);
    transition: width 0.4s ease;
}

/* Step Content */
.step-content {
    display: none;
    animation: slideIn 0.3s ease-in-out;
}

.step-content.active {
    display: block;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.step-title {
    color: var(--bs-primary);
    margin-bottom: 1rem;
    font-weight: 600;
    border-bottom: 2px solid rgba(var(--bs-primary-rgb), 0.1);
    padding-bottom: 0.5rem;
}

/* Mobile Permissions List */
.mobile-permissions-list {
    max-height: 60vh;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    background: #f8f9fa;
}

.permission-item {
    border-bottom: 1px solid #e9ecef;
    padding: 0.75rem 1rem;
    transition: background-color 0.2s ease;
}

.permission-item:last-child {
    border-bottom: none;
}

.permission-item:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.05);
}

.permission-label {
    margin-bottom: 0;
    font-weight: 500;
    line-height: 1.4;
    display: flex;
    align-items: center;
    word-wrap: break-word;
}

.permission-label small {
    margin-top: 0.25rem;
    opacity: 0.7;
}

/* ===== MOBILE ADD NEW USER COMPREHENSIVE REDESIGN ===== */

/* Mobile Card Layout Override for Add New User */
@media (max-width: 767.98px) {

    /* Remove default card padding for mobile user forms */
    .mobile-user-form .card-body {
        padding: 0 !important;
    }

    /* Create proper mobile container */
    .mobile-add-user-steps {
        padding: 1rem;
    }

    /* Step content with proper spacing */
    .step-content {
        padding: 0;
        margin-bottom: 1rem;
    }

    /* Mobile form spacing */
    .mobile-user-form .mb-3 {
        margin-bottom: 1.5rem !important;
    }

    /* Mobile optimized inputs */
    .mobile-optimized-input {
        font-size: 16px !important;
        /* Prevent zoom on iOS */
        padding: 0.75rem !important;
        border-radius: 0.5rem !important;
        border: 2px solid #e5e7eb !important;
        transition: border-color 0.2s ease !important;
    }

    .mobile-optimized-input:focus {
        border-color: #3b82f6 !important;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
    }

    /* Mobile form labels */
    .mobile-user-form .form-label {
        font-weight: 600 !important;
        color: #374151 !important;
        margin-bottom: 0.5rem !important;
        font-size: 0.875rem !important;
    }
}

/* Mobile Touch Targets - Complete Redesign */
.mobile-touch-target {
    min-height: 56px !important;
    /* Larger touch target */
    display: flex !important;
    align-items: center !important;
    padding: 0.75rem 0 !important;
    /* Remove horizontal padding, use vertical */
    background: transparent !important;
    border-radius: 0.5rem !important;
    transition: background-color 0.2s ease !important;
    position: relative !important;
    width: 100% !important;
}

.mobile-touch-target:hover {
    background-color: rgba(59, 130, 246, 0.05) !important;
}

/* Mobile checkbox styling */
.mobile-touch-target .form-check-input {
    margin-top: 0 !important;
    margin-right: 0.75rem !important;
    margin-left: 0 !important;
    transform: scale(1.1) !important;
    /* Consistent smaller scale */
    border: 2px solid #d1d5db !important;
    border-radius: 0.375rem !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
    /* Prevent checkbox from shrinking */
}

.mobile-touch-target .form-check-input:checked {
    background-color: #3b82f6 !important;
    border-color: #3b82f6 !important;
}

.mobile-touch-target .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
}

/* Mobile checkbox labels */
.mobile-touch-target .form-check-label {
    margin-bottom: 0 !important;
    font-size: 1rem !important;
    line-height: 1.5 !important;
    color: #374151 !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    flex-grow: 1 !important;
    padding-right: 0.5rem !important;
    /* Ensure text doesn't touch right edge */
}

/* Step Navigation Buttons */
.step-navigation-buttons {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 1rem 0;
    border-top: 1px solid #dee2e6;
    margin: 1rem -1rem -1rem -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Mobile-optimized card layout for Add New User */
@media (max-width: 767.98px) {

    /* Remove Bootstrap card constraints for mobile user form */
    .mobile-user-form .admin-card {
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    .mobile-user-form .admin-card .card-header {
        background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%) !important;
        border: none !important;
        color: white !important;
        border-radius: 0.75rem 0.75rem 0 0 !important;
        padding: 1rem 1.25rem !important;
    }

    .mobile-user-form .admin-card .card-header h6 {
        color: white !important;
        font-weight: 700 !important;
        margin: 0 !important;
    }

    .mobile-user-form .admin-card .card-header i {
        color: rgba(255, 255, 255, 0.9) !important;
    }

    .mobile-user-form .admin-card .card-body {
        background: white !important;
        border-radius: 0 0 0.75rem 0.75rem !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
        min-height: 60vh !important;
        /* Ensure enough space */
        position: relative !important;
    }
}

.mobile-button {
    min-height: 48px;
    font-weight: 600;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

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

/* Review Content */
.review-content {
    background: #f8f9fa;
    border-radius: 0.5rem;
    padding: 1rem;
}

.review-section {
    background: white;
    border-radius: 0.375rem;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.review-heading {
    color: var(--bs-primary);
    margin-bottom: 0.75rem;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mobile permissions list styling */
@media (max-width: 767.98px) {
    .mobile-permissions-list {
        background: transparent !important;
        /* Remove background container */
        border-radius: 0 !important;
        padding: 0 !important;
        /* Remove padding */
        margin: 0 !important;
        /* Remove margin */
        max-height: 50vh !important;
        /* Limit height to prevent excessive scrolling */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        /* Smooth scrolling on iOS */
    }

    .permission-item {
        background: transparent !important;
        /* Remove white background */
        border: none !important;
        /* Remove border */
        border-radius: 0 !important;
        /* Remove border radius */
        margin-bottom: 0.375rem !important;
        box-shadow: none !important;
        /* Remove shadow */
        overflow: hidden !important;
    }

    .permission-item .mobile-touch-target {
        padding: 0.75rem !important;
        /* Reduced from 1rem */
        min-height: 48px !important;
        /* Reduced from 64px */
        border-radius: 0.5rem !important;
    }

    .permission-item .mobile-touch-target:hover {
        background-color: rgba(59, 130, 246, 0.05) !important;
    }

    .permission-item .form-check-input {
        transform: scale(1.1) !important;
        /* Reduced from 1.3 */
        margin-right: 0.75rem !important;
        margin-top: 0 !important;
        flex-shrink: 0 !important;
    }

    .permission-label {
        display: flex !important;
        flex-direction: row !important;
        /* Changed from column to row */
        align-items: center !important;
        /* Changed from flex-start to center */
        flex-grow: 1 !important;
        line-height: 1.4 !important;
    }

    .permission-label i {
        color: #6b7280 !important;
        margin-right: 0.5rem !important;
        font-size: 1rem !important;
        flex-shrink: 0 !important;
        width: 1.25rem !important;
        /* Fixed width for alignment */
        text-align: center !important;
    }

    .permission-label .permission-text {
        display: flex !important;
        flex-direction: column !important;
        flex-grow: 1 !important;
    }

    .permission-label small {
        margin-top: 0.125rem !important;
        /* Reduced spacing */
        color: #6b7280 !important;
        font-size: 0.7rem !important;
        /* Slightly smaller */
        line-height: 1.2 !important;
    }

    /* Mobile validation and error styling */
    .mobile-add-user-steps .text-danger {
        font-size: 0.8rem !important;
        margin-top: 0.375rem !important;
        padding: 0.5rem 0.75rem !important;
        background-color: rgba(220, 53, 69, 0.1) !important;
        border-left: 3px solid #dc3545 !important;
        border-radius: 0.25rem !important;
        line-height: 1.4 !important;
        display: none !important;
        /* Hide validation errors initially */
    }

    /* Only show validation errors after form interaction */
    .mobile-add-user-steps .field-validation-error,
    .mobile-add-user-steps .was-validated .text-danger,
    .mobile-add-user-steps .show-validation .text-danger {
        display: block !important;
    }

    .mobile-add-user-steps .is-invalid {
        border-color: #dc3545 !important;
        background-color: rgba(220, 53, 69, 0.05) !important;
    }

    .mobile-add-user-steps .is-invalid:focus {
        border-color: #dc3545 !important;
        box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2) !important;
    }

    /* Step title styling */
    .step-title {
        color: #1f2937 !important;
        font-weight: 700 !important;
        font-size: 1.125rem !important;
        margin-bottom: 1rem !important;
        padding-bottom: 0.5rem !important;
        border-bottom: 2px solid #e5e7eb !important;
    }

    /* Mobile review section optimization */
    .review-item {
        padding: 0.375rem 0 !important;
        /* Reduced padding */
        margin-bottom: 0.375rem !important;
        /* Reduced margin */
    }

    .review-item strong {
        font-size: 0.8rem !important;
        /* Smaller label font */
        min-width: auto !important;
        /* Let it be flexible */
        white-space: nowrap !important;
        /* Keep labels on one line */
    }

    .review-item span {
        font-size: 0.8rem !important;
        /* Smaller value font */
        font-weight: 400 !important;
        /* Less bold to save space */
        line-height: 1.2 !important;
        /* Tighter line height */
    }
}

.review-item {
    display: flex;
    align-items: flex-start;
    /* Changed from center to flex-start */
    padding: 0.5rem 0;
    border-bottom: 1px solid #f1f3f4;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
    /* Add gap between label and value */
}

.review-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.review-item strong {
    color: #495057;
    font-size: 0.9rem;
    flex-shrink: 0;
    /* Prevent label from shrinking */
    min-width: fit-content;
    /* Only take space needed */
}

.review-item span {
    color: #212529;
    font-weight: 500;
    font-size: 0.85rem;
    /* Slightly smaller font */
    flex-grow: 1;
    /* Take remaining space */
    text-align: right;
    word-break: break-all;
    /* Break long emails properly */
    overflow-wrap: break-word;
    hyphens: none;
    /* Disable hyphenation */
}

.review-permissions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.review-permission-badge {
    background: rgba(var(--bs-primary-rgb), 0.1);
    color: var(--bs-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Mobile Optimized Inputs */
.mobile-optimized-input {
    min-height: 48px;
    font-size: 16px;
    /* Prevents zoom on iOS */
    border-radius: 0.5rem;
    border: 2px solid #dee2e6;
    transition: all 0.2s ease;
}

.mobile-optimized-input:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Enhanced Error States for Mobile */
.mobile-add-user-steps .text-danger {
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

.mobile-add-user-steps .is-invalid {
    border-color: #dc3545;
}

.mobile-add-user-steps .is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Responsive Adjustments for Mobile Steps */
@media (max-width: 575px) {
    .step-navigation {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }

    .step-indicator i {
        width: 2rem;
        height: 2rem;
        font-size: 1rem;
    }

    .step-indicator small {
        font-size: 0.65rem;
    }

    .mobile-permissions-list {
        max-height: 50vh;
    }

    .permission-item {
        padding: 0.625rem 0.75rem;
    }

    .review-content {
        padding: 0.75rem;
    }

    .review-section {
        padding: 0.75rem;
    }

    .step-navigation-buttons {
        margin: 0.75rem -0.75rem -0.75rem -0.75rem;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* ===== MOBILE EDIT USER MODAL ===== */
@media (max-width: 575.98px) {
    .mobile-edit-modal {
        border-radius: 0;
        border: none;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    /* Mobile Modal Header */
    .mobile-modal-header {
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        border-bottom: 2px solid #dee2e6;
        padding: 1.25rem 1rem;
        flex-shrink: 0;
        border-radius: 0;
    }

    .modal-icon {
        width: 40px;
        height: 40px;
        background: rgba(var(--bs-primary-rgb), 0.1);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .modal-icon i {
        font-size: 1.5rem;
    }

    .mobile-close-btn {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease;
    }

    .mobile-close-btn:hover {
        background: rgba(0, 0, 0, 0.2);
        transform: scale(1.05);
    }

    /* Mobile Modal Body */
    .mobile-modal-body {
        flex: 1;
        padding: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: #f8f9fa;
    }

    /* Mobile Form Sections */
    .mobile-form-section {
        background: white;
        margin-bottom: 0.75rem;
        border-radius: 0;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    .mobile-section-title {
        background: #f8f9fa;
        padding: 1rem 1.25rem 0.75rem 1.25rem;
        margin: 0;
        font-weight: 600;
        color: #495057;
        border-bottom: 1px solid #e9ecef;
        font-size: 0.95rem;
        display: flex;
        align-items: center;
        letter-spacing: 0.025em;
    }

    .mobile-section-title i {
        color: var(--bs-primary);
    }

    /* Mobile Form Groups */
    .mobile-form-group {
        padding: 1.25rem;
        border-bottom: 1px solid #f1f3f4;
    }

    .mobile-form-group:last-child {
        border-bottom: none;
    }

    .mobile-form-label {
        font-weight: 600;
        color: #374151;
        margin-bottom: 0.75rem;
        display: block;
        font-size: 0.95rem;
        letter-spacing: 0.025em;
    }

    /* Mobile Input Container */
    .mobile-input-container {
        position: relative;
        margin-bottom: 0.5rem;
    }

    .mobile-edit-input {
        min-height: 52px;
        font-size: 16px;
        /* Prevents zoom on iOS */
        border: 2px solid #e1e5e9;
        border-radius: 0.75rem;
        padding: 0.75rem 1rem 0.75rem 3rem;
        background: #fafbfc;
        transition: all 0.3s ease;
        font-weight: 500;
    }

    .mobile-edit-input:focus {
        border-color: var(--bs-primary);
        background: white;
        box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.1);
        outline: none;
    }

    .mobile-edit-input::placeholder {
        color: #9ca3af;
        font-weight: 400;
    }

    .input-icon {
        position: absolute;
        left: 1rem;
        top: 50%;
        transform: translateY(-50%);
        color: #6b7280;
        font-size: 1.1rem;
        pointer-events: none;
        transition: color 0.3s ease;
    }

    .mobile-edit-input:focus+.input-icon {
        color: var(--bs-primary);
    }

    /* Mobile Error Text */
    .mobile-error-text {
        color: #dc3545;
        font-size: 0.875rem;
        margin-top: 0.25rem;
        display: block;
        font-weight: 500;
    }

    /* Mobile Toggle Card */
    .mobile-toggle-card {
        background: #f8f9fa;
        border: 2px solid #e9ecef;
        border-radius: 0.75rem;
        overflow: hidden;
        transition: all 0.3s ease;
    }

    .mobile-toggle-card:hover {
        border-color: rgba(var(--bs-primary-rgb), 0.3);
        box-shadow: 0 2px 8px rgba(var(--bs-primary-rgb), 0.1);
    }

    .mobile-toggle-content {
        padding: 1rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .mobile-toggle-info {
        flex: 1;
        margin-right: 1rem;
    }

    .mobile-toggle-label {
        font-weight: 600;
        color: #374151;
        margin-bottom: 0.25rem;
        display: block;
        font-size: 1rem;
    }

    .mobile-toggle-description {
        color: #6b7280;
        font-size: 0.875rem;
        line-height: 1.4;
        margin: 0;
    }

    /* Mobile Switch Styling */
    .mobile-toggle-switch {
        flex-shrink: 0;
    }

    .mobile-switch-input {
        display: none;
    }

    .mobile-switch-label {
        display: block;
        width: 52px;
        height: 28px;
        background: #e5e7eb;
        border-radius: 14px;
        cursor: pointer;
        transition: all 0.3s ease;
        position: relative;
        margin: 0;
    }

    .mobile-switch-slider {
        position: absolute;
        top: 2px;
        left: 2px;
        width: 24px;
        height: 24px;
        background: white;
        border-radius: 50%;
        transition: all 0.3s ease;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    .mobile-switch-input:checked+.mobile-switch-label {
        background: var(--bs-primary);
    }

    .mobile-switch-input:checked+.mobile-switch-label .mobile-switch-slider {
        transform: translateX(24px);
    }

    .mobile-switch-label:active .mobile-switch-slider {
        width: 28px;
    }

    /* Mobile Admin Notice */
    .mobile-admin-notice {
        background: rgba(var(--bs-primary-rgb), 0.1);
        border-top: 1px solid rgba(var(--bs-primary-rgb), 0.2);
        padding: 0.75rem 1rem;
        color: var(--bs-primary);
        font-size: 0.875rem;
        display: flex;
        align-items: center;
        font-weight: 500;
    }

    /* Mobile Permissions Preview */
    .mobile-permissions-preview {
        background: #f8f9fa;
        border: 1px solid #e9ecef;
        border-radius: 0.5rem;
        padding: 1rem;
    }

    .permission-badges-container {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 1rem;
        min-height: 2rem;
    }

    .permission-preview-badge {
        background: rgba(var(--bs-primary-rgb), 0.1);
        color: var(--bs-primary);
        padding: 0.4rem 0.75rem;
        border-radius: 1rem;
        font-size: 0.8rem;
        font-weight: 500;
        border: 1px solid rgba(var(--bs-primary-rgb), 0.2);
    }

    .mobile-manage-permissions-btn {
        width: 100%;
        min-height: 44px;
        border-radius: 0.5rem;
        font-weight: 600;
        font-size: 0.9rem;
        transition: all 0.2s ease;
    }

    .mobile-manage-permissions-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(var(--bs-primary-rgb), 0.2);
    }

    /* Mobile Modal Footer */
    .mobile-modal-footer {
        background: white;
        border-top: 2px solid #e9ecef;
        padding: 1.25rem;
        flex-shrink: 0;
        border-radius: 0;
    }

    .mobile-action-buttons {
        display: flex;
        gap: 1rem;
    }

    .mobile-action-btn {
        flex: 1;
        min-height: 52px;
        font-weight: 600;
        font-size: 1rem;
        border-radius: 0.75rem;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-cancel-btn {
        background: #f8f9fa;
        border: 2px solid #e9ecef;
        color: #6c757d;
    }

    .mobile-cancel-btn:hover {
        background: #e9ecef;
        border-color: #adb5bd;
        color: #495057;
        transform: translateY(-1px);
    }

    .mobile-save-btn {
        background: var(--bs-primary);
        border: 2px solid var(--bs-primary);
        box-shadow: 0 2px 8px rgba(var(--bs-primary-rgb), 0.3);
    }

    .mobile-save-btn:hover {
        background: var(--bs-primary);
        border-color: var(--bs-primary);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(var(--bs-primary-rgb), 0.4);
    }

    .mobile-action-btn:active {
        transform: scale(0.98);
    }

    /* Mobile Alert Styling */
    .mobile-alert {
        margin: 1rem;
        border-radius: 0.75rem;
        border: none;
        padding: 1rem;
        font-weight: 500;
    }

    /* Responsive Adjustments for Extra Small Screens */
    @media (max-width: 575px) {
        .mobile-modal-header {
            padding: 1rem;
        }

        .modal-icon {
            width: 36px;
            height: 36px;
        }

        .modal-icon i {
            font-size: 1.25rem;
        }

        .mobile-close-btn {
            width: 36px;
            height: 36px;
        }

        .mobile-form-group {
            padding: 1rem;
        }

        .mobile-edit-input {
            min-height: 48px;
            padding: 0.625rem 0.875rem 0.625rem 2.75rem;
        }

        .input-icon {
            left: 0.875rem;
            font-size: 1rem;
        }

        .mobile-toggle-content {
            padding: 0.875rem;
        }

        .mobile-switch-label {
            width: 48px;
            height: 26px;
            border-radius: 13px;
        }

        .mobile-switch-slider {
            width: 22px;
            height: 22px;
        }

        .mobile-switch-input:checked+.mobile-switch-label .mobile-switch-slider {
            transform: translateX(22px);
        }

        .mobile-action-btn {
            min-height: 48px;
            font-size: 0.95rem;
        }

        .mobile-modal-footer {
            padding: 1rem;
        }
    }

    /* ===== MOBILE PERMISSIONS MODAL ===== */
    @media (max-width: 575.98px) {
        .mobile-permissions-modal {
            border-radius: 0;
            border: none;
            height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .mobile-permissions-header {
            background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
            border-bottom: 2px solid #f1c40f;
            padding: 1.25rem 1rem;
            flex-shrink: 0;
            border-radius: 0;
        }

        .mobile-permissions-header .modal-icon {
            background: rgba(255, 193, 7, 0.2);
        }

        .mobile-permissions-body {
            flex: 1;
            padding: 0;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            background: #f8f9fa;
        }

        /* Admin Status Notice */
        .admin-status-notice {
            background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
            border: 1px solid #b6d4da;
            margin: 1rem;
            border-radius: 0.75rem;
            overflow: hidden;
        }

        .notice-content {
            padding: 1rem;
            display: flex;
            align-items: flex-start;
        }

        .notice-icon {
            font-size: 1.5rem;
            color: #0c5460;
            margin-right: 0.75rem;
            flex-shrink: 0;
            margin-top: 0.125rem;
        }

        .notice-text strong {
            color: #0c5460;
            font-size: 1rem;
            display: block;
            margin-bottom: 0.25rem;
        }

        .notice-text p {
            color: #0c5460;
            margin: 0;
            font-size: 0.875rem;
            opacity: 0.8;
        }

        /* Permissions Container */
        .permissions-container {
            padding: 0 1rem 1rem 1rem;
        }

        /* Permission Category */
        .permission-category {
            background: white;
            border-radius: 0.75rem;
            margin-bottom: 1rem;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
            overflow: hidden;
        }

        .category-header {
            background: #f8f9fa;
            border-bottom: 1px solid #e9ecef;
            padding: 1rem 1.25rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .category-title {
            display: flex;
            align-items: center;
            font-weight: 600;
            color: #495057;
            font-size: 1rem;
        }

        .category-title i {
            color: var(--bs-primary);
            font-size: 1.1rem;
        }

        .toggle-category-btn {
            font-size: 0.8rem;
            padding: 0.375rem 0.75rem;
            border-radius: 1rem;
            font-weight: 500;
            transition: all 0.2s ease;
        }

        .toggle-category-btn:hover {
            transform: translateY(-1px);
        }

        /* Permission Items */
        .permission-items {
            padding: 0.5rem;
        }

        .permission-item-card {
            display: flex;
            align-items: center;
            padding: 1rem;
            border-radius: 0.5rem;
            margin-bottom: 0.5rem;
            transition: all 0.2s ease;
            background: #fafbfc;
            border: 1px solid #f1f3f4;
        }

        .permission-item-card:hover {
            background: rgba(var(--bs-primary-rgb), 0.02);
            border-color: rgba(var(--bs-primary-rgb), 0.1);
        }

        .permission-item-card:last-child {
            margin-bottom: 0;
        }

        /* Permission Toggle Switch */
        .permission-toggle {
            margin-right: 1rem;
            flex-shrink: 0;
        }

        .mobile-permission-checkbox {
            display: none;
        }

        .permission-toggle-label {
            display: block;
            width: 48px;
            height: 26px;
            background: #e5e7eb;
            border-radius: 13px;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            margin: 0;
        }

        .toggle-slider {
            position: absolute;
            top: 2px;
            left: 2px;
            width: 22px;
            height: 22px;
            background: white;
            border-radius: 50%;
            transition: all 0.3s ease;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }

        .mobile-permission-checkbox:checked+.permission-toggle-label {
            background: #22c55e;
        }

        .mobile-permission-checkbox:checked+.permission-toggle-label .toggle-slider {
            transform: translateX(22px);
        }

        .permission-toggle-label:active .toggle-slider {
            width: 26px;
        }

        /* Permission Info */
        .permission-info {
            display: flex;
            align-items: center;
            flex: 1;
            min-width: 0;
        }

        .permission-icon {
            width: 40px;
            height: 40px;
            border-radius: 0.5rem;
            background: rgba(var(--bs-primary-rgb), 0.1);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 1rem;
            flex-shrink: 0;
        }

        .permission-icon i {
            font-size: 1.25rem;
            color: var(--bs-primary);
        }

        .permission-icon.admin-icon {
            background: rgba(255, 193, 7, 0.1);
        }

        .permission-icon.admin-icon i {
            color: #f39c12;
        }

        .permission-details {
            flex: 1;
            min-width: 0;
        }

        .permission-name {
            font-weight: 600;
            color: #374151;
            font-size: 0.95rem;
            display: block;
            margin-bottom: 0.25rem;
            line-height: 1.3;
        }

        .permission-description {
            color: #6b7280;
            font-size: 0.8rem;
            line-height: 1.3;
            margin: 0;
        }

        .auto-managed-text {
            color: #f39c12;
            font-weight: 500;
        }

        /* Selection Summary */
        .selection-summary {
            background: white;
            margin: 0 1rem 1rem 1rem;
            border-radius: 0.75rem;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
            overflow: hidden;
        }

        .summary-header {
            background: #f8f9fa;
            border-bottom: 1px solid #e9ecef;
            padding: 0.75rem 1rem;
            font-weight: 600;
            color: #495057;
            display: flex;
            align-items: center;
            font-size: 0.9rem;
        }

        .summary-header i {
            color: var(--bs-success);
        }

        .summary-content {
            padding: 1rem;
        }

        .summary-stats {
            margin-bottom: 0.75rem;
            text-align: center;
        }

        .stat-item {
            color: #374151;
            font-size: 0.9rem;
        }

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

        .summary-actions button {
            flex: 1;
            font-size: 0.8rem;
            padding: 0.5rem;
            border-radius: 0.5rem;
            font-weight: 500;
        }

        /* Mobile Permissions Footer */
        .mobile-permissions-footer {
            background: white;
            border-top: 2px solid #e9ecef;
            padding: 1.25rem;
            flex-shrink: 0;
            border-radius: 0;
        }

        .mobile-save-permissions-btn {
            background: var(--bs-success);
            border: 2px solid var(--bs-success);
            box-shadow: 0 2px 8px rgba(var(--bs-success-rgb), 0.3);
        }

        .mobile-save-permissions-btn:hover {
            background: var(--bs-success);
            border-color: var(--bs-success);
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(var(--bs-success-rgb), 0.4);
        }

        /* Disabled Permission Items */
        .permission-item-card.disabled {
            opacity: 0.6;
            background: #f8f9fa;
        }

        .permission-item-card.disabled .permission-toggle-label {
            cursor: not-allowed;
            background: #e5e7eb;
        }

        .permission-item-card.disabled .mobile-permission-checkbox:checked+.permission-toggle-label {
            background: #6b7280;
        }

        /* Responsive Adjustments for Permissions Modal */
        @media (max-width: 575px) {
            .mobile-permissions-header {
                padding: 1rem;
            }

            .category-header {
                padding: 0.875rem 1rem;
                flex-direction: column;
                gap: 0.5rem;
                align-items: stretch;
            }

            .category-title {
                justify-content: center;
                font-size: 0.95rem;
            }

            .toggle-category-btn {
                align-self: center;
                font-size: 0.75rem;
                padding: 0.25rem 0.5rem;
            }

            .permission-item-card {
                padding: 0.875rem;
            }

            .permission-icon {
                width: 36px;
                height: 36px;
                margin-right: 0.75rem;
            }

            .permission-icon i {
                font-size: 1.1rem;
            }

            .permission-name {
                font-size: 0.9rem;
            }

            .permission-description {
                font-size: 0.75rem;
            }

            .permission-toggle-label {
                width: 44px;
                height: 24px;
                border-radius: 12px;
            }

            .toggle-slider {
                width: 20px;
                height: 20px;
            }

            .mobile-permission-checkbox:checked+.permission-toggle-label .toggle-slider {
                transform: translateX(20px);
            }

            .summary-content {
                padding: 0.75rem;
            }

            .summary-actions {
                flex-direction: column;
            }

            .mobile-permissions-footer {
                padding: 1rem;
            }
        }

/* ===== SHARED MOBILE UTILITIES ===== */

/* Horizontal scroll wrapper for tables on mobile */
@media (max-width: 767px) {
    .table-scroll-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Ensure all interactive elements meet 44px minimum touch target */
    .touch-target-44 {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Prevent text inputs from triggering iOS zoom (must be ≥16px) */
    input[type="text"],
    input[type="email"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px;
    }

    /* Hide scrollbars on scroll wrappers (cleaner mobile look) */
    .table-scroll-wrapper::-webkit-scrollbar {
        height: 3px;
    }
    .table-scroll-wrapper::-webkit-scrollbar-track {
        background: transparent;
    }
    .table-scroll-wrapper::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.15);
        border-radius: 3px;
    }
}