/* ThreatScope mobile compatibility overrides.
   Loaded after page-specific styles so the shared shell stays consistent. */

@media (max-width: 1024px) {
    .dashboard-layout {
        display: block;
        width: 100%;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: min(84vw, 320px);
        height: 100vh;
        max-height: none;
        border-right: 1px solid #e8e9ed;
        border-bottom: 0;
        overflow-y: auto;
        transform: translateX(-100%);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .main-content {
        --main-content-x: 20px;
        width: 100%;
        margin-left: 0;
        padding: 20px;
    }

    .header,
    .threats-header,
    .results-header,
    .card-header,
    .modern-card-header,
    .modal-header,
    .ai-modal-header,
    .au-modal-foot,
    .modal-footer,
    .modal-foot {
        flex-wrap: wrap;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .header-right {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .stats-row,
    .modern-grid,
    .content-grid,
    .quick-actions-grid,
    .map-layout,
    .ag-layout,
    .gr-grid {
        grid-template-columns: 1fr !important;
    }

    .map-sidebar {
        display: none !important;
    }

    .map-layout {
        height: auto !important;
        min-height: 0;
    }

    .map-container {
        height: min(68vh, 620px);
        min-height: 420px;
    }

    .ag-canvas-card {
        min-height: min(68vh, 620px) !important;
    }

    .ag-canvas-inner {
        height: min(68vh, 620px) !important;
    }

    .ag-toolbar,
    .map-controls,
    .filter-chips,
    .feed-actions,
    .ai-form-footer,
    .ak-actions,
    .au-actions,
    .au-bar,
    .form-row,
    .search-row,
    .scan-form,
    .action-buttons,
    .toolbar,
    .au-toolbar,
    .cred-toolbar {
        flex-wrap: wrap;
    }

    .ag-toolbar .ag-search,
    .search-input,
    .filter-input,
    .au-search,
    .au-search input,
    .gr-search,
    .u-search,
    .u-toolbar input[type=text],
    .scan-form input,
    .scan-form select {
        min-width: min(100%, 220px);
        width: 100%;
    }

    .map-stats-overlay {
        top: auto !important;
        right: 12px !important;
        left: 12px !important;
        bottom: 12px !important;
        min-width: 0 !important;
        max-width: none;
    }

    .toast-container,
    .notification-center {
        left: 12px !important;
        right: 12px !important;
        max-width: none !important;
        width: auto !important;
    }

    .modal-content,
    .modal,
    .modal-box,
    .ai-modal,
    .au-modal,
    .fsd-modal,
    .ad-modal {
        width: min(720px, calc(100vw - 24px)) !important;
        max-width: calc(100vw - 24px) !important;
        max-height: calc(100vh - 24px) !important;
        overflow-y: auto;
    }
}

@media (max-width: 768px) {
    .main-content {
        --main-content-x: 16px;
        padding: 16px;
    }

    .header-left h1,
    .threats-header h1 {
        font-size: 20px;
        line-height: 1.25;
    }

    .header-left p {
        max-width: none;
    }

    .stats-row,
    .quick-actions-grid,
    .modern-grid,
    .content-grid,
    .profile-grid,
    .info-grid,
    .summary-grid,
    .stats-mini,
    .stats-grid,
    .risk-grid,
    .actor-grid,
    .cve-grid,
    .source-grid,
    .ak-grid,
    .subdomain-stats,
    .attack-surface-stats,
    .ad-kpi-grid,
    .ad-mid-grid {
        grid-template-columns: 1fr !important;
    }

    .hero-content {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 20px !important;
    }

    .hero-header {
        padding: 22px 18px !important;
        border-radius: 14px !important;
    }

    .hero-quick-stats {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding: 14px !important;
    }

    .quick-stat-divider {
        display: none;
    }

    .card,
    .modern-card,
    .stat-card,
    .ad-content-card,
    .ad-table-card,
    .search-box,
    .results-card,
    .profile-card {
        max-width: 100%;
        border-radius: 12px !important;
        padding: 16px !important;
    }

    .card-header,
    .modern-card-header,
    .results-header,
    .ad-table-head,
    .ad-pag-bar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }

    .btn-primary,
    .btn-outline,
    .btn-gradient,
    .censys-btn,
    .shodan-btn,
    .netlas-btn,
    .scan-btn,
    .search-btn,
    .export-btn,
    .au-btn,
    .ad-tb-btn {
        min-height: 38px;
        justify-content: center;
    }

    .tab-group {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
    }

    .map-container {
        height: 62vh;
        min-height: 360px;
        border-radius: 12px;
    }

    .map-controls {
        top: 10px !important;
        left: 10px !important;
        right: 10px;
        gap: 6px !important;
        padding: 8px !important;
    }

    .map-control-btn {
        flex: 1 1 calc(50% - 6px);
        justify-content: center;
        padding: 8px 10px !important;
    }

    .map-stats-overlay {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 12px;
        padding: 10px !important;
    }

    .ag-toolbar {
        padding: 10px !important;
    }

    .ag-toolbar .ag-search {
        flex-basis: 100%;
    }

    .ag-toolbar .ag-filter {
        flex: 1 1 calc(50% - 8px);
        justify-content: center;
    }

    .ag-toolbar .ag-ctl-sep {
        display: none;
    }

    .ag-canvas-card,
    .ag-canvas-inner {
        min-height: 420px !important;
        height: 56vh !important;
    }

    .ag-legend {
        left: 10px !important;
        right: 10px;
        bottom: 10px !important;
        flex-direction: row !important;
        flex-wrap: wrap;
    }

    .ag-zoom-ctl {
        right: 10px !important;
        top: 10px;
        bottom: auto !important;
    }

    .ad-actions {
        width: 100%;
        justify-content: flex-start !important;
    }

    .ad-last-scan {
        width: 100%;
        padding-left: 0 !important;
    }

    .ad-modal-row,
    .modal-row,
    .au-modal-body .fg-row,
    .u-detail-grid {
        grid-template-columns: 1fr !important;
    }

    .ad-modal-actions,
    .modal-actions,
    .modal-footer,
    .modal-foot,
    .au-modal-foot {
        flex-direction: column;
    }

    .table-wrap,
    .ad-table-wrap,
    .ad-tbl-wrap,
    .modern-card .ad-tbl-wrap,
    .record-table-wrap,
    .history-table-wrap,
    .results-table-wrap,
    .subdomain-table-wrap,
    .au-table-wrap,
    .task-table-wrap,
    .kev-table-wrap,
    [style*="overflow-x:auto"],
    [style*="overflow-x: auto"] {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    table,
    .ad-tbl,
    .ad-table,
    .u-tbl,
    .gr-tbl,
    .fs-tbl,
    .fs-shares-tbl,
    .fsd-acl-tbl,
    .sv-tbl,
    .cs-tbl,
    .kev-table,
    .prio-table,
    .subdomain-table,
    .history-table,
    .record-table,
    .au-tbl,
    .task-table {
        min-width: 680px;
    }

    .data-row,
    .ad-kv-row,
    .ag-kv,
    .danger-item,
    .activity-item {
        gap: 8px;
    }

    .ak-card-head,
    .au-actions,
    .u-toolbar,
    .gr-toolbar {
        align-items: stretch;
    }

    .ak-badge,
    .ak-actions .btn,
    .au-actions .au-btn,
    .u-toolbar .u-btn,
    .gr-toolbar .gr-btn {
        justify-content: center;
    }

    .ai-modal {
        border-radius: 14px !important;
    }

    .ai-fab {
        right: 16px !important;
        bottom: 16px !important;
    }
}

@media (max-width: 480px) {
    .main-content {
        --main-content-x: 12px;
        padding: 12px;
    }

    .mobile-brand span {
        max-width: 190px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-left h1,
    .threats-header h1,
    .hero-greeting h1 {
        font-size: 19px !important;
    }

    .hero-quick-stats,
    .map-stats-overlay {
        grid-template-columns: 1fr;
    }

    .action-card,
    .modern-threat-item,
    .country-item,
    .as-stat {
        align-items: flex-start;
    }

    .map-control-btn,
    .ag-toolbar .ag-filter,
    .ad-actions .ad-tb-btn {
        flex-basis: 100%;
    }

    .modal-body,
    .ai-modal-body,
    .au-modal-body {
        padding: 16px !important;
    }

    .ak-card-head,
    .au-actions,
    .u-toolbar,
    .gr-toolbar {
        flex-direction: column;
    }

    .ak-grid {
        grid-template-columns: 1fr !important;
    }
}
