/* ============================================================
   STYLE.CSS — Inventaire PWA, thème sombre mobile-first
   ============================================================ */

:root {
  --bg:        #0f1117;
  --bg2:       #181b26;
  --bg3:       #1f2235;
  --bg4:       #252a3a;
  --accent:    #4f7cff;
  --accent2:   #3b5fcf;
  --text:      #e4e7f0;
  --text2:     #7b8099;
  --text3:     #50566e;
  --border:    #252a3a;
  --border2:   #2e3348;
  --success:   #34d399;
  --danger:    #f87171;
  --warning:   #fbbf24;
  --r: 10px;   /* border-radius standard */
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Shell ─────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;          /* dynamic viewport height (iOS 15+) */
  max-width: 540px;
  margin: 0 auto;
  overflow: hidden;
}

/* ─── Header ─────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.header-info { flex: 1; min-width: 0; }

.app-header h1 {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.2px;
}

.inv-date {
  font-size: 12px;
  color: var(--text2);
  margin-top: 1px;
  display: block;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  transition: background 0.3s;
}
.status-dot.offline { background: var(--danger); }

/* ─── Vue principale ─────────────────────────────────────────── */
.vue {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ─── Toolbar ────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 12px 8px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 8px 12px;
  color: var(--text2);
  transition: border-color 0.2s;
}
.search-bar:focus-within {
  border-color: var(--accent);
  color: var(--text);
}
.search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  min-width: 0;
}
.search-bar input::placeholder { color: var(--text3); }

.btn-icon {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  padding: 2px;
  flex-shrink: 0;
}

.btn-cols {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: border-color 0.15s;
}
.btn-cols:active { border-color: var(--accent); }

/* ─── Panneau colonnes ───────────────────────────────────────── */
.panneau-cols {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panneau-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.panneau-titre {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cols-liste {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
}

.col-check {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.col-check input { display: none; }
.col-check.active {
  background: rgba(79, 124, 255, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}
.col-check.active::before {
  content: '✓';
  font-size: 12px;
}

.btn-sm {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  cursor: pointer;
}
.btn-sm.ghost { background: none; color: var(--text2); }

/* ─── Barre info résultats ───────────────────────────────────── */
.bar-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.compteur {
  font-size: 12px;
  color: var(--text2);
}

.badge-filtre {
  font-size: 11px;
  color: var(--accent);
  background: rgba(79, 124, 255, 0.12);
  border: 1px solid rgba(79, 124, 255, 0.3);
  border-radius: 10px;
  padding: 2px 8px;
}

/* ─── Tableau ────────────────────────────────────────────────── */
.table-scroll {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

thead { position: sticky; top: 0; z-index: 10; }

th {
  background: var(--bg3);
  color: var(--text2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border2);
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

.align-right  { text-align: right; }
.align-center { text-align: center; }
.align-left   { text-align: left; }

/* Cellule écart colorée */
.ecart-pos { color: var(--success); font-weight: 600; }
.ecart-neg { color: var(--danger);  font-weight: 600; }

.cell-empty {
  text-align: center;
  color: var(--text3);
  padding: 40px 20px;
  font-size: 14px;
}

/* ─── Résumé bas ─────────────────────────────────────────────── */
.resume {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.resume-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  border-right: 1px solid var(--border);
}
.resume-card:last-child { border-right: none; }

.r-val {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}
.r-label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}
.resume-card.ok  .r-val { color: var(--success); }
.resume-card.ko  .r-val { color: var(--danger); }

/* ─── Navigation bas ─────────────────────────────────────────── */
.bottom-nav {
  display: flex;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0;
  background: none;
  border: none;
  color: var(--text3);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s;
}
.nav-btn.active { color: var(--accent); }
.nav-btn svg { transition: color 0.15s; }

/* ─── Vue config ─────────────────────────────────────────────── */
#vue-config {
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
  margin-top: 20px;
}
.section-label:first-child { margin-top: 0; }

.cfg-group { margin-bottom: 12px; }
.cfg-label {
  display: block;
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 5px;
}
.cfg-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s;
}
.cfg-input:focus { border-color: var(--accent); }

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  border: none;
  border-radius: var(--r);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:active { background: var(--accent2); }

.btn-outline {
  padding: 11px;
  background: none;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  color: var(--text2);
  font-size: 14px;
  cursor: pointer;
}

.info-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
}
.info-item span { color: var(--text); font-weight: 500; }

/* ─── Spinner ────────────────────────────────────────────────── */
#spinner {
  display: none;
  position: fixed;
  inset: 0; z-index: 200;
  justify-content: center;
  align-items: center;
  background: rgba(15, 17, 23, 0.7);
}
.spin {
  width: 32px; height: 32px;
  border: 3px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(70px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 9px 18px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 300;
}
.toast.visible    { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error      { border-color: var(--danger);  color: var(--danger); }
.toast.warning    { border-color: var(--warning); color: var(--warning); }
.toast.success    { border-color: var(--success); color: var(--success); }
