/* Enhanced Mobile-First CSS for TimeTracker */

/* Mobile-specific variables */
/* Force mobile dropdown styles with high specificity */
:root {
    --mobile-touch-target: 52px;
    --mobile-nav-height: 70px;
    --mobile-tabbar-height: 64px;
    --mobile-card-padding: 1.25rem;
    --mobile-button-height: 52px;
    --mobile-input-height: 56px;
    --mobile-section-spacing: 1.5rem;
    --mobile-card-spacing: 1rem;
    --mobile-border-radius: 4px;
    --mobile-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --mobile-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Enhanced Mobile-specific improvements - Modern Touch Interface */
@media (max-width: 768px) {
    /* Prevent content from being hidden behind the tab bar */
    main {
        padding-bottom: calc(var(--mobile-section-spacing) + var(--mobile-tabbar-height) + env(safe-area-inset-bottom));
        padding-top: 1rem;
        scroll-padding-top: var(--mobile-nav-height);
    }
    
    /* Improved body padding for mobile with safe areas */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        overscroll-behavior: none;
        -webkit-overflow-scrolling: touch;
    }

    /* Container improvements */
    .container, .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
        max-width: 100%;
    }
    
    /* Enhanced Row and Column Layout */
    .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        margin-bottom: var(--mobile-card-spacing);
    }
    
    .col:last-child {
        margin-bottom: 0;
    }
    
    /* Enhanced Card Layout - Modern Mobile Design */
    .card {
        margin-bottom: var(--mobile-card-spacing);
        border-radius: var(--border-radius);
        box-shadow: var(--mobile-shadow);
        border: 1px solid var(--border-color);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: var(--card-bg);
        overflow: hidden;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .card:hover,
    .card:active {
        box-shadow: var(--mobile-shadow-hover);
        transform: translateY(-2px) scale(1.01);
        border-color: var(--primary-200);
    }
    
    .card:active {
        transform: translateY(0) scale(0.99);
        transition: all 0.15s ease;
        opacity: 0.95;
    }
    
    .card-body {
        padding: var(--mobile-card-padding);
    }
    
    .card-header {
        padding: 1.25rem var(--mobile-card-padding);
        border-bottom: 1px solid var(--border-color);
        background: var(--light-color);
    }
    
    /* Enhanced Button Layout - Modern Touch Interface */
    .btn {
        min-height: var(--mobile-button-height);
        padding: 1rem 1.5rem;
        font-size: 1rem;
        border-radius: var(--border-radius);
        font-weight: var(--font-weight-medium);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        -webkit-tap-highlight-color: transparent;
        width: 100%;
        margin-bottom: 0.75rem;
        gap: 0.5rem;
        position: relative;
        overflow: hidden;
        touch-action: manipulation;
        user-select: none;
        font-family: var(--font-family-sans);
        letter-spacing: 0.025em;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    /* Enhanced button interactions */
    .btn::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.3);
        transform: translate(-50%, -50%);
        transition: width 0.6s, height 0.6s;
        z-index: 0;
    }
    
    .btn:active::before {
        width: 300px;
        height: 300px;
    }
    
    .btn > * {
        position: relative;
        z-index: 1;
    }
    
    .btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }
    
    .btn:active {
        transform: translateY(0) scale(0.98);
        transition: all 0.15s ease;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    }
    
    /* Enhanced touch feedback */
    @media (hover: none) and (pointer: coarse) {
        .btn:active {
            background-color: var(--surface-pressed);
            transform: scale(0.95);
        }
        
        .btn-primary:active {
            background: var(--primary-700);
        }
    }
    
    /* icon colors inherit from base button styles */
    
    .btn:last-child {
        margin-bottom: 0;
    }
    
    .btn-sm {
        min-height: 44px;
        padding: 0.875rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .btn-sm:hover {
        background: #f3f4f6;
        border-color: #4b5563;
        color: #4b5563;
    }
    
    .btn-lg {
        min-height: 60px;
        padding: 1.25rem 2rem;
        font-size: 1.125rem;
    }
    
    .btn-lg:hover {
        background: #f3f4f6;
        border-color: #4b5563;
        color: #4b5563;
    }
    
    /* Enhanced Button Group Layout */
    .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }
    
    .btn-group .btn {
        border-radius: var(--mobile-border-radius) !important;
        margin-bottom: 0;
        width: 100%;
    }
    
    /* Enhanced Form Layout */
    .form-control, .form-select {
        min-height: var(--mobile-input-height);
        padding: 1rem 1.25rem;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: var(--mobile-border-radius);
        border: 1px solid var(--border-color);
        transition: all 0.3s ease;
        background: var(--bs-body-bg, #ffffff);
        width: 100%;
    }
    
    .form-control:focus, .form-select:focus {
        border-color: #6b7280; /* consistent grey focus from base */
        box-shadow: 0 0 0 4px rgba(107, 114, 128, 0.1);
        outline: none;
        transform: translateY(-1px);
    }
    
    .form-label {
        font-weight: 600;
        color: var(--text-primary);
        margin-bottom: 0.75rem;
        font-size: 0.95rem;
        display: block;
    }
    
    .form-text {
        font-size: 0.875rem;
        color: var(--text-muted);
        margin-top: 0.5rem;
    }
    
    /* Enhanced Table Layout for Mobile */
    .table-responsive {
        border: none;
        border-radius: var(--mobile-border-radius);
        overflow: visible !important; /* Allow dropdowns to overflow */
        margin-bottom: var(--mobile-card-spacing);
    }
    
    .table {
        display: block;
        width: 100%;
        margin-bottom: 0;
    }
    
    .table thead {
        display: none;
    }
    
    .table tbody {
        display: block;
        width: 100%;
    }
    
    .table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--mobile-border-radius);
        background: var(--bs-card-bg, #ffffff);
        box-shadow: var(--mobile-shadow);
        overflow: hidden;
        transition: all 0.3s ease;
    }
    
    .table tr:hover {
        box-shadow: var(--mobile-shadow-hover);
        transform: translateY(-1px);
    }
    
    .table td {
        display: block;
        text-align: left;
        padding: 1rem;
        border: none;
        border-bottom: 1px solid var(--border-color);
        position: relative;
        background: var(--bs-card-bg, #ffffff);
    }
    
    .table td:last-child {
        border-bottom: none;
    }
    
    .table td:before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: var(--text-primary);
        display: block;
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--text-muted);
    }
    
    .table td.actions-cell {
        text-align: left;
        padding: 1rem;
        background: var(--light-color);
    }
    
    .table td.actions-cell:before {
        display: block;
    }
    
    /* Enhanced Navigation Layout - Modern Mobile Glass Effect */
    .navbar {
        min-height: var(--mobile-nav-height);
        padding: 0.75rem 0;
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        border-bottom: 1px solid var(--border-light);
        position: sticky;
        top: 0;
        z-index: var(--z-fixed);
    }
    
    .navbar-brand {
        font-size: 1.25rem;
        font-weight: 700;
    }
    
    .navbar-toggler {
        border: none;
        padding: 0.5rem;
        min-height: var(--mobile-touch-target);
        min-width: var(--mobile-touch-target);
        border-radius: var(--mobile-border-radius);
        background: #f8fafc;
    }
    
    .navbar-toggler:focus {
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    }
    
    .navbar-collapse {
        background: var(--bs-body-bg, #ffffff);
        border-top: 1px solid var(--border-color);
        margin-top: 0.75rem;
        padding: 1rem 0;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
        border-radius: 0;
        position: relative;
        z-index: 1100; /* above page content */
    }
    
    .navbar-nav .nav-link {
        padding: 1rem 1.5rem;
        margin: 0.25rem 0;
        border-radius: 0;
        font-size: 1.1rem;
        min-height: var(--mobile-touch-target);
        display: flex;
        align-items: center;
        gap: 0.75rem;
        transition: all 0.3s ease;
    }
    
    .navbar-nav .nav-link:hover {
        background: var(--light-color);
        transform: translateX(4px);
    }
    
    .navbar-nav .nav-link.active {
        background: #6b7280;
        color: #ffffff !important;
        box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
    }
    
    .navbar-nav .nav-link i {
        width: 24px;
        text-align: center;
        font-size: 1.1rem;
    }
    
    /* Enhanced Dropdown Layout (navbar only) */
    .navbar .dropdown-menu {
        position: static !important;
        float: none;
        width: 100%;
        margin: 0;
        border: 1px solid var(--border-color) !important;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25) !important;
        background: var(--bs-dropdown-bg, #ffffff) !important;
        background-color: var(--bs-dropdown-bg, #ffffff) !important; /* ensure solid bg */
        border-radius: var(--mobile-border-radius);
        margin-top: 0.75rem;
        padding: 0.75rem 0.25rem; /* Add padding to prevent outline clipping */
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        isolation: isolate; /* prevent blending with backdrop */
        z-index: 9999 !important;
        overflow: visible !important; /* Allow outlines to show */
    }
    
    /* Ensure table dropdowns work properly on mobile */
    .table .dropdown-menu {
        position: absolute !important;
        z-index: 1070 !important;
        width: auto !important;
        min-width: 160px;
        left: auto !important;
        right: 0 !important;
    }
    
    .table .dropdown.show {
        z-index: 1100 !important;
    }
    
    .dropdown-item {
        padding: 0.875rem 1.25rem;
        border-radius: var(--mobile-border-radius);
        margin: 0.25rem 0.25rem; /* Add margin for outline space */
        min-height: var(--mobile-touch-target);
        display: flex;
        align-items: center;
        gap: 0.75rem;
        transition: all 0.3s ease;
        color: var(--bs-dropdown-link-color, var(--text-primary)) !important;
        background: var(--bs-dropdown-bg, #ffffff) !important; /* ensure solid bg for items */
        border: none;
        text-decoration: none;
        font-weight: 600;
        font-size: 1rem;
        text-shadow: none;
    }
    
    .dropdown-item:hover {
        background: var(--bs-dropdown-link-hover-bg, #f1f5f9) !important;
        color: var(--text-primary, #0f172a) !important;
        transform: translateX(4px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .dropdown-item:active {
        background: #e2e8f0 !important;
        transform: scale(0.98);
    }
    
    .dropdown-divider {
        border-top: 1px solid #e2e8f0 !important;
        margin: 0.5rem 0;
        opacity: 1;
    }
    
    /* Enhanced dropdown toggle button */
    .dropdown-toggle {
        background: var(--dropdown-bg) !important;
        border: 1px solid var(--border-color) !important;
        color: var(--text-primary) !important;
        font-weight: 500 !important;
        padding: 0.75rem 1rem !important;
        border-radius: var(--mobile-border-radius) !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
        text-decoration: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        min-height: var(--mobile-touch-target) !important;
    }
    
    .dropdown-toggle:hover {
        background: var(--light-color) !important;
        border-color: var(--border-color) !important;
        color: var(--text-primary) !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
    }
    
    .dropdown-toggle:focus {
        background: var(--dropdown-bg) !important;
        border-color: #6b7280 !important;
        color: #6b7280 !important;
        box-shadow: 0 0 0 4px rgba(107, 114, 128, 0.1) !important;
        outline: 2px solid #6b7280 !important;
        outline-offset: 2px !important;
    }
    
    .dropdown-toggle::after {
        border-top-color: var(--text-muted) !important;
        margin-left: 0.5rem !important;
        border-width: 0.3em 0.3em 0 !important;
    }
    
    /* Ensure navbar dropdown is visible when open */
    .navbar .dropdown.show .dropdown-menu {
        display: block !important;
        transform: none !important;
    }
    
    /* Improve dropdown accessibility (navbar only) */
    .navbar .dropdown-menu[data-bs-popper] {
        position: static !important;
        transform: none !important;
    }
    
    /* Override Bootstrap dropdown styles (navbar only) */
    .navbar .dropdown-menu.show {
        display: block !important;
        transform: none !important;
        background: var(--bs-dropdown-bg, #ffffff) !important;
        border: 1px solid var(--border-color) !important;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25) !important;
    }
    
    /* Force navbar dropdown visibility */
    .navbar .dropdown.show .dropdown-menu,
    .navbar .dropdown-menu.show,
    .navbar .dropdown-menu[data-bs-popper="static"] {
        display: block !important;
        background: var(--bs-dropdown-bg, #ffffff) !important;
        border: 1px solid var(--border-color) !important;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25) !important;
        z-index: 9999 !important;
    }
    
    /* Additional dropdown overrides for Bootstrap (navbar only) */
    .navbar .dropdown-menu[data-bs-popper="static"],
    .navbar .dropdown-menu[data-bs-popper="dynamic"] {
        position: static !important;
        transform: none !important;
        inset: auto !important;
        margin: 0.75rem 0 0 0 !important;
    }
    
    /* Ensure dropdown container is visible */
    .dropdown {
        position: relative !important;
    }
    
    /* Override any Bootstrap positioning */
    .dropdown-menu.dropdown-menu-end {
        right: auto !important;
        left: auto !important;
        position: static !important;
    }
    
    /* Enhanced Modal Layout */
    .modal-dialog {
        margin: 0.75rem;
        max-width: calc(100% - 1.5rem);
    }
    
    .modal-content {
        border-radius: var(--mobile-border-radius);
        border: none;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    }
    
    .modal-header, .modal-body, .modal-footer {
        padding: 1.25rem;
    }
    
    .modal-footer {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin-bottom: 0;
    }
    
    /* Enhanced Typography */
    h1 { font-size: 1.875rem; line-height: 1.2; }
    h2 { font-size: 1.625rem; line-height: 1.2; }
    h3 { font-size: 1.375rem; line-height: 1.3; }
    h4 { font-size: 1.125rem; line-height: 1.3; }
    h5 { font-size: 1rem; line-height: 1.4; }
    h6 { font-size: 0.95rem; line-height: 1.4; }
    
    /* Enhanced Spacing */
    .mb-4 { margin-bottom: var(--mobile-section-spacing) !important; }
    .mb-3 { margin-bottom: var(--mobile-card-spacing) !important; }
    .mb-2 { margin-bottom: 0.75rem !important; }
    
    .py-4 { padding-top: var(--mobile-section-spacing) !important; padding-bottom: var(--mobile-section-spacing) !important; }
    .py-3 { padding-top: var(--mobile-card-spacing) !important; padding-bottom: var(--mobile-card-spacing) !important; }
    
    .px-4 { padding-left: var(--mobile-card-padding) !important; padding-right: var(--mobile-card-padding) !important; }
    .px-3 { padding-left: 1rem !important; padding-right: 1rem !important; }
    
    /* Enhanced Utility Classes */
    .mobile-stack {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .mobile-stack .btn {
        margin-bottom: 0;
        width: 100%;
    }
    
    .touch-target {
        min-height: var(--mobile-touch-target);
        min-width: var(--mobile-touch-target);
    }
    
    /* Enhanced Mobile Components */
    .mobile-card {
        margin-bottom: var(--mobile-card-spacing);
        border-radius: var(--mobile-border-radius);
        box-shadow: var(--mobile-shadow);
        transition: all 0.3s ease;
    }

    /* Mobile table action group horizontal layout */
    .table td .btn-group {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 0.5rem;
        width: 100%;
    }
    .table td .btn-group .btn {
        flex: 1 1 auto;
        min-width: 0;
        padding: 0.875rem 0.75rem;
        font-size: 1rem;
    }
    
    .mobile-card:hover {
        box-shadow: var(--mobile-shadow-hover);
        transform: translateY(-2px);
    }
    
    .mobile-btn {
        width: auto;
        margin-bottom: 0.75rem;
        padding: 1rem 1.5rem;
        font-size: 1rem;
        min-height: var(--mobile-button-height);
        border-radius: var(--mobile-border-radius);
    }
    
    .mobile-btn:last-child {
        margin-bottom: 0;
    }
    
    /* Enhanced Mobile Table Layout */
    .mobile-table-row {
        background: var(--bs-card-bg, #ffffff);
        border: 1px solid var(--border-color);
        border-radius: var(--mobile-border-radius);
        margin-bottom: var(--mobile-card-spacing);
        padding: 1rem;
        box-shadow: var(--mobile-shadow);
        transition: all 0.3s ease;
    }
    
    .mobile-table-row:hover {
        box-shadow: var(--mobile-shadow-hover);
        transform: translateY(-1px);
    }
    
    .mobile-table-row .row {
        margin: 0;
    }
    
    .mobile-table-row .col {
        padding: 0.75rem 0;
        border-bottom: 1px solid #f1f5f9;
        margin-bottom: 0.5rem;
    }
    
    .mobile-table-row .col:last-child {
        border-bottom: none;
        margin-bottom: 0;
    }
    
    .mobile-table-row .col:before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: var(--text-primary);
        display: block;
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--text-muted);
    }
    
    /* Enhanced Mobile Form Layout */
    .mobile-form-group {
        margin-bottom: 1.5rem;
    }
    
    .mobile-form-group .form-label {
        display: block;
        margin-bottom: 0.75rem;
        font-weight: 600;
        color: var(--text-primary);
    }
    
    .mobile-form-group .form-control,
    .mobile-form-group .form-select {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .mobile-form-group .form-text {
        margin-top: 0.25rem;
        font-size: 0.8rem;
    }
    
    /* Enhanced Mobile Navigation */
    .mobile-nav-item {
        padding: 1rem 1.5rem;
        border-radius: var(--mobile-border-radius);
        margin: 0.25rem 0;
        transition: all 0.3s ease;
        min-height: var(--mobile-touch-target);
        display: flex;
        align-items: center;
        gap: 0.75rem;
        background: var(--bs-card-bg, #ffffff);
        border: 1px solid var(--border-color);
    }
    
    .mobile-nav-item:hover {
        background: var(--light-color);
        transform: translateX(4px);
        box-shadow: var(--mobile-shadow);
    }
    
    .mobile-nav-item.active {
        background: #6b7280;
        color: white;
        border-color: #6b7280;
        box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
    }
    
    /* Enhanced Mobile Animations */
    .mobile-fade-in {
        animation: mobileFadeIn 0.4s ease-out;
    }
    
    .mobile-slide-up {
        animation: mobileSlideUp 0.4s ease-out;
    }
    
    @keyframes mobileFadeIn {
        from { 
            opacity: 0; 
            transform: translateY(20px); 
        }
        to { 
            opacity: 1; 
            transform: translateY(0); 
        }
    }
    
    @keyframes mobileSlideUp {
        from { 
            opacity: 0; 
            transform: translateY(30px); 
        }
        to { 
            opacity: 1; 
            transform: translateY(0); 
        }
    }
    
    /* Enhanced Mobile Shadows */
    .mobile-shadow {
        box-shadow: var(--mobile-shadow);
    }
    
    .mobile-shadow-hover {
        box-shadow: var(--mobile-shadow-hover);
    }
    
    /* Enhanced Mobile Borders */
    .mobile-border {
        border: 1px solid var(--border-color);
        border-radius: var(--mobile-border-radius);
    }
    
    /* Enhanced Mobile Backgrounds */
    .mobile-bg-light {
        background-color: #f8fafc;
    }
    
    .mobile-bg-white {
        background-color: white;
    }
    
    /* Enhanced Mobile Text Colors */
    .mobile-text-primary {
        color: var(--text-primary) !important;
    }
    
    .mobile-text-secondary {
        color: #475569 !important;
    }
    
    .mobile-text-muted {
        color: var(--text-muted) !important;
    }
    
    /* Enhanced Mobile Spacing Utilities */
    .mobile-p-0 { padding: 0 !important; }
    .mobile-p-1 { padding: 0.25rem !important; }
    .mobile-p-2 { padding: 0.5rem !important; }
    .mobile-p-3 { padding: 1rem !important; }
    .mobile-p-4 { padding: 1.25rem !important; }
    
    .mobile-m-0 { margin: 0 !important; }
    .mobile-m-1 { margin: 0.25rem !important; }
    .mobile-m-2 { margin: 0.5rem !important; }
    .mobile-m-3 { margin: 1rem !important; }
    .mobile-m-4 { margin: 1.25rem !important; }
    
    /* Enhanced Mobile Grid Layout */
    .mobile-grid-2 {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .mobile-grid-3 {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 0.75rem;
    }
    
    @media (max-width: 480px) {
        .mobile-grid-2,
        .mobile-grid-3 {
            grid-template-columns: 1fr;
        }
    }
}

/* Enhanced Mobile Navigation */
.navbar-toggler {
    border: none;
    padding: 0.5rem;
    border-radius: var(--mobile-border-radius);
    transition: all 0.3s ease;
}

.navbar-toggler:focus {
    box-shadow: var(--focus-ring, 0 0 0 3px rgba(59, 130, 246, 0.1));
}

.navbar-toggler-icon {
    background-image: none;
    width: 24px;
    height: 18px;
    position: relative;
    transition: all 0.3s ease;
}

.navbar-toggler-icon::before,
.navbar-toggler-icon::after,
.navbar-toggler-icon {
    background: var(--text-primary);
}

.navbar-toggler-icon::before,
.navbar-toggler-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    transition: all 0.3s ease;
}

.navbar-toggler-icon::before {
    top: -6px;
}

.navbar-toggler-icon::after {
    bottom: -6px;
}

.navbar-toggler[aria-expanded="true"] .navbar-toggler-icon {
    background: transparent;
}

.navbar-toggler[aria-expanded="true"] .navbar-toggler-icon::before {
    transform: rotate(45deg);
    top: 0;
}

.navbar-toggler[aria-expanded="true"] .navbar-toggler-icon::after {
    transform: rotate(-45deg);
    bottom: 0;
}

/* Mobile Bottom Tab Bar */
@media (max-width: 768px) {
    .mobile-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        height: calc(var(--mobile-tabbar-height) + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, 0.95);
        border-top: 1px solid var(--border-light);
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        display: flex;
        align-items: center;
        justify-content: space-around;
        padding-bottom: env(safe-area-inset-bottom);
        z-index: var(--z-fixed);
        transition: all var(--transition);
    }
    
    .mobile-tabbar::before {
        content: '';
        position: absolute;
        top: 0;
        left: 10%;
        right: 10%;
        height: 1px;
        background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
        opacity: 0.3;
    }
    
    [data-theme="dark"] .mobile-tabbar {
        background: rgba(11, 18, 32, 0.95);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }
    .mobile-tabbar .tab-item {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
        height: var(--mobile-tabbar-height);
        color: var(--text-tertiary);
        text-decoration: none;
        font-size: 0.75rem;
        font-weight: var(--font-weight-medium);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: 0;
        margin: 0 0.125rem;
        position: relative;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        overflow: hidden;
    }
    
    .mobile-tabbar .tab-item::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        background: rgba(59, 130, 246, 0.1);
        border-radius: 50%;
        transform: translate(-50%, -50%);
        transition: width 0.3s ease, height 0.3s ease;
        z-index: 0;
    }
    
    .mobile-tabbar .tab-item:active::before {
        width: 100%;
        height: 100%;
    }
    
    .mobile-tabbar .tab-item > * {
        position: relative;
        z-index: 1;
    }
    .mobile-tabbar .tab-item .tab-icon {
        font-size: 1.25rem;
        line-height: 1;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .mobile-tabbar .tab-item:hover .tab-icon,
    .mobile-tabbar .tab-item.active .tab-icon {
        transform: scale(1.1);
    }
    
    .mobile-tabbar .tab-item.active .tab-icon {
        animation: bounce 0.6s ease;
    }
    
    @keyframes bounce {
        0%, 20%, 53%, 80%, 100% {
            transform: scale(1.1);
        }
        40%, 43% {
            transform: scale(1.2);
        }
        70% {
            transform: scale(1.15);
        }
        90% {
            transform: scale(1.05);
        }
    }
    .mobile-tabbar .tab-item:hover,
    .mobile-tabbar .tab-item.active {
        color: var(--primary-color);
        background: var(--primary-50);
        transform: translateY(-1px);
    }
    
    .mobile-tabbar .tab-item.active {
        background: linear-gradient(135deg, var(--primary-100), var(--primary-50));
        box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
    }
    
    .mobile-tabbar .tab-item:active {
        transform: scale(0.95);
        transition: all 0.15s ease;
        background: var(--primary-200);
    }
    
    /* Enhanced touch feedback for tab items */
    @media (hover: none) and (pointer: coarse) {
        .mobile-tabbar .tab-item:active {
            background: var(--primary-100);
            transform: scale(0.92);
        }
    }
}

/* Respect forced light theme on mobile if explicitly set */
@media (prefers-color-scheme: dark) {
    /* Respect explicit light theme: variables already ensure light styling */
    html[data-theme="light"] .navbar,
    html[data-theme="light"] .mobile-tabbar {
        background: var(--navbar-bg) !important;
        border-color: var(--border-color) !important;
    }
}

/* Enhanced Small Mobile Devices */
@media (max-width: 480px) {
    .container, .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 1rem 1rem;
    }
    
    .btn {
        padding: 1rem 1.25rem;
        font-size: 0.95rem;
        min-height: 56px;
        /* inherit visual styles from base button tokens */
    }
    
    .btn:hover { transform: translateY(-1px); }
    
    .form-control, .form-select {
        padding: 0.875rem 1rem;
        min-height: 56px;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .table td {
        padding: 0.875rem;
    }
    
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-header, .modal-body, .modal-footer {
        padding: 1rem;
    }
    
    /* Enhanced Small Mobile Typography */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.125rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.9rem; }
    
    /* Enhanced Small Mobile Spacing */
    .mb-4 { margin-bottom: 1.25rem !important; }
    .mb-3 { margin-bottom: 1rem !important; }
    .mb-2 { margin-bottom: 0.75rem !important; }
    
    .py-4 { padding-top: 1.25rem !important; padding-bottom: 1.25rem !important; }
    .py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
}

/* Enhanced Landscape Mobile Devices */
@media (max-width: 768px) and (orientation: landscape) {
    .navbar-collapse {
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .modal-dialog {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn {
        min-height: 48px;
        padding: 0.875rem 1.5rem;
        /* inherit visual styles from base button tokens */
    }
    
    .btn:hover { transform: translateY(-1px); }
}

/* Enhanced High-DPI Mobile Devices */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .btn, .form-control, .form-select {
        border-width: 0.5px;
    }
    
    .table td {
        border-bottom-width: 0.5px;
    }
    
    .card {
        border-width: 0.5px;
    }
}

/* Enhanced Mobile Print Styles */
@media print and (max-width: 768px) {
    .navbar, .btn, .modal, .dropdown {
        display: none !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
        margin-bottom: 1rem !important;
    }
    
    .table td {
        border: 1px solid #000 !important;
    }
    
    .container {
        padding: 0 !important;
        max-width: 100% !important;
    }
}

/* Enhanced Analytics Dashboard Mobile Styles */
@media (max-width: 768px) {
    .chart-container {
        min-height: 250px !important;
        margin-bottom: var(--mobile-card-spacing);
    }
    
    .analytics-card {
        margin-bottom: var(--mobile-card-spacing);
    }
    
    .analytics-summary-card {
        padding: 1rem;
        text-align: center;
    }
    
    .analytics-summary-card h6 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
        color: var(--text-primary);
    }
    
    .analytics-summary-card small {
        font-size: 0.8rem;
        color: var(--text-muted);
    }
    
    .analytics-summary-card i {
        font-size: 1.5rem !important;
        margin-bottom: 0.75rem;
        color: #6b7280;
    }
    
    .analytics-chart-wrapper {
        background: var(--bs-card-bg, #ffffff);
        border-radius: var(--mobile-border-radius);
        padding: 1rem;
        box-shadow: var(--mobile-shadow);
        margin-bottom: var(--mobile-card-spacing);
    }
}

/* Enhanced Chart.js Mobile Optimizations */
@media (max-width: 768px) {
    .chartjs-tooltip {
        font-size: 0.875rem !important;
        padding: 0.75rem !important;
        border-radius: var(--mobile-border-radius);
        box-shadow: var(--mobile-shadow-hover);
    }
    
    .chartjs-legend {
        font-size: 0.875rem !important;
        margin-top: 1rem;
    }
    
    .chartjs-legend-item {
        margin-bottom: 0.5rem;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
}

/* Enhanced Mobile Loading States */
@media (max-width: 768px) {
    .loading-skeleton {
        background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
        background-size: 200% 100%;
        animation: loading 1.5s infinite;
        border-radius: var(--mobile-border-radius);
        height: 20px;
        margin-bottom: 0.75rem;
    }
    
    @keyframes loading {
        0% { background-position: 200% 0; }
        100% { background-position: -200% 0; }
    }
    
    .loading-card {
        min-height: 200px;
        background: var(--light-color);
        border-radius: var(--mobile-border-radius);
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-muted);
        font-size: 0.9rem;
    }
}

/* Enhanced Mobile Dark Mode Support via data-theme */
@media (max-width: 768px) {
    [data-theme="dark"] .navbar { 
        background: var(--navbar-bg) !important; 
        border-bottom-color: var(--border-color) !important;
    }
    [data-theme="dark"] .navbar-collapse { background: var(--navbar-bg); border-color: var(--border-color); }
    [data-theme="dark"] .card { background: var(--bs-card-bg); border-color: var(--border-color); color: var(--text-primary); }
    [data-theme="dark"] .table td { background: var(--bs-card-bg); color: var(--text-secondary); }
    [data-theme="dark"] .form-control,
    [data-theme="dark"] .form-select { background: #0f172a; border-color: var(--border-color); color: var(--text-primary); }
    [data-theme="dark"] .dropdown-menu { background: var(--dropdown-bg) !important; border-color: var(--border-color); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
    [data-theme="dark"] .dropdown-item { color: var(--text-secondary) !important; }
    [data-theme="dark"] .dropdown-item:hover { background: #111827 !important; color: var(--text-primary) !important; }
    [data-theme="dark"] .dropdown-divider { border-top-color: var(--border-color) !important; }
    [data-theme="dark"] .dropdown-toggle { background: var(--dropdown-bg) !important; border-color: var(--border-color) !important; color: var(--text-secondary) !important; }
    [data-theme="dark"] .dropdown-toggle:hover { background: #111827 !important; border-color: var(--border-color) !important; color: var(--text-primary) !important; }
}

