/* Structure : en-tête, menu latéral, zone de contenu */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); color: var(--text); background: linear-gradient(180deg, #0d1829 0%, #0a1321 100%); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); }
a:hover { color: var(--red); }
button, input, select, textarea { font-family: inherit; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.shell { min-height: 100vh; }

/* ---- en-tête ---- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 30; padding: 0 22px 0 18px; display: flex; align-items: center; gap: 18px;
  background: radial-gradient(ellipse 420px 60px at 64% 100%, rgba(225, 29, 36, .22), rgba(225, 29, 36, 0) 70%), linear-gradient(180deg, var(--shell-top) 0%, var(--shell-bot) 100%);
}
.topbar-streak {
  position: fixed; left: 150px; right: 0; top: calc(var(--top-h) - 2px); height: 3px; z-index: 31; pointer-events: none;
  background: linear-gradient(90deg, rgba(225, 29, 36, 0) 0%, #e11d24 18%, #ff3a40 55%, #b3121a 85%, rgba(179, 18, 26, .3) 100%);
  box-shadow: 0 0 10px rgba(255, 40, 48, .75), 0 0 22px rgba(225, 29, 36, .45);
}
.icon-btn-dark { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: transparent; border: 0; padding: 0; cursor: pointer; color: #c4ccd8; border-radius: 6px; position: relative; }
.icon-btn-dark:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.brand { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 108px; width: max-content; padding: 0 2px; text-decoration: none; }
.brand img { width: 104px; height: 34px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .5)); }
.brand small { font-family: var(--cond); font-size: 7.6px; font-weight: 700; letter-spacing: .55px; line-height: 1; color: #9aa6b8; white-space: nowrap; }
.topbar .brand { flex: none; width: auto; min-width: 124px; }
.global-search { margin-left: clamp(20px, 10vw, 170px); display: flex; align-items: stretch; width: min(600px, 40vw); height: 36px; border-radius: 5px; overflow: hidden; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); position: relative; }
.global-search input { flex: 1; border: 0; outline: none; padding: 0 14px; font-size: 13px; color: var(--text); background: linear-gradient(180deg, #fff, #f2f4f7); min-width: 0; }
.global-search button { width: 44px; border: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(180deg, #ef2b31 0%, #c9141b 100%); cursor: pointer; color: #fff; }
.search-results { position: absolute; top: 40px; left: 0; right: 44px; background: #fff; border-radius: 6px; box-shadow: 0 12px 30px rgba(0, 0, 0, .35); max-height: 360px; overflow: auto; z-index: 40; padding: 6px; }
.search-results a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 5px; text-decoration: none; color: var(--text-2); font-size: 13px; }
.search-results a:hover, .search-results a.active { background: #f1f4f8; color: var(--text); }
.search-results .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 6px 10px 2px; font-weight: 600; }
.spacer { flex: 1; }
.notif-dot { position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: #ff2b33; color: #ff2b33; box-shadow: 0 0 0 2px #0f1a2d, 0 0 8px rgba(255, 43, 51, .8); }
.user-menu { display: flex; align-items: center; gap: 10px; margin-left: 6px; background: transparent; border: 0; color: #fff; cursor: pointer; padding: 4px 6px; border-radius: 8px; position: relative; }
.user-menu:hover { background: rgba(255, 255, 255, .06); }
.user-menu img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .4); }
.user-menu span { font-size: 13px; font-weight: 600; }
.dropdown { position: absolute; right: 0; top: 48px; min-width: 220px; background: #fff; border-radius: 8px; box-shadow: 0 12px 30px rgba(0, 0, 0, .35); padding: 6px; z-index: 50; color: var(--text); }
.dropdown .who { padding: 8px 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.dropdown button, .dropdown a { display: flex; width: 100%; align-items: center; gap: 8px; padding: 9px 10px; border: 0; background: transparent; text-align: left; font-size: 13.5px; color: var(--text-2); border-radius: 5px; cursor: pointer; text-decoration: none; }
.dropdown button:hover, .dropdown a:hover { background: #f1f4f8; }

/* ---- menu latéral ---- */
.sidebar {
  position: fixed; left: 0; top: var(--top-h); bottom: 0; width: var(--side-w); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; z-index: 20;
  background: linear-gradient(180deg, var(--side-1) 0%, var(--side-2) 60%, var(--side-3) 100%); border-right: 1px solid rgba(255, 255, 255, .04);
}
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 36px; padding: 0 14px; border-radius: 5px; text-decoration: none; font-size: 14px; letter-spacing: .1px; color: #d3d9e3; font-weight: 500; transition: background .2s, color .2s, transform .2s; }
.nav-link svg { color: #c4ccd8; }
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; transform: translateX(3px); }
.nav-link.active { color: #fff; font-weight: 600; background: linear-gradient(90deg, #e3222a 0%, #c3141b 100%); box-shadow: 0 6px 16px rgba(225, 29, 36, .38), inset 0 1px 0 rgba(255, 255, 255, .18); transform: none; }
.nav-link.active svg { color: #fff; }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 700; background: rgba(255, 255, 255, .12); color: #fff; border-radius: 9px; padding: 1px 7px; }
.nav-link.active .nav-count { background: rgba(255, 255, 255, .25); }

/* catégories colorées du menu */
.nav-cat { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.nav-cat-title { padding: 2px 14px 3px; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--cat); opacity: .95; }
.nav-cat .nav-link { border-left: 3px solid var(--cat); }
.nav-cat .nav-link svg { color: var(--cat); }
.nav-cat .nav-link.active { border-left-color: #fff; }
.nav-cat .nav-link.active svg { color: #fff; }
.nav-legend { margin-top: auto; padding: 10px 6px 2px; border-top: 1px solid rgba(255, 255, 255, .08); }
.nav-legend summary { cursor: pointer; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #9aa6b8; padding: 4px 8px; }
.nav-legend-row { display: flex; align-items: center; gap: 8px; padding: 3px 8px; font-size: 12px; color: #c4ccd8; }
.nav-legend-row i { width: 10px; height: 10px; border-radius: 3px; background: var(--cat); flex: none; }
.nav-cat + .nav-cat { margin-top: 10px; }

/* ---- contenu ---- */
.main {
  margin: var(--top-h) 10px 10px var(--side-w); min-height: calc(100vh - var(--top-h) - 10px); background: var(--bg); border-radius: 0 0 10px 10px; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .05), 0 10px 30px rgba(0, 0, 0, .35);
}
.main.white { background: #fff; }
.page-pad { padding: 18px 20px 24px; }

@media (max-width: 1100px) {
  :root { --side-w: 64px; }
  .nav-link span, .nav-count, .nav-cat-title, .nav-legend { display: none; }
  .nav-link { justify-content: center; padding: 0; }
  .brand small { display: none; }
  .user-menu span { display: none; }
}
@media (max-width: 720px) {
  .global-search { display: none; }
}

/* ---- langue : bouton + écriture droite-gauche (arabe) ---- */
.lang-btn { height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .08); color: #fff; font: 700 13px 'Tajawal', 'Barlow', sans-serif; cursor: pointer; }
.lang-btn:hover { background: rgba(255, 255, 255, .18); }
.lang-login { position: absolute; top: 14px; right: 14px; background: #111d31; }
html.lang-ar body, html.lang-ar input, html.lang-ar select, html.lang-ar textarea, html.lang-ar button { font-family: 'Tajawal', 'Barlow', sans-serif; }
html[dir=rtl] .sidebar { left: auto; right: 0; border-right: 0; border-left: 1px solid rgba(255, 255, 255, .04); }
html[dir=rtl] .main { margin: var(--top-h) var(--side-w) 10px 10px; }
html[dir=rtl] .nav-cat .nav-link { border-left: 0; border-right: 3px solid var(--cat); }
html[dir=rtl] .nav-cat .nav-link.active { border-right-color: #fff; }
html[dir=rtl] .nav-link:hover { transform: translateX(-3px); }
html[dir=rtl] .nav-count { margin-left: 0; margin-right: auto; }
html[dir=rtl] .table th, html[dir=rtl] .table td { text-align: right; }
html[dir=rtl] .table .num, html[dir=rtl] td.num, html[dir=rtl] th.num { text-align: left; }
html[dir=rtl] .rl-list { border-right: 0; border-left: 1px solid #e3e8ef; }
html[dir=rtl] .modal, html[dir=rtl] .card, html[dir=rtl] .field { text-align: right; }
html[dir=rtl] input[type=tel], html[dir=rtl] input[name=plate], html[dir=rtl] input[name=vin], html[dir=rtl] input[type=email], html[dir=rtl] input[type=number], html[dir=rtl] input[type=date] { direction: ltr; text-align: right; }
html[dir=rtl] .search-results, html[dir=rtl] .dropdown { left: 0; right: auto; }
@media (max-width: 720px) { html[dir=rtl] .main { margin: var(--top-h) 0 0 0; } }
.login-card { position: relative; } .lang-login { z-index: 3; }
/* recherche globale v1.61 : résultat approché, aide clavier */
.search-results { max-height: min(70vh, 520px); }
.search-results a span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .sr-approx { font-style: normal; color: #b26a00; font-weight: 700; margin-left: auto; }
.search-results .sr-hint { font-size: 11px; color: var(--muted); padding: 6px 10px 2px; border-top: 1px solid #eef1f5; margin-top: 4px; }
/* la liste de résultats sortait du cadre arrondi (overflow: hidden) et restait invisible : arrondis portés par les enfants */
.global-search { overflow: visible; }
.global-search input { border-radius: 5px 0 0 5px; }
.global-search button { border-radius: 0 5px 5px 0; }
html[dir=rtl] .global-search input { border-radius: 0 5px 5px 0; }
html[dir=rtl] .global-search button { border-radius: 5px 0 0 5px; }
.tb-scan { margin-left: 8px; width: 38px; height: 38px; }
