/* =====================================================================
   Business Map | Dubai Mall — style.css
   ===================================================================== */
:root {
    --header-h: 64px;
    --tabs-h: 48px;
    --bg: #F3F4F6;
    --surface: #FFFFFF;
    --surface-2: #F8F9FB;
    --ink: #111317;
    --ink-2: #4B5160;
    --muted: #8A909C;
    --border: #E4E6EB;
    --accent: #2A78D6;
    --accent-soft: #E7F0FC;
    --good: #0B8A3E;
    --critical: #D03B3B;
    --warning: #B7790B;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    color: var(--ink);
    background: var(--bg);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
body.is-loading .bm-main { opacity: .6; transition: opacity .15s; }

/* ===================== HEADER ===================== */
.bm-header {
    height: var(--header-h);
    background: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 16px;
}
.bm-brand { display: flex; align-items: baseline; gap: 10px; font-size: 20px; white-space: nowrap; }
.bm-brand-main { font-weight: 700; letter-spacing: -.01em; }
.bm-brand-sep { color: #5F6470; font-weight: 300; }
.bm-brand-sub { font-weight: 400; color: #fff; }
.bm-header-right { display: flex; align-items: center; gap: 16px; min-width: 0; }
.bm-period-label { color: #A5AAB5; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-pills { display: flex; gap: 4px; background: #1B1C1F; padding: 4px; border-radius: 999px; }
.pill {
    border: none; background: transparent; color: #D4D7DD;
    padding: 8px 18px; border-radius: 999px; cursor: pointer;
    font-size: 13px; font-weight: 600; transition: background .15s, color .15s;
}
.pill:hover { color: #fff; background: #2A2C31; }
.pill.active { background: #fff; color: #000; }

/* --- Menu devise --- */
.cur-dd { position: relative; }
.cur-btn {
    display: flex; align-items: center; gap: 4px;
    background: #1B1C1F; color: #fff; border: 1px solid #2A2C31; border-radius: 999px;
    padding: 7px 10px 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; letter-spacing: .02em;
}
.cur-btn:hover { border-color: #4A4D55; }
.cur-dd.open .cur-btn { border-color: #fff; }
.cur-menu {
    display: none; position: absolute; right: 0; top: calc(100% + 8px); z-index: 50;
    list-style: none; margin: 0; padding: 6px; min-width: 250px;
    background: var(--surface); color: var(--ink); border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,.28);
}
.cur-dd.open .cur-menu { display: block; }
.cur-menu li[data-cur] {
    display: grid; grid-template-columns: 42px 1fr auto 16px; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; outline: none;
}
.cur-menu li[data-cur]:hover, .cur-menu li[data-cur]:focus { background: var(--surface-2); }
.cur-menu li.active { font-weight: 600; }
.cur-menu .cur-code { font-weight: 700; }
.cur-menu .cur-name { color: var(--ink-2); }
.cur-menu .cur-sym { color: var(--muted); font-variant-numeric: tabular-nums; }
.cur-menu .cur-check { color: var(--accent); font-weight: 700; }
.cur-menu .cur-note { padding: 8px 10px 4px; margin-top: 4px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); line-height: 1.4; }

/* --- Switch langue FR | EN --- */
.lang-switch { display: flex; align-items: center; gap: 2px; }
.lang-switch button {
    background: none; border: none; color: #8A909C; cursor: pointer;
    font-size: 13px; font-weight: 700; padding: 6px 6px; letter-spacing: .04em; border-radius: 6px;
}
.lang-switch button:hover { color: #fff; }
.lang-switch button.active { color: #fff; text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 2px; }
.lang-sep { color: #4A4D55; }

/* ===================== ONGLETS ===================== */
.bm-tabs {
    height: var(--tabs-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    padding: 0 16px;
    gap: 4px;
}
.tab {
    border: none; background: none; cursor: pointer;
    padding: 0 18px; height: 100%;
    font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    color: var(--muted);
    border-bottom: 3px solid transparent;
    transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: #000; }

.bm-main { position: relative; height: calc(100vh - var(--header-h) - var(--tabs-h)); }
.view { display: none; position: absolute; inset: 0; }
.view.active { display: flex; flex-direction: column; }

/* ===================== LISTE ===================== */
.list-toolbar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.list-search {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
    padding: 0 10px; color: var(--muted); flex: 0 1 340px;
}
.list-search input { border: none; background: none; outline: none; padding: 9px 0; font: inherit; width: 100%; color: var(--ink); }
#list-category { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; background: var(--surface); }
.list-summary { margin-left: auto; color: var(--ink-2); font-size: 13px; }
.list-summary b { color: var(--ink); }
.list-scroll { flex: 1; overflow: auto; background: var(--surface); }

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.data-table th {
    position: sticky; top: 0; z-index: 2;
    background: var(--surface-2); color: var(--ink-2);
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
    text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border);
    white-space: nowrap; user-select: none;
}
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: var(--ink); }
.data-table th .sort-ind { color: #C3C7CF; margin-left: 4px; font-size: 10px; }
.data-table th.sorted .sort-ind { color: var(--ink); }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #EEF0F3; white-space: nowrap; }
.data-table tbody tr:hover td { background: #FAFBFC; }
.data-table .num { text-align: right; }
.data-table tfoot td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--border); }
.data-table.compact td { padding: 8px 12px; }
.data-table.compact th { position: static; }

.cell-brand { display: flex; align-items: center; gap: 10px; }
.cell-brand .name { font-weight: 600; }
.cell-brand .cat { color: var(--muted); font-size: 12px; }
.cell-id { color: var(--ink-2); font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; }
.row-vacant td { color: var(--muted); }

.logo-wrap, .logo-fallback {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    border-radius: 8px; border: 1px solid var(--border); background: #fff; overflow: hidden;
}
.logo-wrap img { width: 70%; height: 70%; object-fit: contain; }
.logo-fallback { background: #EEF0F3; color: var(--ink-2); font-weight: 700; }

.freq-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.freq-chip i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.delta { font-weight: 600; font-size: 12px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--critical); }
.delta.neutral { color: var(--muted); }

.btn-see {
    border: 1px solid var(--border); background: var(--surface); color: var(--ink);
    padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.btn-see:hover { border-color: #000; }

/* ===================== CARTE ===================== */
#view-map { background: #EDEEF0; }
#map { position: absolute; inset: 0; }

.map-controls { position: absolute; top: 16px; right: 16px; z-index: 5; display: flex; gap: 8px; }
.seg { display: flex; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); padding: 3px; }
.seg button { border: none; background: none; padding: 7px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.seg button.active { background: #000; color: #fff; }
.icon-btn { border: none; background: var(--surface); width: 38px; border-radius: 8px; box-shadow: var(--shadow); cursor: pointer; color: var(--ink-2); display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { color: #000; }

.map-legend {
    position: absolute; left: 16px; bottom: 24px; z-index: 5;
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 12px 14px; min-width: 230px;
}
.map-legend h4 { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--ink); }
.map-legend .lg-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); padding: 2px 0; }
.map-legend .lg-row i { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; }
.map-legend .lg-row span.rng { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

.shop-panel {
    position: absolute; top: 16px; left: 16px; z-index: 6; width: 340px;
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
    display: none; overflow: hidden;
}
.shop-panel.open { display: block; }
.sp-head { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); }
.sp-head h3 { margin: 0; font-size: 17px; }
.sp-head .sp-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.sp-close { margin-left: auto; border: none; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); align-self: flex-start; }
.sp-class { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); }
.sp-class i { width: 12px; height: 12px; border-radius: 3px; }
.sp-grid { display: grid; grid-template-columns: 1fr 1fr; }
.sp-grid > div { padding: 12px 16px; border-bottom: 1px solid #EEF0F3; }
.sp-grid > div:nth-child(odd) { border-right: 1px solid #EEF0F3; }
.sp-grid .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sp-grid .v { font-size: 16px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }
.sp-grid .d { margin-top: 2px; }
.sp-foot { padding: 12px 16px; font-size: 12px; color: var(--ink-2); }

.mapboxgl-popup-content { font-family: inherit; padding: 8px 12px; border-radius: 8px; box-shadow: var(--shadow); }
.pop-name { font-weight: 600; }
.pop-val { color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }

/* --- Panneau d'édition (EDIT_MODE) --- */
.edit-panel {
    display: none; position: absolute; right: 16px; top: 66px; z-index: 7; width: 320px;
    max-height: calc(100% - 90px); overflow: auto;
    background: #111317; color: #E8EAEE; border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.35);
    padding: 16px; font-size: 13px;
}
body.edit-mode .edit-panel { display: block; }
.edit-panel h4 { margin: 0 0 4px; font-size: 14px; color: #fff; }
.edit-panel .ed-badge { display: inline-block; font-size: 10px; font-weight: 700; background: #E63946; color: #fff; border-radius: 4px; padding: 2px 6px; margin-bottom: 10px; letter-spacing: .05em; }
.edit-panel label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #8A909C; margin: 12px 0 5px; }
.edit-panel select, .edit-panel input {
    width: 100%; background: #1E2026; color: #fff; border: 1px solid #343741; border-radius: 6px; padding: 8px; font: inherit;
}
.edit-panel .ed-row { display: flex; gap: 6px; margin-top: 6px; }
.edit-panel .ed-row > * { flex: 1; }
.edit-panel button {
    background: #2A2D35; color: #fff; border: 1px solid #3A3E48; border-radius: 6px; padding: 8px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.edit-panel button:hover { background: #363A44; }
.edit-panel button.primary { background: #fff; color: #000; border-color: #fff; }
.edit-panel button.danger { color: #FF8A8F; }
.edit-panel .ed-hint { color: #A5AAB5; font-size: 12px; line-height: 1.45; margin: 10px 0 0; }
.edit-panel .ed-status { margin-top: 12px; padding: 8px; border-radius: 6px; background: #1E2026; color: #C9CDD5; font-size: 12px; min-height: 32px; }
.edit-panel hr { border: none; border-top: 1px solid #2A2D35; margin: 14px 0 4px; }

/* ===================== STATISTIQUES ===================== */
#view-stat { overflow: auto; display: none; }
#view-stat.active { display: block; }
.stat-wrap { padding: 20px; max-width: 1600px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi {
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-height: 124px;
}
.kpi .k-label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.kpi .k-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .k-sub { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kpi .k-brand { display: flex; align-items: center; gap: 10px; }
.kpi .k-brand .k-value { font-size: 20px; }
.kpi.hero { background: #000; color: #fff; }
.kpi.hero .k-label { color: #C9CDD5; }
.kpi.hero .k-sub { color: #A5AAB5; }
.kpi.hero .delta.up { color: #5BD68B; }
.kpi.hero .delta.down { color: #FF8A8F; }

.stat-row { display: grid; gap: 16px; }
.stat-row.cols-2-1 { grid-template-columns: 2fr 1fr; }
.stat-row.cols-1-1 { grid-template-columns: 1fr 1fr; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--muted); }
.chart-box { position: relative; width: 100%; }
.h-300 { height: 300px; } .h-340 { height: 340px; } .h-440 { height: 440px; }

.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-legend i.line { height: 2px; border-radius: 0; }
.chart-legend i.dash { height: 0; border-top: 2px dashed #A5AAB5; background: none !important; }

.alerts-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; }
.alerts-list li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid #EEF0F3; align-items: flex-start; }
.alerts-list li:last-child { border-bottom: none; }
.alerts-list .ic { width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.alerts-list .ic.critical { background: #FBE7E7; color: var(--critical); }
.alerts-list .ic.warning { background: #FDF3DC; color: var(--warning); }
.alerts-list .ic.serious { background: #FDECE4; color: #C45A2C; }
.alerts-list .a-title { font-weight: 600; font-size: 13px; }
.alerts-list .a-text { color: var(--ink-2); font-size: 12px; margin-top: 1px; }
.alerts-list .a-tag { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.alerts-list li.clickable { cursor: pointer; }
.alerts-list li.clickable:hover .a-title { text-decoration: underline; }

.stat-note { color: var(--muted); font-size: 12px; margin: 0 0 12px; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1280px) {
    .bm-period-label { display: none; }
}
@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-row.cols-2-1, .stat-row.cols-1-1 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    :root { --header-h: 96px; }
    .bm-header { flex-direction: column; align-items: flex-start; justify-content: center; gap: 8px; padding: 0 16px; }
    .bm-header-right { gap: 8px; flex-wrap: wrap; }
    .pill { padding: 7px 12px; }
    .bm-period-label { display: none; }
    .bm-tabs { overflow-x: auto; padding: 0 8px; }
    .tab { padding: 0 12px; font-size: 11px; white-space: nowrap; }
    .kpi-grid { grid-template-columns: 1fr; }
    .shop-panel { width: auto; right: 16px; }
    .map-controls { top: auto; bottom: 16px; right: 16px; }
    .map-legend { bottom: 70px; }
}
