/* ========================================
   MOBILE STYLES - HGOV ADO REPORTING
   Mobile-specific overrides and enhancements
   This file should be imported AFTER app.css
   ======================================== */

/* ========================================
   MOBILE CSS CUSTOM PROPERTIES
   Breakpoint Reference:
   - xs: < 576px  (mobile portrait)
   - sm: >= 576px (mobile landscape)
   - md: >= 768px (tablets)
   - lg: >= 992px (desktop)
   - xl: >= 1200px (large desktop)
   ======================================== */

/* Mobile-specific design tokens */
@media (max-width: 767.98px) {
    :root,
    [data-theme="light"],
    [data-theme="dark"] {
        /* Touch-friendly minimum sizes */
        --touch-target-min: 44px;
        --touch-target-comfortable: 48px;
        --touch-spacing: 8px;

        /* Mobile typography scale */
        --font-size-base-mobile: 16px; /* Prevents zoom on iOS inputs */
        --font-size-3xl: 1.5rem;
        --font-size-2xl: 1.25rem;
        --font-size-xl: 1.125rem;
        --font-size-lg: 1rem;

        /* Mobile spacing */
        --spacing-page: 0.75rem;
        --spacing-card: 1rem;

        /* Mobile-optimized shadows (lighter for performance) */
        --shadow-sm-mobile: 0 1px 2px rgba(0, 0, 0, 0.04);
        --shadow-md-mobile: 0 2px 4px rgba(0, 0, 0, 0.08);

        /* Mobile nav dimensions */
        --mobile-header-height: 56px;
        --mobile-bottom-nav-height: 56px;
    }
}

/* Small mobile (portrait) */
@media (max-width: 575.98px) {
    :root,
    [data-theme="light"],
    [data-theme="dark"] {
        --font-size-3xl: 1.375rem;
        --font-size-2xl: 1.125rem;
        --spacing-page: 0.5rem;
    }
}

/* ========================================
   TOUCH DEVICE ENHANCEMENTS
   Applied via JS class 'touch-device' on html element
   ======================================== */

.touch-device * {
    /* Disable text selection on interactive elements for cleaner touch */
    -webkit-tap-highlight-color: transparent;
}

.touch-device button,
.touch-device a,
.touch-device .btn,
.touch-device .nav-rail-item,
.touch-device .clickable {
    /* Remove 300ms tap delay */
    touch-action: manipulation;
}

/* ========================================
   GLOBAL TOUCH TARGET SIZING
   Ensures all interactive elements meet 44px minimum
   ======================================== */

@media (max-width: 767.98px) {
    /* Buttons */
    .btn,
    button:not(.nav-rail-item) {
        min-height: var(--touch-target-min);
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Small buttons get padding boost */
    .btn-sm {
        min-height: 40px;
        padding: 0.5rem 0.875rem;
    }

    /* Icon buttons */
    .btn-icon,
    .btn-icon-sm {
        min-width: var(--touch-target-min);
        min-height: var(--touch-target-min);
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Form inputs */
    .form-control,
    .form-select,
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="search"],
    select,
    textarea {
        min-height: var(--touch-target-min);
        font-size: var(--font-size-base-mobile); /* Prevents iOS zoom */
        padding: 0.625rem 0.875rem;
    }

    /* Checkboxes and radios - larger touch area */
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
        margin-right: var(--touch-spacing);
    }

    /* Links in lists */
    .list-group-item,
    .dropdown-item {
        min-height: var(--touch-target-min);
        padding: 0.75rem 1rem;
    }

    /* Pagination */
    .pagination .page-link {
        min-width: var(--touch-target-min);
        min-height: var(--touch-target-min);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.5rem 0.75rem;
    }

    /* Table rows for tap targets */
    .table td,
    .table th {
        padding: 0.75rem 0.5rem;
    }
}

/* ========================================
   MOBILE TYPOGRAPHY
   ======================================== */

@media (max-width: 767.98px) {
    /* Page titles */
    h1, .h1 {
        font-size: var(--font-size-2xl);
        line-height: 1.3;
    }

    h2, .h2 {
        font-size: var(--font-size-xl);
    }

    h3, .h3 {
        font-size: var(--font-size-lg);
    }

    /* Reduce letter-spacing for mobile readability */
    .brand-title,
    .header-title {
        letter-spacing: -0.01em;
    }
}

/* ========================================
   MOBILE HEADER ENHANCEMENTS
   ======================================== */

@media (max-width: 767.98px) {
    /* Make header sticky */
    .app-header {
        position: sticky;
        top: 0;
        z-index: 1001;
        height: var(--mobile-header-height);
    }

    /* Compact branding */
    .app-branding {
        gap: 0.5rem;
    }

    .brand-logo {
        height: 32px;
        margin-left: -10px;
    }

    .brand-title {
        font-size: 1rem;
        white-space: nowrap;
    }



    .brand-subtitle {
        display: none; /* Already hidden, ensuring consistency */
    }

    /* Header actions - more compact */
    .header-right {
        gap: 0;
        padding-right: 8px;
    }

    .header-right .btn,
    .header-right button {
        padding: 0.5rem;
        min-width: 40px;
    }

    /* Pull avatar and AI icon closer together */
    .header-right .agent-ai-ask-btn {
        margin-left: -8px !important;
    }

    /* Theme toggle button */
    .theme-toggle-btn {
        width: 40px;
        height: 40px;
        padding: 0;
    }
}

/* Extra small screens */
@media (max-width: 375px) {
    .brand-title {
        font-size: 0.9rem;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ========================================
   MOBILE NAVIGATION DRAWER ENHANCEMENTS
   ======================================== */

@media (max-width: 767.98px) {
    /* Nav rail as full-height drawer */
    .nav-rail {
        position: fixed;
        left: 0;
        top: var(--mobile-header-height);
        height: calc(100vh - var(--mobile-header-height));
        width: 280px;
        max-width: 85vw;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-rail.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    /* Improved backdrop */
    .nav-rail-backdrop {
        position: fixed;
        top: var(--mobile-header-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }

    .nav-rail-backdrop.show {
        opacity: 1;
        visibility: visible;
    }

    /* Larger nav items for touch */
    .nav-rail-item {
        min-height: var(--touch-target-comfortable);
        padding: 0.875rem 1rem;
        font-size: 0.9375rem;
    }

    .nav-rail-item .icon {
        width: 24px;
        height: 24px;
        font-size: 1.125rem;
    }

    /* Hide collapse toggle on mobile */
    .nav-rail button[title*="Collapse"],
    .nav-rail button[title*="Expand"] {
        display: none;
    }

    /* Mobile nav toggle button - ensure visibility */
    .mobile-nav-toggle {
        display: flex !important;
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
    }
}

/* ========================================
   MOBILE CONTENT AREA
   ======================================== */

@media (max-width: 767.98px) {
    /* Adjust main content padding */
    #main-content {
        padding: var(--spacing-page) !important;
    }

    /* Full-width content on mobile */
    .container,
    .container-fluid {
        padding-left: var(--spacing-page);
        padding-right: var(--spacing-page);
    }

    /* Cards */
    .card {
        border-radius: 12px;
        margin-bottom: 0.75rem;
    }

    .card-body {
        padding: var(--spacing-card);
    }

    .card-header {
        padding: 0.875rem var(--spacing-card);
    }

    /* Documentation pages - no horizontal scroll, reduced padding */
    .documentation-content,
    .documentation-hub-content {
        max-width: 100% !important;
        padding: 0 0.5rem !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    .help-page {
        overflow-x: hidden !important;
    }

    .help-section {
        overflow-x: hidden !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .help-section pre,
    .help-section code {
        white-space: pre-wrap !important;
        word-break: break-all;
        max-width: 100% !important;
        overflow-x: auto;
    }

    .help-section table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100% !important;
    }

    .help-section img {
        max-width: 100% !important;
        height: auto !important;
    }
}


/* ========================================
   MOBILE GRID & LAYOUT UTILITIES
   ======================================== */

@media (max-width: 767.98px) {
    /* Flexbox utilities for mobile */
    .mobile-stack {
        flex-direction: column !important;
    }

    .mobile-gap-sm {
        gap: 0.5rem !important;
    }

    .mobile-gap-md {
        gap: 0.75rem !important;
    }

    /* Hide on mobile */
    .mobile-hidden,
    .hide-on-mobile {
        display: none !important;
    }

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

    /* Full width on mobile */
    .mobile-full-width {
        width: 100% !important;
    }
}

@media (min-width: 768px) {
    .mobile-only {
        display: none !important;
    }
}

/* ========================================
   KPI CARDS MOBILE LAYOUT
   ======================================== */

@media (max-width: 767.98px) {
    /* KPI grid - single column on mobile */
    .kpi-grid,
    .kpi-cards-grid,
    .stats-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.625rem !important;
    }

    /* Compact KPI cards */
    .kpi-card {
        padding: 0.875rem;
        border-radius: 10px;
    }

    .kpi-header {
        margin-bottom: 0.5rem;
    }

    .kpi-header h3 {
        font-size: 0.75rem;
        line-height: 1.3;
    }

    .kpi-value {
        font-size: 1.375rem !important;
        line-height: 1.2;
    }

    .kpi-label {
        font-size: 0.6875rem;
        margin-top: 0.25rem;
    }

    /* KPI info icon - slightly larger for touch */
    .kpi-info-icon,
    .info-icon {
        min-width: 24px;
        min-height: 24px;
    }
}

/* ========================================
   CHARTS MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 767.98px) {
    /* Chart grid - single column */
    .charts-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* Chart cards */
    .chart-card {
        border-radius: 12px;
        padding: 0.875rem;
    }

    .chart-header {
        margin-bottom: 0.625rem;
    }

    .chart-header h3 {
        font-size: 0.9375rem;
    }

    /* Chart cards - prevent overflow */
    .chart-card {
        overflow: hidden;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Reduce chart height on mobile and constrain width */
    .chart-container,
    .apexcharts-canvas {
        height: 250px !important;
        max-height: 280px;
        max-width: 100% !important;
        width: 100% !important;
        overflow: hidden;
    }

    /* Constrain SVG charts to container */
    .apexcharts-canvas svg,
    .chart-card svg {
        max-width: 100% !important;
        overflow: hidden;
    }

    /* ApexCharts specific mobile adjustments */
    .apexcharts-legend {
        padding: 8px 0 0 0 !important;
        flex-wrap: wrap;
        justify-content: center;
    }

    .apexcharts-legend-text {
        font-size: 11px !important;
    }

    .apexcharts-legend-series {
        margin: 2px 6px !important;
    }

    /* Hide chart toolbar on mobile */
    .apexcharts-toolbar {
        display: none !important;
    }

    /* Ensure inner chart wrapper doesn't overflow */
    .apexcharts-inner {
        max-width: 100%;
    }
}

/* ========================================
   FILTER & SEARCH MOBILE LAYOUT
   ======================================== */

@media (max-width: 767.98px) {
    /* Filter bar - stack vertically */
    .filter-bar,
    .search-controls,
    .filter-controls {
        flex-direction: column !important;
        gap: 0.625rem !important;
        padding: 0.875rem !important;
    }

    /* Filter groups take full width */
    .filter-group,
    .filter-field,
    .search-field {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Filter labels */
    .filter-label {
        font-size: 0.8125rem;
        margin-bottom: 0.375rem;
    }

    /* Collapsible filter panel */
    .search-card.collapsed .search-card-body {
        display: none;
    }

    .search-card .toggle-filters-btn {
        width: 100%;
        justify-content: space-between;
    }

    /* Advanced search fields grid */
    .advanced-search-row {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* Team/Project filter - full width */
    .team-filter-group,
    .project-filter-group {
        width: 100% !important;
    }
}


/* ========================================
   DATA TABLES MOBILE LAYOUT
   ======================================== */

@media (max-width: 767.98px) {
    /* Table container - horizontal scroll */
    .table-container,
    .data-table-container,
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 calc(var(--spacing-page) * -1);
        padding: 0 var(--spacing-page);
        /* Scroll indicator shadow */
        background:
            linear-gradient(to right, var(--bg-primary), var(--bg-primary)),
            linear-gradient(to right, var(--bg-primary), var(--bg-primary)),
            linear-gradient(to right, rgba(0, 0, 0, 0.1), transparent),
            linear-gradient(to left, rgba(0, 0, 0, 0.1), transparent);
        background-position: left center, right center, left center, right center;
        background-repeat: no-repeat;
        background-size: 20px 100%, 20px 100%, 10px 100%, 10px 100%;
        background-attachment: local, local, scroll, scroll;
    }

    /* Tables */
    .table,
    .modern-table,
    .hierarchy-table {
        min-width: 600px; /* Force horizontal scroll */
        font-size: 0.8125rem;
    }

    .table thead th,
    .modern-table thead th {
        position: sticky;
        top: 0;
        z-index: 10;
        font-size: 0.75rem;
        padding: 0.625rem 0.5rem;
        white-space: nowrap;
    }

    .table tbody td,
    .modern-table tbody td {
        padding: 0.625rem 0.5rem;
        vertical-align: middle;
    }

    /* Frozen first column */
    .frozen-columns .frozen-col,
    .hierarchy-table .frozen-col {
        position: sticky;
        left: 0;
        z-index: 5;
        background: var(--bg-primary);
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
    }

    [data-theme="dark"] .frozen-columns .frozen-col,
    [data-theme="dark"] .hierarchy-table .frozen-col {
        background: var(--bg-secondary);
    }

    /* Hierarchy indentation - reduce on mobile */
    .hierarchy-indent {
        width: 12px !important;
        min-width: 12px !important;
    }

    /* Work item title - truncate */
    .work-item-title,
    .item-title {
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* State badges - compact */
    .state-badge,
    .badge {
        font-size: 0.6875rem;
        padding: 0.25rem 0.5rem;
    }

    /* Results count and pagination */
    .results-panel-header {
        flex-direction: column !important;
        gap: 0.75rem;
        align-items: stretch !important;
    }

    .pagination {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .page-info {
        text-align: center;
        width: 100%;
    }
}

/* Very small screens - card view hint */
@media (max-width: 480px) {
    .table-scroll-hint {
        display: block;
        text-align: center;
        padding: 0.5rem;
        font-size: 0.75rem;
        color: var(--text-secondary);
        background: var(--bg-secondary);
        border-radius: 6px;
        margin-bottom: 0.5rem;
    }

    .table-scroll-hint::before {
        content: "← Scroll horizontally →";
    }
}

@media (min-width: 481px) {
    .table-scroll-hint {
        display: none;
    }
}

/* ========================================
   PAGE-SPECIFIC: DASHBOARD
   ======================================== */

@media (max-width: 767.98px) {
    .dashboard-modern,
    .dashboard-page {
        padding: 0;
    }

    /* Dashboard header - NOTE: page-specific styles in each .razor.css override this */
    .dashboard-header {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.875rem;
        align-items: stretch;
    }

    .dashboard-header .header-left {
        width: 100%;
    }

    /* Keep header icon and title same size as desktop */
    .dashboard-header .header-icon,
    .page-header .header-icon,
    .compact-header .header-icon {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    .dashboard-header .header-title,
    .page-header .header-title,
    .compact-header .header-title {
        font-size: 1.25rem;
    }

    /* Dashboard filter bar */
    .dashboard-filters {
        flex-direction: column;
        gap: 0.625rem;
    }

    /* Period selector as segmented control */
    .period-selector,
    .view-mode-selector {
        width: 100%;
        display: flex;
        background: var(--bg-tertiary);
        border-radius: 8px;
        padding: 4px;
    }

    .period-selector label,
    .view-mode-selector label {
        flex: 1;
        text-align: center;
        padding: 0.5rem 0.25rem;
        font-size: 0.8125rem;
        border-radius: 6px;
        transition: all 0.2s ease;
    }

    .period-selector input:checked + span,
    .view-mode-selector input:checked + span {
        background: var(--primary-color);
        color: var(--text-on-primary);
    }

    /* Section titles */
    .section-title {
        font-size: 1rem;
        margin: 1rem 0 0.75rem;
        padding: 0 var(--spacing-page);
    }
}

/* ========================================
   PAGE-SPECIFIC: EPICS
   ======================================== */

@media (max-width: 767.98px) {
    .epics-modern {
        padding: 0 var(--spacing-page);
    }

    /* Compact header */
    .compact-header {
        padding: 0.75rem 0;
        margin-bottom: 0.75rem;
    }

    .compact-header .header-left {
        gap: 0.5rem;
    }

    .compact-header .header-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .compact-header .header-title {
        font-size: 1.125rem;
    }

    /* Quick filters row - horizontal scroll */
    .quick-filters-row {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
        margin: 0 calc(var(--spacing-page) * -1);
        padding-left: var(--spacing-page);
        padding-right: var(--spacing-page);
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .quick-filters-row::-webkit-scrollbar {
        display: none;
    }

    .quick-filters-row .filter-pill {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Search card */
    .search-card {
        margin-bottom: 0.75rem;
        border-radius: 12px;
    }

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

    .search-card-body {
        padding: 1rem;
    }

    /* Results panel */
    .results-panel {
        border-radius: 12px;
    }

    .results-panel-header {
        padding: 0.875rem;
    }

    /* Header actions - NOTE: page-specific styles in each .razor.css handle mobile layout */

    /* Fullscreen mode on mobile - use entire screen */
    .results-fullscreen {
        position: fixed;
        top: var(--mobile-header-height);
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        margin: 0;
        border-radius: 0;
        background: var(--bg-primary);
    }
}

/* ========================================
   PAGE-SPECIFIC: TEAMS
   ======================================== */

@media (max-width: 767.98px) {
    .teams-page {
        padding: 0 var(--spacing-page);
    }

    /* Teams container - stack panels */
    .teams-container {
        flex-direction: column !important;
        gap: 0;
    }

    /* Team list panel - collapsible on mobile */
    .teams-list-panel {
        width: 100% !important;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .teams-list-panel.collapsed {
        max-height: 56px;
        overflow: hidden;
    }

    .teams-list-panel .panel-header {
        padding: 0.875rem;
    }

    /* Team list - horizontal scroll or compact */
    .team-list {
        max-height: 200px;
        overflow-y: auto;
    }

    .team-item {
        padding: 0.75rem;
        min-height: var(--touch-target-min);
    }

    .team-item .team-info {
        flex: 1;
        min-width: 0;
    }

    .team-item .team-name {
        font-size: 0.9375rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .team-item .team-meta {
        font-size: 0.75rem;
        gap: 0.5rem;
    }

    .team-item .team-actions {
        gap: 0.25rem;
    }

    .team-item .btn-icon {
        width: 36px;
        height: 36px;
    }

    /* Team details panel */
    .team-details-panel {
        width: 100% !important;
        min-height: 400px;
    }

    .team-details-panel .panel-header {
        padding: 0.875rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .team-details-panel .panel-header h2 {
        font-size: 1.125rem;
        flex: 1;
        min-width: 200px;
    }

    /* No selection state */
    .no-selection-state {
        padding: 2rem 1rem;
    }

    .no-selection-state i {
        font-size: 2rem;
        margin-bottom: 0.75rem;
    }

    /* Tabs - scrollable */
    .team-tabs,
    .nav-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    .team-tabs::-webkit-scrollbar,
    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .team-tabs .nav-link,
    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 0.75rem 1rem;
        min-height: var(--touch-target-min);
    }

    /* Tab content */
    .tab-content {
        padding: 1rem;
    }
}

/* ========================================
   PAGE-SPECIFIC: WORK ITEMS
   ======================================== */

@media (max-width: 767.98px) {
    .work-items-modern {
        padding: 0 var(--spacing-page);
    }

    /* Search hero - compact */
    .search-hero {
        padding: 1rem;
        border-radius: 12px;
        margin-bottom: 0.75rem;
    }

    .hero-title {
        font-size: 1.25rem;
    }

    .hero-subtitle {
        font-size: 0.8125rem;
    }
}

/* ========================================
   MODALS & DIALOGS MOBILE
   ======================================== */

@media (max-width: 767.98px) {
    /* Modal backdrop */
    .modal-backdrop {
        background: rgba(0, 0, 0, 0.6);
    }

    /* Modal dialog - full width on mobile */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-dialog-centered {
        min-height: calc(100% - 1rem);
    }

    /* Large modals - nearly full screen */
    .modal-lg,
    .modal-xl {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }

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

    /* Modal content */
    .modal-content {
        border-radius: 16px 16px 0 0;
    }

    .modal-header {
        padding: 1rem;
        border-radius: 16px 16px 0 0;
    }

    .modal-title {
        font-size: 1.125rem;
    }

    .modal-body {
        padding: 1rem;
        max-height: 60vh;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        flex: 1;
        min-width: 120px;
    }

    /* Close button */
    .btn-close {
        width: 44px;
        height: 44px;
        padding: 0;
    }
}

/* ========================================
   DROPDOWNS & POPOVERS MOBILE
   ======================================== */

@media (max-width: 767.98px) {
    /* Dropdown menus - full width */
    .dropdown-menu {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        transform: none !important;
        border-radius: 16px 16px 0 0;
        max-height: 70vh;
        overflow-y: auto;
        margin: 0;
        border: none;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }

    .dropdown-item {
        padding: 0.875rem 1rem;
        min-height: var(--touch-target-min);
    }

    /* Multi-select dropdown - bottom sheet */
    .multi-select-dropdown .dropdown-menu,
    .multiselect-dropdown-menu {
        max-height: 60vh;
    }

    /* Popovers */
    .popover {
        max-width: calc(100vw - 1rem);
    }

    .simple-popover-portal {
        max-width: calc(100vw - 1rem);
    }

    /* Tooltips - hide on touch devices by default */
    .touch-device [data-tooltip]::after,
    .touch-device [data-tooltip]::before {
        display: none;
    }
}

/* ========================================
   LOADING STATES MOBILE
   ======================================== */

@media (max-width: 767.98px) {
    .loading-spinner,
    .loading-overlay {
        padding: 2rem 1rem;
    }

    .spinner-large {
        width: 48px;
        height: 48px;
    }

    .loading-text {
        font-size: 0.875rem;
    }
}

/* ========================================
   EMPTY STATES MOBILE
   ======================================== */

@media (max-width: 767.98px) {
    .empty-state {
        padding: 2rem 1rem;
    }

    .empty-state-icon {
        font-size: 3rem;
    }

    .empty-state-title {
        font-size: 1.125rem;
    }

    .empty-state-description {
        font-size: 0.875rem;
    }
}

/* ========================================
   AgentAI CHAT PANEL MOBILE
   ======================================== */

@media (max-width: 767.98px) {
    /* Hide footer when chat panel is open on mobile */
    .app-footer.chat-panel-open {
        display: none;
    }

    /* Chat panel - full screen on mobile */
    .agent-ai-chat-panel {
        position: fixed !important;
        top: var(--mobile-header-height) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0;
        z-index: 1001;
    }

    .agent-ai-chat-panel .panel-header {
        padding: 0.875rem;
    }

    .agent-ai-chat-panel .chat-messages {
        padding: 0.75rem;
    }

    .agent-ai-chat-panel .chat-input-area {
        padding: 0.75rem;
    }

    .agent-ai-chat-panel .chat-input {
        min-height: var(--touch-target-min);
    }
}

/* ========================================
   PRINT MEDIA - PRESERVE FOR REPORTS
   ======================================== */

@media print {
    /* Reset mobile styles for print */
    .nav-rail,
    .app-header,
    .mobile-nav-toggle,
    .nav-rail-backdrop {
        display: none !important;
    }

    #main-content {
        padding: 0 !important;
        margin: 0 !important;
    }
}
