/* assets/theme.css - v3.0.0 - Thèmes SIVOM : coloré / sobre / office × clair / sombre */

/* ───────── Jetons ───────── */
html[data-style] {
  --blue:#254193; --red:#e30513; --green:#00973a; --yellow:#fecf23; --lblue:#009ee3; --purple:#82358b;
  --light:#f4f6fb; --surface:#ffffff; --surface-2:#f8f9fc; --border:#e1e5ee; --text:#1f2633; --text-2:#4b5566;
  --gray:#8a93a3; --hover:#eef2fb; --neutral:#e8ebf2; --neutral-2:#d5dae5;
  --bar:linear-gradient(90deg,#254193,#009ee3); --side:linear-gradient(160deg,#254193,#1a2d5f);
  --radius:10px; --shadow:0 2px 10px rgba(20,30,60,.08); --font:'Segoe UI',Roboto,system-ui,-apple-system,sans-serif;
}
html[data-style="sivom"][data-theme="dark"] {
  --light:#0f1522; --surface:#18202f; --surface-2:#1f293b; --border:#2c3850; --text:#e7ebf3; --text-2:#b4bdcc;
  --gray:#7d889b; --hover:#24304a; --neutral:#2a3550; --neutral-2:#36435f; --blue:#4a6fd8; --lblue:#29b3f0;
  --bar:linear-gradient(90deg,#1b2f6e,#0a6fa3); --side:linear-gradient(160deg,#16244f,#0e1730);
  --shadow:0 2px 12px rgba(0,0,0,.45);
}
html[data-style="sobre"] {
  --blue:#14213d; --lblue:#b08d4a; --red:#9b2c2c; --green:#2f6b4f; --yellow:#c9a55a; --purple:#5a4a6b;
  --light:#f7f4ec; --surface:#fffdf8; --surface-2:#f3efe4; --border:#e2dccb; --text:#1d2230; --text-2:#4c5262;
  --hover:#efe9da; --neutral:#ebe5d6; --neutral-2:#ddd5c1; --bar:#14213d; --side:#14213d; --radius:6px;
  --font:Georgia,'Times New Roman',serif;
}
html[data-style="sobre"][data-theme="dark"] {
  --light:#11141b; --surface:#1a1e27; --surface-2:#222733; --border:#343a48; --text:#ece6d6; --text-2:#bdb6a5;
  --gray:#8c8778; --hover:#272d3a; --neutral:#2b303d; --neutral-2:#3a4050; --blue:#c9a55a; --lblue:#d8b977;
  --bar:#0b1120; --side:#0b1120; --shadow:0 2px 12px rgba(0,0,0,.5);
}
html[data-style="office"] {
  --blue:#0f6cbd; --lblue:#2b88d8; --red:#c50f1f; --green:#107c10; --yellow:#eaa300; --purple:#5c2e91;
  --light:#f5f5f5; --surface:#ffffff; --surface-2:#fafafa; --border:#e0e0e0; --text:#242424; --text-2:#424242;
  --gray:#707070; --hover:#f0f6fc; --neutral:#ebebeb; --neutral-2:#d1d1d1; --bar:#0f6cbd; --side:#fafafa;
  --radius:4px; --shadow:0 1px 3px rgba(0,0,0,.12); --font:'Segoe UI',system-ui,sans-serif;
}
html[data-style="office"][data-theme="dark"] {
  --light:#1f1f1f; --surface:#292929; --surface-2:#2f2f2f; --border:#3d3d3d; --text:#f0f0f0; --text-2:#c8c8c8;
  --gray:#9a9a9a; --hover:#333b45; --neutral:#383838; --neutral-2:#474747; --blue:#479ef5; --lblue:#62abf5;
  --bar:#1b1b1b; --side:#242424; --shadow:0 1px 4px rgba(0,0,0,.5);
}

/* Variables historiques des feuilles existantes */
html[data-style] {
  --color-primary:var(--blue); --color-secondary:var(--red); --color-accent:var(--green); --color-warning:var(--yellow);
  --color-alt1:var(--lblue); --color-alt2:var(--purple); --color-dark:var(--text); --color-light:var(--light);
  --color-border:var(--border); --color-success:var(--green); --color-error:var(--red); --color-info:var(--lblue);
  --shadow-lg:var(--shadow);
}
html[data-style] body { background:var(--light); color:var(--text); font-family:var(--font); }
html[data-style] input, html[data-style] select, html[data-style] textarea { background:var(--surface); color:var(--text); border-color:var(--border); }
html[data-style] table th { color:var(--text); }

/* Sidebar admin existante */
html[data-style] .sidebar { background:var(--side); }
html[data-style="office"]:not([data-theme="dark"]) .sidebar { color:var(--text); border-right:1px solid var(--border); }
html[data-style="office"]:not([data-theme="dark"]) .sidebar .nav-btn { color:var(--text-2); }
html[data-style="office"]:not([data-theme="dark"]) .sidebar .nav-btn.active,
html[data-style="office"]:not([data-theme="dark"]) .sidebar .nav-btn:hover { background:var(--hover); color:var(--blue); border-left-color:var(--blue); }
html[data-style="sobre"] .sidebar .nav-btn.active { border-left-color:#b08d4a; }
.sidebar .nav-btn { font-size:.92rem; font-family:inherit; }
.sidebar a.nav-btn { display:block; text-decoration:none; }
body.app-page, body.login-page { margin:0; }
body.app-page * , body.login-page * { box-sizing:border-box; }
.sidebar .nav-sep { height:1px; background:rgba(255,255,255,.15); margin:.6rem 1.2rem; }
.sidebar .nav-btn i { width:1.2em; text-align:center; margin-right:.3rem; }
.admin-header { display:flex; align-items:center; justify-content:space-between; gap:1rem; }
.admin-header h1 { color:var(--text); }

/* Logo toujours sur fond blanc */
.logo-box { display:inline-flex; align-items:center; justify-content:center; background:#fff; border-radius:8px; padding:4px 8px; box-shadow:0 1px 3px rgba(0,0,0,.15); }
.logo-box img { height:38px; width:auto; display:block; }
.logo-box.big img { height:64px; }
.sidebar-header .logo-box { margin-bottom:.5rem; }
.sidebar-header .logo-box img { height:46px; margin:0; }

/* ───────── Topbar des nouvelles pages ───────── */
.topbar { background:var(--bar); color:#fff; display:flex; align-items:center; gap:1rem; padding:.55rem 1.2rem; flex-wrap:wrap; box-shadow:var(--shadow); position:sticky; top:0; z-index:1000; }
html[data-style="sobre"] .topbar { border-bottom:3px solid #b08d4a; }
.topbar .brand { display:flex; align-items:center; gap:.7rem; color:#fff; text-decoration:none; font-weight:700; font-size:1.1rem; }
.top-nav { display:flex; gap:.25rem; flex-wrap:wrap; flex:1; }
.tb-link { color:rgba(255,255,255,.88); text-decoration:none; padding:.45rem .75rem; border-radius:var(--radius); display:inline-flex; gap:.45rem; align-items:center; font-size:.92rem; }
.tb-link:hover, .tb-link.active { background:rgba(255,255,255,.18); color:#fff; }
.topbar-right { display:flex; align-items:center; gap:.5rem; }
.tb-user { font-size:.88rem; opacity:.9; }
.admin-header .topbar-right { color:var(--text); }

.page-wrap { max-width:1300px; margin:1.4rem auto; padding:0 1rem 3rem; }
.app-footer { text-align:center; padding:1rem; }
.app-version { color:#9aa0aa !important; font-size:.75rem; font-family:monospace; opacity:.85; }
.app-version a { color:inherit; }

/* ───────── Composants ───────── */
.card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); padding:1.2rem 1.3rem; margin-bottom:1.2rem; }
.card h2, .card h3 { color:var(--blue); margin:0 0 .9rem; display:flex; gap:.5rem; align-items:center; font-size:1.15rem; }
.card-head { display:flex; justify-content:space-between; align-items:center; gap:.8rem; flex-wrap:wrap; margin-bottom:.8rem; }
.card-head h2 { margin:0; }
.grid2 { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:1rem; }
.muted { color:var(--gray); font-size:.9rem; }
.form-control { width:100%; padding:.6rem .75rem; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); color:var(--text); font:inherit; }
.form-control:focus { outline:2px solid var(--lblue); outline-offset:0; }
.fl { display:block; margin-bottom:.9rem; }
.fl > span { display:block; font-size:.86rem; font-weight:600; color:var(--text-2); margin-bottom:.3rem; }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:.45rem; padding:.58rem 1rem; border:0; border-radius:var(--radius); font:inherit; font-weight:600; cursor:pointer; text-decoration:none; background:var(--neutral); color:var(--text); transition:filter .15s, transform .1s; }
.btn:hover { filter:brightness(1.07); }
.btn:active { transform:translateY(1px); }
.btn:disabled { opacity:.5; cursor:not-allowed; }
.btn-primary { background:var(--blue); color:#fff !important; }
.btn-success { background:var(--green); color:#fff !important; }
.btn-danger  { background:var(--red); color:#fff !important; }
.btn-info    { background:var(--lblue); color:#fff !important; }
.btn-sm { padding:.32rem .6rem; font-size:.84rem; }
.btn-optimus { background:linear-gradient(90deg,#254193,#82358b); color:#fff !important; }
.w100 { width:100%; }
.table-wrap { overflow-x:auto; }
.tbl { width:100%; border-collapse:collapse; font-size:.92rem; }
.tbl th { text-align:left; background:var(--surface-2); color:var(--text-2); font-weight:600; padding:.55rem .6rem; border-bottom:2px solid var(--border); white-space:nowrap; }
.tbl td { padding:.5rem .6rem; border-bottom:1px solid var(--border); vertical-align:middle; }
.tbl tr:hover td { background:var(--hover); }
.badge-r { display:inline-block; padding:.15rem .55rem; border-radius:20px; font-size:.78rem; font-weight:700; color:#fff; background:var(--gray); }
.b-admin { background:var(--red); } .b-responsable { background:var(--blue); } .b-adjoint { background:var(--purple); } .b-agent { background:var(--green); }
.b-sso { background:var(--lblue); } .b-off { background:#777; }
.alert { padding:.75rem 1rem; border-radius:var(--radius); margin-bottom:1rem; border-left:4px solid; }
.alert-error   { background:rgba(227,5,19,.09);  border-color:var(--red);   color:var(--text); }
.alert-success { background:rgba(0,151,58,.1);   border-color:var(--green); color:var(--text); }
.alert-info    { background:rgba(0,158,227,.1);  border-color:var(--lblue); color:var(--text); }
.alert-warn    { background:rgba(254,207,35,.16); border-color:var(--yellow); color:var(--text); }
.tabs { display:flex; gap:.3rem; flex-wrap:wrap; margin-bottom:1rem; }
.tabs a { padding:.45rem .9rem; border-radius:var(--radius); background:var(--neutral); color:var(--text); text-decoration:none; font-weight:600; font-size:.9rem; }
.tabs a.active { background:var(--blue); color:#fff; }
.steps { display:flex; gap:.4rem; flex-wrap:wrap; margin-bottom:1rem; }
.steps span { padding:.4rem .8rem; border-radius:20px; background:var(--neutral); color:var(--text-2); font-size:.86rem; font-weight:600; }
.steps span.on { background:var(--blue); color:#fff; }
.steps span.done { background:var(--green); color:#fff; }
.chip { display:inline-block; padding:.12rem .5rem; margin:.1rem; border-radius:12px; background:var(--neutral); font-size:.8rem; }
.swatch { display:inline-block; width:12px; height:12px; border-radius:3px; vertical-align:middle; margin-right:.3rem; }
.dropzone { border:2px dashed var(--neutral-2); border-radius:var(--radius); padding:2rem; text-align:center; cursor:pointer; color:var(--text-2); background:var(--surface-2); transition:border-color .15s; }
.dropzone:hover, .dropzone.over { border-color:var(--lblue); }
.dropzone i { font-size:2.2rem; color:var(--lblue); display:block; margin-bottom:.5rem; }
.preview-tbl td.sel-date { background:rgba(0,151,58,.14); }
.preview-tbl th.sel-date { background:var(--green); color:#fff; }
.preview-tbl th.sel-code { background:var(--purple); color:#fff; }
.preview-tbl th.sel-commune { background:var(--blue); color:#fff; }
.preview-tbl th { cursor:pointer; }
.matrix td, .matrix th { text-align:center; }
.matrix td:first-child, .matrix th:first-child { text-align:left; }
.help-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(290px,1fr)); gap:1rem; }
.help-card { border-top:4px solid var(--c, var(--blue)); }
.help-card h3 i { color:var(--c, var(--blue)); }
.help-card ul { padding-left:1.1rem; line-height:1.6; color:var(--text-2); }

/* ───────── Connexion ───────── */
.login-page { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:1rem;
  background:radial-gradient(circle at 15% 20%, rgba(0,158,227,.18), transparent 45%), radial-gradient(circle at 85% 80%, rgba(130,53,139,.16), transparent 45%), var(--light); }
.login-card { position:relative; background:var(--surface); border:1px solid var(--border); border-radius:14px; box-shadow:0 10px 40px rgba(0,0,0,.14); width:100%; max-width:410px; padding:2.2rem 2rem 1.4rem; text-align:center; overflow:hidden; }
.login-stripe { position:absolute; top:0; left:0; right:0; height:6px; background:linear-gradient(90deg,#254193 0 17%,#e30513 17% 34%,#00973a 34% 51%,#fecf23 51% 68%,#009ee3 68% 85%,#82358b 85%); }
.login-card h1 { color:var(--blue); font-size:1.45rem; margin:1rem 0 .3rem; }
.login-card form { text-align:left; margin-top:1.2rem; }
.sep { display:flex; align-items:center; gap:.7rem; color:var(--gray); margin:1rem 0; font-size:.85rem; }
.sep::before, .sep::after { content:''; flex:1; height:1px; background:var(--border); }
.small-link { display:block; margin-top:.9rem; font-size:.87rem; color:var(--lblue); text-decoration:none; }
.login-card .app-version { margin-top:1rem; }

/* ───────── Sélecteur de thème ───────── */
.pm-theme-btn { background:rgba(255,255,255,.18); color:inherit; border:0; border-radius:var(--radius); width:36px; height:34px; cursor:pointer; font-size:1rem; }
.admin-header .pm-theme-btn, .pm-theme-float { background:var(--neutral); color:var(--text); }
.pm-theme-float { position:fixed; right:14px; bottom:44px; z-index:3000; box-shadow:var(--shadow); }
.pm-theme-menu { position:fixed; z-index:6000; background:var(--surface); color:var(--text); border:1px solid var(--border); border-radius:10px; box-shadow:0 8px 30px rgba(0,0,0,.2); padding:.7rem; min-width:210px; }
.pm-theme-menu h4 { font-size:.75rem; text-transform:uppercase; color:var(--gray); margin:.2rem 0 .4rem; letter-spacing:.04em; }
.pm-theme-menu button { display:flex; align-items:center; gap:.55rem; width:100%; padding:.42rem .5rem; border:0; background:none; color:var(--text); border-radius:6px; cursor:pointer; font:inherit; text-align:left; }
.pm-theme-menu button:hover, .pm-theme-menu button.on { background:var(--hover); }
.pm-theme-menu .dot { width:16px; height:16px; border-radius:50%; flex:none; }

/* ───────── Correctifs sombres ───────── */
html[data-theme="dark"] .leaflet-container { background:#1c2433; }
html[data-theme="dark"] .leaflet-popup-content-wrapper, html[data-theme="dark"] .leaflet-popup-tip { background:var(--surface); color:var(--text); }
html[data-theme="dark"] .notification { background:var(--surface) !important; color:var(--text) !important; }
html[data-theme="dark"] .data-table th { background:var(--surface-2); color:var(--text); }
html[data-theme="dark"] .data-table tr:hover td { background:var(--hover); }

/* ───────── Responsive ───────── */
@media (max-width:760px) {
  .topbar { padding:.5rem .7rem; }
  .tb-link span { display:none; }
  .brand-txt { display:none; }
  .admin-app { flex-direction:column; }
  .sidebar { width:100% !important; }
  .sidebar-nav { display:flex; flex-wrap:wrap; padding:.3rem; }
  .sidebar .nav-btn { width:auto; padding:.55rem .7rem; border-left:0; font-size:.85rem; }
  .sidebar .nav-sep { display:none; }
  .page-wrap { margin-top:.8rem; padding:0 .5rem 3rem; }
  .card { padding:1rem .8rem; }
}
@media (hover:none) { .btn-action { opacity:1 !important; } }
.alert a { color:var(--lblue); font-weight:600; }
