/**
 * AI Command Center — ultra-compact mobile (command_center.php).
 *
 * MOBILE LAYOUT TOGGLE (body class on command_center.php):
 *   cc-mobile-layout-drawer  — full-width content + slide-out Topics menu (default)
 *   cc-mobile-layout-split   — prior half-width left rail (revert if drawer looks worse)
 */

body.panel-chrome.command-center-shell-theme {
    overflow-x: hidden;
}

body.panel-chrome.command-center-shell-theme .command-center.ac-panel-page {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

.cc-mobile-nav-bar,
.cc-mobile-nav-backdrop {
    display: none;
}

@media (max-width: 992px) {
    body.panel-chrome.command-center-shell-theme .command-center.ac-panel-page {
        --aeris-sidebar-w: 100%;
        --aeris-main-gutter-right: 0;
        --cc-m-fs-body: 0.625rem;
        --cc-m-fs-small: 0.5625rem;
        --cc-m-fs-micro: 0.5rem;
        --cc-m-fs-stat: 0.75rem;
        --cc-m-gap: 4px;
        padding-left: 6px !important;
        padding-right: 6px !important;
        font-size: var(--cc-m-fs-body);
        line-height: 1.25;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-shell.ac-layout-shell {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        width: 100% !important;
        max-width: 100% !important;
        column-gap: 0 !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-main.ac-main-with-gutter {
        order: 1;
        flex: 1 1 auto !important;
        grid-column: auto !important;
        grid-row: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        overflow-x: hidden;
    }

    /* —— Drawer layout (default): full-width main + slide-out topic menu —— */
    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-drawer .cc-mobile-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1290;
        background: rgba(2, 6, 23, 0.62);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }

    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-drawer .cc-mobile-nav-backdrop[hidden] {
        display: none !important;
    }

    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-drawer .cc-mobile-nav-bar {
        display: flex;
        align-items: center;
        gap: 8px;
        position: sticky;
        top: 0;
        z-index: 1100;
        margin: 0 0 6px;
        padding: 6px 8px;
        border-radius: 8px;
        border: 1px solid rgba(56, 189, 248, 0.35);
        background: rgba(12, 19, 40, 0.92);
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    }

    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-drawer .cc-mobile-nav-toggle {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
        border: 1px solid rgba(56, 189, 248, 0.45);
        border-radius: 999px;
        background: rgba(56, 189, 248, 0.14);
        color: #e0f2fe;
        font-size: var(--cc-m-fs-small);
        font-weight: 600;
        padding: 5px 10px;
        cursor: pointer;
    }

    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-drawer .cc-mobile-nav-current {
        flex: 1 1 auto;
        min-width: 0;
        font-size: var(--cc-m-fs-small);
        font-weight: 600;
        color: #bae6fd;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-drawer .command-center .cc-sidebar.ac-sidebar-card {
        order: 2;
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1300;
        width: min(82vw, 260px) !important;
        max-width: min(82vw, 260px) !important;
        flex: none !important;
        margin: 0;
        border-radius: 0 12px 12px 0 !important;
        box-shadow: 8px 0 28px rgba(0, 0, 0, 0.45);
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
        gap: 2px;
        padding: 10px 8px !important;
    }

    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-drawer.cc-nav-open .command-center .cc-sidebar.ac-sidebar-card {
        transform: translateX(0);
    }

    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-drawer .command-center .cc-sidebar h3 {
        font-size: var(--cc-m-fs-small) !important;
        margin: 8px 4px 4px !important;
    }

    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-drawer .command-center .cc-sidebar > a {
        font-size: var(--cc-m-fs-body) !important;
        padding: 7px 8px !important;
        min-height: 32px;
    }

    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-drawer .command-center .cc-sidebar > a i {
        font-size: 0.6875rem !important;
        width: 14px;
    }

    /* —— Split layout (revert): narrow left rail beside content —— */
    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-split .cc-mobile-nav-bar,
    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-split .cc-mobile-nav-backdrop {
        display: none !important;
    }

    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-split .command-center .cc-shell.ac-layout-shell {
        flex-direction: row !important;
        column-gap: var(--cc-m-gap) !important;
    }

    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-split .command-center .cc-main.ac-main-with-gutter {
        order: 2;
        width: auto !important;
        max-width: none !important;
    }

    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-split .command-center .cc-sidebar.ac-sidebar-card {
        order: 1;
        position: static !important;
        transform: none !important;
        flex: 0 0 38% !important;
        width: 38% !important;
        max-width: 140px !important;
        min-width: 0 !important;
        max-height: calc(100dvh - 120px) !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        display: grid;
        grid-template-columns: 1fr;
        column-gap: 0;
        row-gap: 3px;
        padding: 6px 4px !important;
        border-radius: 10px !important;
        box-shadow: none;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-sidebar h3 {
        grid-column: 1 / -1;
        font-size: var(--cc-m-fs-micro) !important;
        margin: 4px 0 2px !important;
        letter-spacing: 0.06em;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-sidebar > a {
        margin-bottom: 0 !important;
        padding: 4px 5px !important;
        font-size: var(--cc-m-fs-micro) !important;
        white-space: normal !important;
        gap: 4px !important;
        min-height: 26px;
        border-radius: 6px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-sidebar > a i {
        font-size: 0.5625rem !important;
        width: 10px;
        flex-shrink: 0;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-sidebar a span {
        white-space: normal !important;
        line-height: 1.15;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-rail-spacer {
        display: none !important;
    }

    /* All five stats on one row */
    body.panel-chrome.command-center-shell-theme .command-center .stats-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
        gap: var(--cc-m-gap) !important;
        overflow-x: visible !important;
        margin-bottom: 6px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .stat-panel {
        padding: 4px 2px !important;
        min-width: 0;
        border-radius: 6px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .stat-panel:hover {
        transform: none;
    }

    body.panel-chrome.command-center-shell-theme .command-center .stat-panel .label {
        font-size: 0.4375rem !important;
        letter-spacing: 0.02em;
        margin-bottom: 2px !important;
        line-height: 1.1;
    }

    body.panel-chrome.command-center-shell-theme .command-center .stat-panel .value {
        font-size: var(--cc-m-fs-stat) !important;
        text-shadow: none !important;
        line-height: 1.1;
    }

    body.panel-chrome.command-center-shell-theme .command-center .quick-actions {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: var(--cc-m-gap) !important;
        margin-bottom: 6px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .quick-action-btn {
        font-size: var(--cc-m-fs-micro) !important;
        padding: 5px 3px !important;
        letter-spacing: 0;
        border-radius: 6px !important;
        line-height: 1.15;
    }

    body.panel-chrome.command-center-shell-theme .command-center .quick-action-btn:hover {
        transform: none;
    }

    body.panel-chrome.command-center-shell-theme .command-center .quick-action-btn i {
        font-size: 0.6875rem !important;
        margin-bottom: 2px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .panels-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 6px !important;
        margin-bottom: 6px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .panel-links.panel-links-compact {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: var(--cc-m-gap) !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .panel-group-title {
        font-size: var(--cc-m-fs-micro) !important;
        padding: 4px 2px 1px !important;
        margin-bottom: 0 !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .control-panel {
        padding: 6px 5px !important;
        border-radius: 8px !important;
        border-width: 1px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .control-panel:hover {
        transform: none;
    }

    body.panel-chrome.command-center-shell-theme .command-center .panel-header {
        margin-bottom: 6px !important;
        padding-bottom: 4px !important;
        gap: 4px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .panel-header i {
        font-size: 0.75rem !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .panel-header h3 {
        font-size: var(--cc-m-fs-small) !important;
        letter-spacing: 0.04em;
    }

    body.panel-chrome.command-center-shell-theme .command-center .panel-link {
        font-size: var(--cc-m-fs-micro) !important;
        padding: 4px 6px !important;
        min-height: 26px;
        gap: 4px !important;
        border-radius: 5px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .panel-link i {
        font-size: 0.5625rem !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .link-badge {
        font-size: 0.4375rem !important;
        padding: 1px 4px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-gateway-site-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        gap: var(--cc-m-gap) !important;
        margin-bottom: 6px !important;
        padding-bottom: 2px;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-gateway-site-tab {
        flex: 0 0 auto;
        font-size: var(--cc-m-fs-micro) !important;
        padding: 3px 8px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway-body {
        min-height: 260px !important;
    }

    /* Command Gateway — horizontal tool tabs (full-width content below) */
    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-layout {
        flex-direction: column !important;
        align-items: stretch !important;
        min-height: 240px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-sidebar {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        flex: 0 0 auto !important;
        padding: 6px 4px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-sidebar .nav.flex-column {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: 6px !important;
        padding-bottom: 2px;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-sidebar .nav-item {
        flex: 0 0 auto;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-sidebar hr,
    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-sidebar h6,
    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-sidebar .nav-item > span.text-info,
    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-sidebar .nav-item > span.text-uppercase {
        display: none !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-sidebar .nav-link,
    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-sidebar .cc-gateway-tool-link {
        font-size: var(--cc-m-fs-small) !important;
        padding: 6px 10px !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        border-radius: 999px !important;
        border: 1px solid rgba(255, 255, 255, 0.14) !important;
        background: rgba(255, 255, 255, 0.06) !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-sidebar .nav-link[style*="background-color"],
    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-sidebar .cc-gateway-tool-link[style*="background-color"] {
        border-color: rgba(13, 110, 253, 0.55) !important;
        background: rgba(13, 110, 253, 0.28) !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-layout > .flex-grow-1 {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-widgets {
        padding: 8px 6px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-widgets .row {
        --bs-gutter-x: 6px;
        --bs-gutter-y: 6px;
        margin-bottom: 6px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-widgets .card {
        font-size: var(--cc-m-fs-micro) !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway .cc-gateway-widgets .card-body {
        padding: 6px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway {
        padding: 6px !important;
        border-radius: 8px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .command-header {
        padding: 5px 6px !important;
        margin-bottom: 4px !important;
        gap: 4px !important;
        border-radius: 6px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .command-title h1 {
        font-size: var(--cc-m-fs-small) !important;
        letter-spacing: 0.06em;
    }

    body.panel-chrome.command-center-shell-theme .command-center .command-title > .fas {
        font-size: var(--cc-m-fs-small) !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .status-indicator {
        width: 6px;
        height: 6px;
        margin-right: 6px;
    }

    body.panel-chrome.command-center-shell-theme .command-center .command-header-badge {
        font-size: 0.4375rem !important;
        padding: 1px 5px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .command-header-actions .commander-info .name {
        font-size: var(--cc-m-fs-micro) !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .command-header-actions .commander-info .role {
        font-size: 0.4375rem !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .command-header-btn {
        font-size: 0.4375rem !important;
        padding: 2px 6px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-global-search-input {
        font-size: var(--cc-m-fs-body) !important;
        padding: 4px 8px 4px 28px !important;
        min-height: 28px;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-global-search-wrap i {
        font-size: 0.625rem !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-mission-nav {
        padding: 3px 4px !important;
        margin-bottom: 4px !important;
        gap: 3px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-mission-nav a.nav-single-btn,
    body.panel-chrome.command-center-shell-theme .command-center .cc-mission-nav .nav-dropdown-btn {
        font-size: var(--cc-m-fs-micro) !important;
        padding: 0 4px !important;
        height: 20px !important;
        min-height: 20px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-mission-nav a.nav-single-btn i,
    body.panel-chrome.command-center-shell-theme .command-center .cc-mission-nav .nav-dropdown-btn > i {
        font-size: 0.5rem !important;
    }

    body.panel-chrome.command-center-shell-theme #apf-panel-footer-strip.cc-footer-shell {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        padding: 6px 4px !important;
        margin-top: 6px !important;
        font-size: var(--cc-m-fs-micro) !important;
    }

    body.panel-chrome.command-center-shell-theme #apf-panel-footer-strip .cc-footer-col {
        grid-column: auto !important;
        width: 100% !important;
    }

    body.panel-chrome.command-center-shell-theme .cc-quick-fab {
        right: 6px;
        bottom: 8px;
        transform: scale(0.85);
        transform-origin: bottom right;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-global-search {
        flex: 1 1 100%;
        max-width: 100%;
    }

    /* Inline layout grids inside topic panels */
    body.panel-chrome.command-center-shell-theme .command-center .control-panel [style*="grid-template-columns"] {
        gap: 6px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .control-panel p,
    body.panel-chrome.command-center-shell-theme .command-center .control-panel li,
    body.panel-chrome.command-center-shell-theme .command-center .control-panel label {
        font-size: var(--cc-m-fs-micro) !important;
        line-height: 1.25 !important;
    }
}

@media (max-width: 480px) {
    body.panel-chrome.command-center-shell-theme .command-center.ac-panel-page {
        --cc-m-fs-body: 0.5625rem;
        --cc-m-fs-small: 0.5rem;
        --cc-m-fs-micro: 0.4375rem;
        --cc-m-fs-stat: 0.6875rem;
        --cc-m-gap: 3px;
        padding-left: 4px !important;
        padding-right: 4px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .stats-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
        gap: 3px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .stat-panel .label {
        font-size: 0.375rem !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .stat-panel .value {
        font-size: var(--cc-m-fs-stat) !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .quick-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .panels-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 4px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .panel-links.panel-links-compact {
        grid-template-columns: 1fr !important;
    }

    body.panel-chrome.command-center-shell-theme.cc-mobile-layout-split .command-center .cc-sidebar.ac-sidebar-card {
        flex: 0 0 36% !important;
        width: 36% !important;
        max-width: 120px !important;
        padding: 4px 3px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-sidebar > a {
        min-height: 24px;
        padding: 3px 4px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .command-header-contacts {
        max-height: 40px;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    body.panel-chrome.command-center-shell-theme .command-center .command-header-contacts .command-header-badge {
        flex: 0 0 auto;
    }

    body.panel-chrome.command-center-shell-theme .command-center .cc-command-gateway-body {
        min-height: 220px !important;
    }

    body.panel-chrome.command-center-shell-theme .command-center .command-title h1 {
        font-size: var(--cc-m-fs-micro) !important;
    }
}
