/* ── Shared Styles + Mobile Optimizations ── */
/* Include on every page: <link rel="stylesheet" href="mobile.css"> */

/* Agent photos — zoom in 25% and push up to show faces better */
.sidebar-avatar img {
    object-fit: cover;
    object-position: center 15%;
    transform: scale(1.25);
}
.leader-photo {
    object-position: center 15% !important;
    transform: scale(1.25) !important;
}
.leader-picker-item img {
    object-position: center 15%;
    transform: scale(1.25);
}

/* Mobile nav toggle button (hidden on desktop) */
.mobile-nav-toggle {
    display: none;
    position: fixed; top: 12px; left: 12px; z-index: 200;
    width: 36px; height: 36px; border-radius: 8px;
    border: 1px solid #E5E7EB; background: #FFFFFF;
    align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.mobile-nav-toggle svg { width: 18px; height: 18px; stroke: #191A1A; fill: none; stroke-width: 2; stroke-linecap: round; }

/* Mobile overlay behind sidebar */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(25,26,26,0.4); z-index: 99;
}

@media (max-width: 900px) {
    /* Show hamburger */
    .mobile-nav-toggle { display: flex; }

    /* Sidebar: off-screen by default, slide in */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 100;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }

    /* Main content: full width */
    .main {
        margin-left: 0 !important;
        padding: 16px !important;
        padding-top: 56px !important; /* room for hamburger */
    }

    /* Page header */
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
        margin-bottom: 20px !important;
    }
    .page-header h1 { font-size: 22px !important; }
    .header-actions { width: 100%; justify-content: flex-start; }

    /* Filter bars & controls — wrap and scroll */
    .filter-bar, .controls {
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 8px 0 !important;
    }
    .filter-select, .ctrl-select, .ctrl-date {
        font-size: 11px !important;
        padding: 6px 24px 6px 10px !important;
        min-width: 0 !important;
    }
    .ctrl-date { width: 115px !important; }
    .toggle-group { flex-shrink: 0; }
    .toggle-btn { padding: 5px 10px !important; font-size: 10px !important; }
    .ctrl-spacer { display: none; }

    /* Metric cards grid */
    .metrics-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    /* Summary rows */
    .summary-row {
        flex-direction: column !important;
        gap: 8px !important;
    }

    /* Cards */
    .card, .chart-card, .metric-card, .summary-card {
        padding: 14px 16px !important;
        border-radius: 10px !important;
    }
    .card-title, .chart-title { font-size: 14px !important; }
    .card-sub, .chart-subtitle { font-size: 11px !important; }
    .metric-card-value { font-size: 28px !important; }
    .summary-value { font-size: 26px !important; }

    /* Tables — horizontal scroll */
    .impact-table, .source-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .impact-table th, .impact-table td,
    .source-table th, .source-table td {
        white-space: nowrap;
        padding: 8px 10px !important;
        font-size: 12px !important;
    }

    /* Transaction grid — stack */
    .table-row {
        grid-template-columns: 1fr !important;
        gap: 4px !important;
        padding: 12px !important;
    }
    .table-header { display: none !important; }

    /* Agent bar — scroll horizontally */
    .agent-bar {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .agent-bar::-webkit-scrollbar { display: none; }

    /* Agent picker dropdown */
    .agent-picker-dropdown {
        min-width: 200px !important;
        max-height: 260px !important;
    }

    /* Action bar */
    .action-bar {
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    /* Modals — full width on mobile */
    .modal {
        width: 95vw !important;
        max-width: 95vw !important;
        padding: 20px !important;
        border-radius: 12px !important;
    }

    /* Panel sheets */
    .panel-sheet {
        max-height: 85vh !important;
        border-radius: 16px 16px 0 0 !important;
    }

    /* Charts — ensure they fit */
    .chart-container, .chart-wrap {
        min-height: 260px !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Legend */
    .legend, .chart-legend {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    /* User bar */
    .user-bar {
        top: 8px !important;
        right: 12px !important;
    }

    /* Stats rows / grids */
    .stats-row {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    /* Learning page */
    .courses-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }
    .continue-card {
        flex-direction: column !important;
    }

    /* Rewards grid */
    .rewards-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    /* Resources topics grid */
    .topics-grid {
        grid-template-columns: 1fr !important;
    }
    .groups-grid {
        grid-template-columns: 1fr !important;
    }

    /* Goals months grid */
    .months-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Hide non-essential on mobile */
    .peek-btn { display: none !important; }
}

@media (max-width: 480px) {
    .main {
        padding: 12px !important;
        padding-top: 52px !important;
    }
    .page-header h1 { font-size: 20px !important; }

    .metrics-grid {
        grid-template-columns: 1fr !important;
    }
    .courses-grid, .rewards-grid {
        grid-template-columns: 1fr !important;
    }
    .stats-row {
        grid-template-columns: 1fr !important;
    }
    .months-grid {
        grid-template-columns: 1fr !important;
    }
    .metric-card-value { font-size: 24px !important; }
    .summary-value { font-size: 22px !important; }
}
