/* =====================================================================
   Al Khalifa Mobilité — Feuille de style de l'application (PWA)
   Mobile-first. Les couleurs proviennent de /settings et sont injectées
   dans les variables --ak-* au démarrage (voir app.js).
   ===================================================================== */

:root {
  --ak-primary: #0B6E4F;
  --ak-secondary: #C8A24A;
  --ak-dark: #0E1B14;
  --ak-light: #F6F8F7;
  --ak-radius: 16px;

  --bg: #ffffff;
  --bg-soft: #f2f5f3;
  --surface: #ffffff;
  --text: #16211c;
  --text-soft: #5b6b62;
  --border: #e4e9e6;
  --danger: #c0392b;
  --success: #1e8e5a;
  --shadow: 0 2px 12px rgba(14, 27, 20, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 62px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1512; --bg-soft: #161e1a; --surface: #18211d;
    --text: #eaf1ed; --text-soft: #9db0a7; --border: #26332c;
    --shadow: 0 2px 14px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1512; --bg-soft: #161e1a; --surface: #18211d;
  --text: #eaf1ed; --text-soft: #9db0a7; --border: #26332c;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}
[dir="rtl"] { direction: rtl; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

/* --- Écran de démarrage --- */
.splash {
  position: fixed; inset: 0; display: grid; place-content: center; justify-items: center;
  gap: 14px; background: var(--ak-dark); color: #fff; z-index: 1000;
}
.splash__logo {
  width: 84px; height: 84px; border-radius: 24px; display: grid; place-items: center;
  background: var(--ak-primary); color: #fff; font-size: 40px; font-weight: 800;
}
.splash__name { font-size: 18px; font-weight: 600; letter-spacing: .3px; }
.splash__spinner {
  width: 26px; height: 26px; border: 3px solid rgba(255,255,255,.25);
  border-top-color: var(--ak-secondary); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Structure --- */
.app { min-height: 100%; }
.screen {
  min-height: 100vh; padding-top: calc(var(--safe-top) + 8px);
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
}
.screen--plain { padding-bottom: calc(var(--safe-bottom) + 16px); }
.container { padding: 0 16px; max-width: 640px; margin: 0 auto; }

/* --- En-tête --- */
.appbar {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border);
}
.appbar__title { font-size: 17px; font-weight: 700; flex: 1; }
.appbar__btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; font-size: 18px;
}

/* --- Barre de navigation basse --- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; align-items: stretch;
}
.tabbar__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-soft); font-size: 11px; font-weight: 600;
}
.tabbar__item.active { color: var(--ak-primary); }
.tabbar__icon { font-size: 20px; line-height: 1; }

/* --- Cartes --- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--ak-radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.card--flat { box-shadow: none; }
.card__title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.muted { color: var(--text-soft); }
.small { font-size: 13px; }

/* --- Grille de modules (accueil) --- */
.modules { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.module {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--ak-radius);
  padding: 18px 14px; box-shadow: var(--shadow); text-align: start; position: relative; overflow: hidden;
}
.module__icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-size: 22px; background: color-mix(in srgb, var(--ak-primary) 14%, transparent);
  color: var(--ak-primary); margin-bottom: 10px;
}
.module__name { font-weight: 700; font-size: 15px; }
.module__desc { color: var(--text-soft); font-size: 12.5px; margin-top: 2px; }
.module[disabled] { opacity: .5; pointer-events: none; }

/* --- Héros --- */
.hero {
  border-radius: var(--ak-radius); padding: 24px 18px; color: #fff; margin-bottom: 16px;
  background: linear-gradient(135deg, var(--ak-primary), color-mix(in srgb, var(--ak-primary) 55%, var(--ak-dark)));
}
.hero__title { font-size: 22px; font-weight: 800; line-height: 1.2; }
.hero__sub { opacity: .9; margin-top: 6px; font-size: 14px; }

/* --- Boutons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 18px; border-radius: 14px; border: 0; cursor: pointer;
  background: var(--ak-primary); color: #fff; font-weight: 700; font-size: 15px;
  transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn--ghost { background: transparent; color: var(--ak-primary); border: 1.5px solid var(--ak-primary); }
.btn--soft { background: var(--bg-soft); color: var(--text); }
.btn--gold { background: var(--ak-secondary); color: var(--ak-dark); }
.btn--sm { width: auto; padding: 9px 14px; font-size: 13px; border-radius: 11px; }
.btn--block { width: 100%; }

/* --- Formulaires --- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-soft); }
.input, .select, textarea.input {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface); font-size: 15px; outline: none; transition: border-color .15s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--ak-primary); }
.field__error { color: var(--danger); font-size: 12.5px; margin-top: 5px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.segmented { display: flex; gap: 6px; background: var(--bg-soft); padding: 4px; border-radius: 12px; }
.segmented button {
  flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px;
  font-weight: 600; font-size: 13px; color: var(--text-soft);
}
.segmented button.active { background: var(--surface); color: var(--ak-primary); box-shadow: var(--shadow); }
.check { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--ak-primary); }

/* --- Prix / lignes --- */
.pricebox { border: 1px solid var(--border); border-radius: var(--ak-radius); padding: 14px; margin: 14px 0; }
.priceline { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14px; }
.priceline--total { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 12px; font-weight: 800; font-size: 17px; }
.priceline .neg { color: var(--success); }

/* --- Badges & états --- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--bg-soft); color: var(--text-soft);
}
.badge--ok { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
.badge--warn { background: color-mix(in srgb, var(--ak-secondary) 22%, transparent); color: #8a6d16; }
.badge--danger { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

/* --- Listes --- */
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--ak-radius); margin-bottom: 10px;
}
.list-item__body { flex: 1; min-width: 0; }
.list-item__title { font-weight: 700; font-size: 15px; }
.list-item__meta { color: var(--text-soft); font-size: 13px; }
.thumb { width: 60px; height: 60px; border-radius: 12px; object-fit: cover; background: var(--bg-soft); }

/* --- Toast & loader --- */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 16px); z-index: 60; display: grid; gap: 8px; padding: 0 16px; pointer-events: none; }
.toast {
  background: var(--ak-dark); color: #fff; padding: 12px 16px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow); animation: toastin .2s ease;
}
.toast--error { background: var(--danger); }
.toast--success { background: var(--success); }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }
.loader-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.25); display: grid; place-items: center; z-index: 80; }
.loader { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }

/* --- Divers --- */
.section-title { font-size: 15px; font-weight: 800; margin: 18px 0 10px; }
.stack > * + * { margin-top: 12px; }
.center { text-align: center; }
.empty { text-align: center; color: var(--text-soft); padding: 48px 16px; }
.empty__icon { font-size: 44px; margin-bottom: 12px; }
.spacer { height: 8px; }
.link { color: var(--ak-primary); font-weight: 600; }
.price-tag { font-weight: 800; color: var(--ak-primary); }
.strike { text-decoration: line-through; color: var(--text-soft); font-weight: 500; font-size: 13px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { white-space: nowrap; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 600; }
.chip.active { background: var(--ak-primary); color: #fff; border-color: var(--ak-primary); }
