/* ══════════════════════════════════════════════
   Mobile Responsive — Prisme / Vertigo
   Shared across all 14 screens
   ══════════════════════════════════════════════ */

/* ─── Prevent horizontal overflow ─── */
html, body {
    overflow-x: hidden;
}

/* ─── Hamburger button (hidden by default) ─── */
.hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-white);
    cursor: pointer;
    flex-shrink: 0;
}
.hamburger-btn i {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

/* ─── Sidebar overlay ─── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 99;
}
.sidebar-overlay.open {
    display: block;
}

/* ══════════════════════════════════════════════
   Tablet — max 1024px
   ══════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .grid-2,
    .grid-1-2,
    .grid-2-1,
    .grid-3-2 {
        grid-template-columns: 1fr;
    }
    .grid-3 {
        grid-template-columns: 1fr 1fr;
    }
    .kpi-row {
        grid-template-columns: repeat(3, 1fr);
    }
    .profile-hero,
    .opp-hero,
    .project-hero {
        flex-direction: column;
    }
    .profile-kpis {
        margin-left: 0;
    }
}

/* ══════════════════════════════════════════════
   Mobile — max 768px
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ─── Sidebar slide-out ─── */
    .sidebar {
        transform: translateX(-100%);
        transition: transform .3s ease;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .hamburger-btn {
        display: flex;
    }

    /* ─── Topbar ─── */
    .topbar {
        padding: 10px 12px;
        gap: 8px;
        flex-wrap: wrap;
    }
    .topbar-left {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }
    .topbar-title {
        font-size: 16px;
    }
    .topbar-right {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
    }
    .topbar-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    .topbar-date {
        display: none;
    }

    /* ─── Page content ─── */
    .page-content,
    .dashboard {
        padding: 14px;
        gap: 14px;
    }

    /* ─── Proto banner ─── */
    .proto-banner {
        font-size: 10px;
        padding: 5px 12px;
    }

    /* ─── Grids: single column ─── */
    .grid-2,
    .grid-1-2,
    .grid-2-1,
    .grid-3-2,
    .grid-3 {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }

    /* ─── KPI rows: always 2 cols on mobile ─── */
    .kpi-row {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px;
    }
    .kpi-card {
        padding: 12px;
    }
    .kpi-value {
        font-size: 20px;
    }
    .kpi-label {
        font-size: 11px;
    }
    .kpi-top {
        margin-bottom: 6px;
    }
    .kpi-icon {
        width: 30px;
        height: 30px;
        border-radius: 6px;
    }
    .kpi-icon i {
        width: 15px;
        height: 15px;
    }

    /* ─── Cards ─── */
    .section-card {
        border-radius: 8px;
    }
    .section-body {
        padding: 12px;
    }
    .section-header {
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 6px;
    }

    /* ─── Tables: horizontal scroll ─── */
    .table-projects,
    .scenario-table,
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ─── Timesheet wrapper scroll ─── */
    .ts-grid-wrapper,
    .ts-grid {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ─── 01 Dashboard ─── */
    .chart-bars {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .gauge-row {
        flex-direction: column;
        gap: 8px;
    }
    .gauge-label {
        width: auto;
    }
    .table-mini {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ─── 02 Rentabilite ─── */
    .margin-bar {
        width: 50px;
    }
    .budget-track {
        width: 50px;
    }
    .filter-chip {
        font-size: 11px;
        padding: 4px 8px;
    }

    /* ─── 03 Detail projet ─── */
    .project-hero {
        flex-direction: column;
    }
    .person-row {
        flex-wrap: wrap;
        gap: 8px;
    }
    .person-bar {
        width: 60px;
    }

    /* ─── 04 Previsionnel CA ─── */
    .forecast-chart {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }

    /* ─── 05 Planning charge ─── */
    .grid-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }
    .grid-wrapper table,
    .grid-wrapper > div {
        min-width: 600px;
    }

    /* ─── 07 Fiche collaborateur ─── */
    .profile-hero {
        flex-direction: column;
        padding: 14px;
    }
    .profile-kpis {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
    }
    .profile-name {
        font-size: 20px;
    }
    .skill-name {
        width: 80px;
        font-size: 11px;
    }
    .history-row {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* ─── 08 Saisie temps ─── */
    .week-summary {
        flex-wrap: wrap;
        gap: 10px;
    }
    .ws-divider {
        display: none;
    }

    /* ─── 09 Pipe commercial ─── */
    .kanban {
        flex-direction: column;
    }
    .kanban-col {
        min-width: 100%;
    }
    .detail-overlay {
        width: 100% !important;
        right: -100% !important;
    }
    .detail-overlay.open {
        right: 0 !important;
    }
    .funnel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ─── 10 Detail opportunite ─── */
    .opp-hero {
        flex-direction: column;
    }
    .stage-track {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .score-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* ─── 11 Alertes IA ─── */
    .summary-bar {
        flex-direction: column;
    }
    .alert-card {
        flex-wrap: wrap;
    }
    .alert-actions {
        flex-wrap: wrap;
        width: 100%;
    }

    /* ─── 13 Simulateur ─── */
    .hypo-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    .hypo-label {
        width: auto;
    }

    /* ─── 14 Tendances ─── */
    .chart-area {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .bar-chart {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }
    .trend-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* ─── AI insight bars ─── */
    .ai-insight-bar,
    .ai-bar,
    .ai-alert {
        font-size: 12px;
        padding: 12px;
    }

    /* ─── Breadcrumb ─── */
    .breadcrumb {
        font-size: 12px;
        flex-wrap: wrap;
    }
}

/* ══════════════════════════════════════════════
   Small mobile — max 400px
   ══════════════════════════════════════════════ */
@media (max-width: 400px) {
    .topbar {
        padding: 8px 10px;
    }
    .topbar-right {
        width: 100%;
        justify-content: flex-end;
    }
    .topbar-btn i {
        display: none;
    }
    .page-content,
    .dashboard {
        padding: 10px;
        gap: 10px;
    }
    .kpi-card {
        padding: 10px;
    }
    .kpi-value {
        font-size: 18px;
    }
    .profile-meta {
        flex-direction: column;
        gap: 6px;
    }
    .section-body {
        padding: 10px;
    }
}
