/* ============================================
   THE HELPING HAND - MOBILE RESPONSIVE STYLES
   ============================================ */

/* ============================================
   GLOBAL MOBILE OVERFLOW FIX
   ============================================ */
@media (max-width: 767.98px) {
    /* Prevent horizontal scrolling on mobile */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    /* Ensure all containers respect viewport width */
    .container-fluid,
    .container,
    .wrapper,
    .content-page,
    .content,
    .page-content {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    /* Fix any elements that might cause horizontal overflow */
    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100% !important;
    }

    /* Ensure images don't overflow */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Fix tables that might overflow */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================
   MOBILE FONT SIZE SCALING
   ============================================ */

/* Tablet screens (768px - 991.98px) - Slight reduction */
@media (max-width: 991.98px) {
    :root {
        --bs-body-font-size: 0.8125rem;
    }

    body {
        font-size: 0.8125rem;
    }

    h1, .h1 { font-size: 1.75rem; }
    h2, .h2 { font-size: 1.5rem; }
    h3, .h3 { font-size: 1.25rem; }
    h4, .h4 { font-size: 1.1rem; }
    h5, .h5 { font-size: 0.95rem; }
    h6, .h6 { font-size: 0.85rem; }

    .display-1 { font-size: 3rem; }
    .display-2 { font-size: 2.5rem; }
    .display-3 { font-size: 2rem; }
    .display-4 { font-size: 1.75rem; }
    .display-5 { font-size: 1.5rem; }
    .display-6 { font-size: 1.25rem; }

    .lead { font-size: 1rem; }
    .small, small { font-size: 0.75rem; }
}

/* Mobile screens (< 768px) - More reduction */
@media (max-width: 767.98px) {
    :root {
        --bs-body-font-size: 0.75rem;
    }

    body {
        font-size: 0.75rem;
    }

    h1, .h1 { font-size: 1.5rem; }
    h2, .h2 { font-size: 1.25rem; }
    h3, .h3 { font-size: 1.1rem; }
    h4, .h4 { font-size: 1rem; }
    h5, .h5 { font-size: 0.875rem; }
    h6, .h6 { font-size: 0.8rem; }

    .display-1 { font-size: 2.5rem; }
    .display-2 { font-size: 2rem; }
    .display-3 { font-size: 1.75rem; }
    .display-4 { font-size: 1.5rem; }
    .display-5 { font-size: 1.25rem; }
    .display-6 { font-size: 1.1rem; }

    .lead { font-size: 0.9rem; }
    .small, small { font-size: 0.7rem; }

    /* Form elements */
    .form-label {
        font-size: 0.75rem;
        margin-bottom: 0.2rem;
    }

    /* Buttons */
    .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }

    .btn-sm {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }

    .btn-lg {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }

    /* Badges */
    .badge {
        font-size: 0.65rem;
        padding: 0.25rem 0.4rem;
    }

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

    /* Dropdown items */
    .dropdown-item {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }

    /* Nav links */
    .nav-link {
        font-size: 0.8rem;
    }

    /* Alerts */
    .alert {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }
}

/* Small mobile screens (< 576px) - Maximum reduction */
@media (max-width: 575.98px) {
    :root {
        --bs-body-font-size: 0.7rem;
    }

    body {
        font-size: 0.7rem;
    }

    h1, .h1 { font-size: 1.25rem; }
    h2, .h2 { font-size: 1.1rem; }
    h3, .h3 { font-size: 1rem; }
    h4, .h4 { font-size: 0.9rem; }
    h5, .h5 { font-size: 0.8rem; }
    h6, .h6 { font-size: 0.75rem; }

    .display-1 { font-size: 2rem; }
    .display-2 { font-size: 1.75rem; }
    .display-3 { font-size: 1.5rem; }
    .display-4 { font-size: 1.25rem; }
    .display-5 { font-size: 1.1rem; }
    .display-6 { font-size: 1rem; }

    .lead { font-size: 0.85rem; }
    .small, small { font-size: 0.65rem; }

    /* Form elements */
    .form-label {
        font-size: 0.7rem;
    }

    /* Buttons */
    .btn {
        font-size: 0.75rem;
        padding: 0.35rem 0.6rem;
    }

    .btn-sm {
        font-size: 0.65rem;
        padding: 0.25rem 0.4rem;
    }

    /* Badges */
    .badge {
        font-size: 0.6rem;
        padding: 0.2rem 0.35rem;
    }

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

    /* Dropdown items */
    .dropdown-item {
        font-size: 0.75rem;
        padding: 0.35rem 0.6rem;
    }

    /* Nav links */
    .nav-link {
        font-size: 0.75rem;
    }

    /* Alerts */
    .alert {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }
}

/* ============================================
   MOBILE MARGIN & PADDING SCALING
   ============================================ */

/* Tablet screens (768px - 991.98px) */
@media (max-width: 991.98px) {
    /* Container padding */
    .container, .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Content page */
    .content-page {
        padding: 0 0.75rem;
    }

    /* Cards */
    .card-body {
        padding: 1rem;
    }

    .card-header, .card-footer {
        padding: 0.75rem 1rem;
    }

    /* Spacing utilities scale down */
    .p-4 { padding: 1rem !important; }
    .p-5 { padding: 1.5rem !important; }
    .m-4 { margin: 1rem !important; }
    .m-5 { margin: 1.5rem !important; }

    .px-4 { padding-left: 1rem !important; padding-right: 1rem !important; }
    .px-5 { padding-left: 1.5rem !important; padding-right: 1.5rem !important; }
    .py-4 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
    .py-5 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }

    .mx-4 { margin-left: 1rem !important; margin-right: 1rem !important; }
    .mx-5 { margin-left: 1.5rem !important; margin-right: 1.5rem !important; }
    .my-4 { margin-top: 1rem !important; margin-bottom: 1rem !important; }
    .my-5 { margin-top: 1.5rem !important; margin-bottom: 1.5rem !important; }

    /* Gap utilities */
    .gap-4 { gap: 1rem !important; }
    .gap-5 { gap: 1.5rem !important; }

    /* Row gutters */
    .g-4, .gx-4 { --bs-gutter-x: 1rem; }
    .g-4, .gy-4 { --bs-gutter-y: 1rem; }
    .g-5, .gx-5 { --bs-gutter-x: 1.5rem; }
    .g-5, .gy-5 { --bs-gutter-y: 1.5rem; }
}

/* Mobile screens (< 768px) */
@media (max-width: 767.98px) {
    /* Container padding */
    .container, .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* Content page */
    .content-page {
        padding: 0 0.5rem;
    }

    /* Cards */
    .card-body {
        padding: 0.75rem;
    }

    .card-header, .card-footer {
        padding: 0.5rem 0.75rem;
    }

    /* Spacing utilities scale down more */
    .p-3 { padding: 0.5rem !important; }
    .p-4 { padding: 0.75rem !important; }
    .p-5 { padding: 1rem !important; }
    .m-3 { margin: 0.5rem !important; }
    .m-4 { margin: 0.75rem !important; }
    .m-5 { margin: 1rem !important; }

    .px-3 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
    .px-4 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    .px-5 { padding-left: 1rem !important; padding-right: 1rem !important; }
    .py-3 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
    .py-4 { padding-top: 0.75rem !important; padding-bottom: 0.75rem !important; }
    .py-5 { padding-top: 1rem !important; padding-bottom: 1rem !important; }

    .mx-3 { margin-left: 0.5rem !important; margin-right: 0.5rem !important; }
    .mx-4 { margin-left: 0.75rem !important; margin-right: 0.75rem !important; }
    .mx-5 { margin-left: 1rem !important; margin-right: 1rem !important; }
    .my-3 { margin-top: 0.5rem !important; margin-bottom: 0.5rem !important; }
    .my-4 { margin-top: 0.75rem !important; margin-bottom: 0.75rem !important; }
    .my-5 { margin-top: 1rem !important; margin-bottom: 1rem !important; }

    /* Gap utilities */
    .gap-3 { gap: 0.5rem !important; }
    .gap-4 { gap: 0.75rem !important; }
    .gap-5 { gap: 1rem !important; }

    /* Row gutters */
    .g-3, .gx-3 { --bs-gutter-x: 0.5rem; }
    .g-3, .gy-3 { --bs-gutter-y: 0.5rem; }
    .g-4, .gx-4 { --bs-gutter-x: 0.75rem; }
    .g-4, .gy-4 { --bs-gutter-y: 0.75rem; }
    .g-5, .gx-5 { --bs-gutter-x: 1rem; }
    .g-5, .gy-5 { --bs-gutter-y: 1rem; }

    /* Modal padding */
    .modal-header {
        padding: 0.75rem;
    }

    .modal-body {
        padding: 0.75rem;
    }

    .modal-footer {
        padding: 0.5rem 0.75rem;
    }

    /* Table padding */
    .table > :not(caption) > * > * {
        padding: 0.4rem 0.35rem;
    }

    .table-sm > :not(caption) > * > * {
        padding: 0.25rem 0.25rem;
    }

    /* List group */
    .list-group-item {
        padding: 0.5rem 0.75rem;
    }

    /* Page title */
    .page-title-head {
        padding: 0.5rem 0.75rem;
        min-height: 35px;
    }
}

/* Small mobile screens (< 576px) */
@media (max-width: 575.98px) {
    /* Container padding */
    .container, .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* Content page */
    .content-page {
        padding: 0 0.25rem;
    }

    /* Cards */
    .card-body {
        padding: 0.5rem;
    }

    .card-header, .card-footer {
        padding: 0.4rem 0.5rem;
    }

    /* Spacing utilities scale down maximum */
    .p-2 { padding: 0.25rem !important; }
    .p-3 { padding: 0.4rem !important; }
    .p-4 { padding: 0.5rem !important; }
    .p-5 { padding: 0.75rem !important; }
    .m-2 { margin: 0.25rem !important; }
    .m-3 { margin: 0.4rem !important; }
    .m-4 { margin: 0.5rem !important; }
    .m-5 { margin: 0.75rem !important; }

    .px-2 { padding-left: 0.25rem !important; padding-right: 0.25rem !important; }
    .px-3 { padding-left: 0.4rem !important; padding-right: 0.4rem !important; }
    .px-4 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
    .px-5 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    .py-2 { padding-top: 0.25rem !important; padding-bottom: 0.25rem !important; }
    .py-3 { padding-top: 0.4rem !important; padding-bottom: 0.4rem !important; }
    .py-4 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
    .py-5 { padding-top: 0.75rem !important; padding-bottom: 0.75rem !important; }

    .mx-2 { margin-left: 0.25rem !important; margin-right: 0.25rem !important; }
    .mx-3 { margin-left: 0.4rem !important; margin-right: 0.4rem !important; }
    .mx-4 { margin-left: 0.5rem !important; margin-right: 0.5rem !important; }
    .mx-5 { margin-left: 0.75rem !important; margin-right: 0.75rem !important; }
    .my-2 { margin-top: 0.25rem !important; margin-bottom: 0.25rem !important; }
    .my-3 { margin-top: 0.4rem !important; margin-bottom: 0.4rem !important; }
    .my-4 { margin-top: 0.5rem !important; margin-bottom: 0.5rem !important; }
    .my-5 { margin-top: 0.75rem !important; margin-bottom: 0.75rem !important; }

    /* Gap utilities */
    .gap-2 { gap: 0.25rem !important; }
    .gap-3 { gap: 0.4rem !important; }
    .gap-4 { gap: 0.5rem !important; }
    .gap-5 { gap: 0.75rem !important; }

    /* Row gutters */
    .g-2, .gx-2 { --bs-gutter-x: 0.25rem; }
    .g-2, .gy-2 { --bs-gutter-y: 0.25rem; }
    .g-3, .gx-3 { --bs-gutter-x: 0.4rem; }
    .g-3, .gy-3 { --bs-gutter-y: 0.4rem; }
    .g-4, .gx-4 { --bs-gutter-x: 0.5rem; }
    .g-4, .gy-4 { --bs-gutter-y: 0.5rem; }
    .g-5, .gx-5 { --bs-gutter-x: 0.75rem; }
    .g-5, .gy-5 { --bs-gutter-y: 0.75rem; }

    /* Modal padding */
    .modal-header {
        padding: 0.5rem;
    }

    .modal-body {
        padding: 0.5rem;
    }

    .modal-footer {
        padding: 0.4rem 0.5rem;
    }

    /* Table padding */
    .table > :not(caption) > * > * {
        padding: 0.3rem 0.25rem;
        font-size: 0.7rem;
    }

    .table-sm > :not(caption) > * > * {
        padding: 0.2rem 0.2rem;
    }

    /* List group */
    .list-group-item {
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
    }

    /* Page title */
    .page-title-head {
        padding: 0.4rem 0.5rem;
        min-height: 30px;
    }
}

/* ============================================
   GLOBAL MOBILE ADJUSTMENTS
   ============================================ */

/* Improve touch targets for mobile */
@media (max-width: 767.98px) {
    .btn {
        min-height: 40px;
    }

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

    .form-control, .form-select {
        min-height: 40px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Improve card spacing on mobile */
    .card {
        margin-bottom: 0.75rem;
    }

    /* Stack filter controls vertically on mobile */
    .card-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .card-header .d-flex {
        flex-wrap: wrap;
        width: 100%;
    }

    /* Full width search on mobile */
    .app-search {
        width: 100%;
    }

    .app-search input,
    .app-search select {
        width: 100%;
    }

    /* Improve table responsiveness */
    .table-responsive {
        margin: 0 -0.5rem;
        padding: 0 0.5rem;
    }

    /* Stack stat cards */
    .row-cols-md-4 > .col,
    .row-cols-md-3 > .col {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Stack widget cards */
    .row-cols-md-2 > .col {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Improve modal sizing */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    /* Hide less important columns on mobile */
    .d-mobile-none {
        display: none !important;
    }

    /* Improve dropdown menus */
    .dropdown-menu {
        max-width: calc(100vw - 2rem);
    }

    /* Bulk actions bar mobile */
    #bulkActionsBar .d-flex {
        flex-direction: column;
        gap: 0.5rem;
    }

    #bulkActionsBar .d-flex .d-flex {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Page title adjustments */
    .page-title-head {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    .page-title-head .d-flex {
        width: 100%;
        flex-wrap: wrap;
    }
}

/* ============================================
   SMALL MOBILE (< 576px)
   ============================================ */

@media (max-width: 575.98px) {
    /* Single column stats */
    .row-cols-md-4 > .col,
    .row-cols-md-3 > .col,
    .row-cols-md-2 > .col {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Smaller padding */
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    /* Compact table cells */
    .table td, .table th {
        padding: 0.5rem 0.25rem;
        font-size: 0.8125rem;
    }
    
    /* Hide action text, show only icons */
    .btn-action-text {
        display: none;
    }
    
    /* Compact filter row */
    .filter-row .col-md-3 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Notification dropdown full width */
    .dropdown-menu-lg {
        width: calc(100vw - 1rem) !important;
        max-width: 100% !important;
    }
    
    /* Kanban board horizontal scroll */
    .kanban-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 1rem;
    }

    .kanban-board {
        min-width: 280px;
    }
}

/* ============================================
   TABLET (768px - 991.98px)
   ============================================ */

@media (min-width: 768px) and (max-width: 991.98px) {
    /* Two column layout for stats */
    .row-cols-md-4 > .col {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Adjust filter controls */
    #filterControls {
        flex-wrap: wrap;
    }

    #filterControls .app-search {
        flex: 0 0 calc(50% - 0.5rem);
    }
}

/* ============================================
   DASHBOARD MOBILE IMPROVEMENTS
   ============================================ */

@media (max-width: 767.98px) {
    /* Dashboard cards */
    #taskCountCard .card-body,
    #projectCountCard .card-body {
        padding: 1rem;
    }

    #taskCountCard h3,
    #projectCountCard h3 {
        font-size: 1.5rem;
    }

    /* Timeline improvements */
    .timeline-item {
        padding-left: 2rem;
    }

    .timeline-item::before {
        left: 0.5rem;
    }

    /* Schedule card */
    .schedule-item {
        padding: 0.75rem;
    }
}

/* ============================================
   TASK & PROJECT LIST MOBILE
   ============================================ */

@media (max-width: 767.98px) {
    /* Task list cards */
    .task-list-item {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .task-list-item .task-actions {
        margin-top: 0.5rem;
        width: 100%;
        justify-content: flex-end;
    }

    /* Project list improvements */
    .project-row {
        flex-direction: column;
    }

    .project-row .project-info {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .project-row .project-actions {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }

    /* Hide less important table columns */
    .table .col-hide-mobile {
        display: none;
    }

    /* Task Details Mobile Fixes */
    #projectDetailsDisplay .card-header {
        padding: 1rem !important;
        position: relative;
        z-index: 1;
        flex-direction: row !important; /* Override the general card-header rule */
    }

    #projectDetailsDisplay .card-header .row {
        margin: 0;
    }

    #projectDetailsDisplay .card-header .col {
        padding: 0.5rem;
    }

    /* Prevent any pseudo-elements from blocking clicks */
    #projectDetailsDisplay .card-header::before,
    #projectDetailsDisplay .card-header::after,
    #projectDetailsDisplay::before,
    #projectDetailsDisplay::after {
        pointer-events: none !important;
    }

    /* Ensure buttons are clickable on mobile */
    #projectDetailsDisplay .btn,
    #projectDetailsDisplay .dropdown {
        position: relative;
        z-index: 100 !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    }

    /* Specific button fixes */
    .task-action-btn {
        position: relative !important;
        z-index: 101 !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
        cursor: pointer !important;
        -webkit-user-select: none;
        user-select: none;
    }

    #taskClockInBtn,
    #taskClockOutBtn,
    #taskCreateProjectBtn {
        min-width: 120px;
        position: relative !important;
        z-index: 101 !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
    }

    /* Stack task header buttons vertically on small screens */
    #projectDetailsDisplay .card-header .d-flex.align-items-center.gap-2 {
        flex-wrap: wrap;
        gap: 0.5rem !important;
        position: relative;
        z-index: 100;
    }

    /* Ensure dropdown menu is accessible */
    #projectDetailsDisplay .dropdown-menu {
        z-index: 1060;
    }

    /* Fix for nested rows causing layout issues */
    #projectDetailsDisplay .card-header .row .row {
        width: 100%;
    }

    /* Ensure task title doesn't overlap buttons */
    #projectDetailsDisplay .card-header h3 {
        max-width: 100%;
        word-wrap: break-word;
        margin-bottom: 0.5rem;
    }

    /* Avatar adjustments */
    #projectDetailsDisplay .avatar-xxl {
        width: 50px;
        height: 50px;
    }

    #projectDetailsDisplay .avatar-xxl img {
        height: 40px !important;
    }

    /* Task Details Tabs Mobile */
    .nav-task-tabs {
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .nav-task-tabs .nav-item {
        flex-shrink: 0;
    }

    .nav-task-tabs .nav-link {
        padding: 0.75rem 1rem;
        white-space: nowrap;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Ensure tab content is accessible */
    .tab-content {
        position: relative;
        z-index: 1;
    }

    /* Fix for select dropdowns in task details */
    #projectDetailsDisplay select,
    #projectDetailsDisplay .form-select,
    #projectDetailsDisplay .form-control {
        touch-action: manipulation;
        pointer-events: auto;
    }

    /* Ensure button container is above everything */
    #projectDetailsDisplay .d-flex.align-items-center.gap-2,
    #projectDetailsDisplay .d-flex.flex-column.flex-md-row {
        position: relative !important;
        z-index: 1000 !important;
        pointer-events: auto !important;
    }

    /* Ensure all buttons in task details are touchable */
    #projectDetailsDisplay button,
    #projectDetailsDisplay .btn,
    #projectDetailsDisplay a.btn {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        position: relative;
        z-index: 2;
    }

    /* Fix for dropdown menus */
    #projectDetailsDisplay .dropdown-toggle {
        pointer-events: auto;
    }

    /* Ensure card body content is accessible */
    #projectDetailsDisplay .card-body {
        position: relative;
        z-index: 1;
    }
}

/* ============================================
   FORMS MOBILE IMPROVEMENTS
   ============================================ */

@media (max-width: 767.98px) {
    /* Form groups stack vertically */
    .row.g-3 > [class*="col-md-"],
    .row.g-2 > [class*="col-md-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Improve form labels */
    .form-label {
        font-size: 0.875rem;
        margin-bottom: 0.25rem;
    }

    /* Date pickers */
    .flatpickr-calendar {
        width: calc(100vw - 2rem) !important;
        max-width: 320px;
    }

    /* Summernote editor */
    .note-editor {
        min-height: 150px;
    }

    .note-toolbar {
        flex-wrap: wrap;
    }

    /* Ensure all interactive elements are touchable */
    button, .btn, a.btn, select, input, textarea {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    /* Remove any pointer-events: none that might block clicks */
    * {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
    }

    input, textarea, select, button, a {
        -webkit-user-select: auto;
        -moz-user-select: auto;
        -ms-user-select: auto;
        user-select: auto;
    }
}

/* ============================================
   MODAL MOBILE IMPROVEMENTS
   ============================================ */

@media (max-width: 767.98px) {
    /* Make all large modals full width on mobile */
    .modal-xl,
    .modal-lg {
        max-width: calc(100% - 1rem) !important;
        margin: 0.5rem auto !important;
    }

    .modal-xl .modal-content,
    .modal-lg .modal-content {
        border-radius: 0.5rem;
    }

    /* Remove column offsets on mobile - use full width */
    .modal .offset-md-1,
    .modal .offset-md-2,
    .modal .offset-md-3,
    .modal .offset-md-4 {
        margin-left: 0 !important;
    }

    .modal .col-md-8,
    .modal .col-md-10 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Compact modal header */
    .modal-header {
        padding: 0.5rem 0.75rem !important;
    }

    .modal-header .modal-title {
        font-size: 1rem;
    }

    .modal-header .btn-close {
        padding: 0.5rem;
    }

    /* Compact modal body */
    .modal-body {
        padding: 0.5rem !important;
    }

    /* Compact modal footer */
    .modal-footer {
        padding: 0.5rem !important;
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .modal-footer .btn {
        flex: 1 1 auto;
        min-width: 80px;
        padding: 0.35rem 0.5rem;
        font-size: 0.8rem;
    }

    /* Cards inside modals - minimal padding */
    .modal .card {
        margin-bottom: 0.5rem !important;
    }

    .modal .card-header {
        padding: 0.4rem 0.5rem !important;
    }

    .modal .card-header h6,
    .modal .card-header .h6 {
        font-size: 0.8rem;
        margin-bottom: 0;
    }

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

    /* Form elements in modals */
    .modal .form-label {
        font-size: 0.75rem;
        margin-bottom: 0.15rem;
    }

    .modal .form-control,
    .modal .form-select {
        padding: 0.35rem 0.5rem;
        font-size: 0.8rem;
        min-height: 36px;
    }

    .modal .mb-3 {
        margin-bottom: 0.5rem !important;
    }

    .modal .mb-2 {
        margin-bottom: 0.35rem !important;
    }

    .modal .mt-3 {
        margin-top: 0.5rem !important;
    }

    /* Row gutters in modals */
    .modal .row {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
    }

    /* Full screen modals on mobile */
    .modal-fullscreen-mobile {
        width: 100vw;
        max-width: none;
        height: 100%;
        margin: 0;
    }

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

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

/* Small mobile - even more compact */
@media (max-width: 575.98px) {
    .modal-xl,
    .modal-lg,
    .modal-dialog {
        max-width: 100% !important;
        margin: 0 !important;
    }

    .modal-xl .modal-content,
    .modal-lg .modal-content,
    .modal-content {
        border-radius: 0;
        min-height: 100vh;
    }

    .modal-header {
        padding: 0.4rem 0.5rem !important;
    }

    .modal-header .modal-title {
        font-size: 0.9rem;
    }

    .modal-body {
        padding: 0.35rem !important;
    }

    .modal-footer {
        padding: 0.35rem !important;
    }

    .modal-footer .btn {
        padding: 0.3rem 0.4rem;
        font-size: 0.75rem;
    }

    .modal .card-header {
        padding: 0.3rem 0.4rem !important;
    }

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

    .modal .form-control,
    .modal .form-select {
        padding: 0.3rem 0.4rem;
        font-size: 0.75rem;
        min-height: 32px;
    }

    .modal .form-label {
        font-size: 0.7rem;
    }

    .modal .mb-3 {
        margin-bottom: 0.35rem !important;
    }
}

/* ============================================
   RECEIPT UPLOAD MODAL MOBILE SPECIFIC
   ============================================ */

@media (max-width: 767.98px) {
    /* Receipt modal - remove offset, use full width */
    #receiptUploadModal .col-md-8.offset-md-2 {
        margin-left: 0 !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Compact drop zone */
    #receiptUploadModal .drop-zone {
        padding: 15px 10px !important;
    }

    #receiptUploadModal .drop-zone .fa-3x {
        font-size: 2rem !important;
    }

    #receiptUploadModal .drop-zone p {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }

    /* Receipt preview section - stack columns */
    #receiptUploadModal #uploadReceiptPreviewSection .col-md-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Smaller receipt preview image */
    #receiptUploadModal .receipt-preview {
        max-height: 150px !important;
    }

    /* Compact form in receipt modal */
    #receiptUploadModal .row .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media (max-width: 575.98px) {
    #receiptUploadModal .drop-zone {
        padding: 10px !important;
    }

    #receiptUploadModal .drop-zone .fa-3x {
        font-size: 1.5rem !important;
        margin-bottom: 0.25rem !important;
    }

    #receiptUploadModal .drop-zone p {
        font-size: 0.75rem;
        margin-bottom: 0.15rem;
    }

    #receiptUploadModal .receipt-preview {
        max-height: 120px !important;
    }

    /* Stack amount/tax fields on very small screens */
    #receiptUploadModal #uploadReceiptExtractedData .row .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ============================================
   GENERAL DROP ZONE MOBILE
   ============================================ */

@media (max-width: 767.98px) {
    .drop-zone,
    .hh-dropzone {
        padding: 15px 10px !important;
    }

    .drop-zone .fa-3x,
    .hh-dropzone .fa-3x,
    .hh-dropzone-icon {
        font-size: 2rem !important;
        margin-bottom: 0.5rem !important;
    }

    .drop-zone p,
    .hh-dropzone p {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }
}

@media (max-width: 575.98px) {
    .drop-zone,
    .hh-dropzone {
        padding: 10px !important;
    }

    .drop-zone .fa-3x,
    .hh-dropzone .fa-3x,
    .hh-dropzone-icon {
        font-size: 1.5rem !important;
    }

    .drop-zone p,
    .hh-dropzone p {
        font-size: 0.75rem;
    }
}

/* ============================================
   ICON SIZE SCALING FOR MOBILE
   ============================================ */

@media (max-width: 767.98px) {
    .fa-3x { font-size: 2rem !important; }
    .fa-4x { font-size: 2.5rem !important; }
    .fa-5x { font-size: 3rem !important; }

    .ti-lg { font-size: 1.25rem !important; }
    .ti-xl { font-size: 1.5rem !important; }

    /* Avatar sizes */
    .avatar-xl {
        width: 3rem !important;
        height: 3rem !important;
    }

    .avatar-xxl {
        width: 4rem !important;
        height: 4rem !important;
    }

    .avatar-lg {
        width: 2.5rem !important;
        height: 2.5rem !important;
    }
}

@media (max-width: 575.98px) {
    .fa-3x { font-size: 1.5rem !important; }
    .fa-4x { font-size: 2rem !important; }
    .fa-5x { font-size: 2.5rem !important; }

    .avatar-xl {
        width: 2.5rem !important;
        height: 2.5rem !important;
    }

    .avatar-xxl {
        width: 3rem !important;
        height: 3rem !important;
    }

    .avatar-lg {
        width: 2rem !important;
        height: 2rem !important;
    }
}

/* ============================================
   NAVIGATION MOBILE IMPROVEMENTS
   ============================================ */

@media (max-width: 991.98px) {
    /* Improve topbar spacing */
    .app-topbar {
        padding: 0.5rem 0.75rem;
    }

    /* Compact topbar items */
    .topbar-item {
        margin: 0 0.25rem;
    }

    /* User dropdown compact */
    .nav-user .topbar-link {
        padding: 0.25rem;
    }

    /* Breadcrumb improvements */
    .breadcrumb {
        font-size: 0.8125rem;
        flex-wrap: wrap;
    }

    .breadcrumb-item + .breadcrumb-item::before {
        padding: 0 0.25rem;
    }
}

@media (max-width: 767.98px) {
    /* Fix topbar avatar causing layout issues */
    .nav-user .topbar-link img {
        display: inline-block !important;
        width: 28px !important;
        height: 28px !important;
        flex-shrink: 0;
    }

    /* Hide user name on mobile */
    .nav-user .topbar-link > div {
        display: none !important;
    }

    /* Ensure topbar doesn't overflow */
    .app-topbar {
        overflow: hidden;
        max-width: 100vw;
    }

    .app-topbar .container-fluid {
        overflow: hidden;
        max-width: 100%;
    }

    .topbar-menu {
        flex-wrap: nowrap;
        overflow: hidden;
    }

    /* Hide less important topbar items on mobile */
    .topbar-item:has(#selected-language-code) {
        display: none !important;
    }

    /* Compact topbar items further */
    .topbar-item {
        margin: 0 0.1rem;
    }

    .topbar-link {
        padding: 0.25rem !important;
    }

    /* Reduce icon sizes in topbar */
    .topbar-link .fs-xxl {
        width: 18px !important;
        height: 18px !important;
    }

    /* Fix logo size */
    .logo-topbar {
        max-width: 100px;
        overflow: hidden;
    }

    .logo-topbar img {
        max-height: 28px;
        width: auto;
    }

    /* Quick settings buttons - hide on mobile */
    .logo-topbar + .d-flex {
        display: none !important;
    }
}

/* ============================================
   TIMECARD MOBILE IMPROVEMENTS
   ============================================ */

@media (max-width: 767.98px) {
    /* Timecard list */
    .timecard-item {
        flex-direction: column;
    }

    .timecard-item .timecard-info {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .timecard-item .timecard-hours {
        font-size: 1.25rem;
    }

    /* Clock in/out buttons */
    .clock-btn {
        width: 100%;
        padding: 1rem;
        font-size: 1.125rem;
    }

}

/* Timecard Approval Filters - Prevent shrinking below current size */
#filter-employee,
#filter-foreman,
#filter-status,
#filter-date-from,
#filter-date-to {
    min-width: 150px;
}

.timecard-approvals .btn-sm {
    min-width: 100px;
}

/* Force timecard filters to stack below 1400px */
@media (max-width: 1399px) {
    .timecard-approvals .row > [class*="col-"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

/* ============================================
   UTILITY CLASSES FOR MOBILE
   ============================================ */

/* Show only on mobile */
.d-mobile-only {
    display: none !important;
}

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

    .d-mobile-flex {
        display: flex !important;
    }

    .d-mobile-inline {
        display: inline !important;
    }

    /* Text utilities */
    .text-mobile-center {
        text-align: center !important;
    }

    .text-mobile-sm {
        font-size: 0.8125rem !important;
    }

    /* Spacing utilities */
    .p-mobile-2 {
        padding: 0.5rem !important;
    }

    .m-mobile-0 {
        margin: 0 !important;
    }

    .mb-mobile-2 {
        margin-bottom: 0.5rem !important;
    }

    /* Width utilities */
    .w-mobile-100 {
        width: 100% !important;
    }
}

/* ============================================
   SWIPE GESTURES SUPPORT
   ============================================ */

@media (max-width: 767.98px) {
    /* Enable horizontal scroll with snap */
    .swipe-container {
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .swipe-container::-webkit-scrollbar {
        display: none;
    }

    .swipe-item {
        scroll-snap-align: start;
        flex-shrink: 0;
    }
}

/* ============================================
   PULL TO REFRESH INDICATOR
   ============================================ */

.pull-to-refresh {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    z-index: 1000;
    background: var(--bs-primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0 0 0.5rem 0.5rem;
    transition: transform 0.3s ease;
    display: none;
}

@media (max-width: 991.98px) {
    .pull-to-refresh {
        display: block;
    }

    .pull-to-refresh.visible {
        transform: translateX(-50%) translateY(0);
    }
}

/* ============================================
   FLOATING ACTION BUTTON (FAB)
   ============================================ */

.fab-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 1000;
    display: none;
}

@media (max-width: 991.98px) {
    .fab-container {
        display: block;
    }
}

.fab-main {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1ab394 0%, #0acf97 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(26, 179, 148, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.fab-main:hover,
.fab-main:focus {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(26, 179, 148, 0.5);
}

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

.fab-main.open {
    transform: rotate(45deg);
}

.fab-menu {
    position: absolute;
    bottom: 70px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.fab-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.fab-item {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.fab-item-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    color: #333;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fab-item-btn:hover {
    background: #f8f9fa;
    transform: scale(1.1);
}

.fab-item-label {
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
}

/* ============================================
   NOTIFICATION ENHANCEMENTS
   ============================================ */

/* Notification badge pulse animation */
@keyframes notificationPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 6px rgba(220, 53, 69, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    }
}

#notificationBadge {
    animation: notificationPulse 2s infinite;
}

#notificationBadge:empty,
#notificationBadge[style*="display: none"] {
    animation: none;
}

/* Notification dropdown improvements */
.dropdown-menu-lg {
    max-height: 80vh;
}

.notify-item {
    transition: background-color 0.2s ease;
    border-left: 3px solid transparent;
}

.notify-item:hover {
    background-color: rgba(26, 179, 148, 0.05);
}

.notify-item.unread {
    background-color: rgba(26, 179, 148, 0.08);
    border-left-color: #1ab394;
}

.notify-item.unread:hover {
    background-color: rgba(26, 179, 148, 0.12);
}

/* Notification time styling */
.notify-item .text-muted.small,
.notify-item small.text-muted {
    font-size: 11px;
}

/* Notification icon styling */
.notify-item .avatar-sm {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile notification dropdown */
@media (max-width: 575.98px) {
    .dropdown-menu-lg {
        width: calc(100vw - 20px) !important;
        max-width: 100%;
        left: 10px !important;
        right: 10px !important;
    }

    .notify-item {
        padding: 12px 15px;
    }

    .notify-item .avatar-sm {
        width: 32px;
        height: 32px;
    }
}

/* Toast notification improvements */
.swal2-toast {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
}

.swal2-toast.swal2-show {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   DASHBOARD CUSTOMIZATION
   ============================================ */

/* Ensure hidden dashboard widgets stay hidden */
.col[style*="display: none"] {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

/* Dashboard widget toggle list */
#dashboardWidgetsList .list-group-item {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#dashboardWidgetsList .list-group-item:hover {
    background-color: rgba(26, 179, 148, 0.05);
}

#dashboardWidgetsList .form-check-input:checked {
    background-color: #1ab394;
    border-color: #1ab394;
}
