/* ============================================================================
 * Siya9a Pro — Premium SaaS Refresh (v66.0 · Stripe-Look)
 * Layers on top of styles.css + apple-design.css. Adds tokens & components
 * needed for the new Compta / Élèves / Dashboard / Planning / Véhicules.
 *
 * IMPORTANT: this file MUST NOT redefine legacy tokens like --green/--red
 * (they are widely used). It ADDS new tokens (--primary, --bg-app, etc.)
 * and component classes (.kpi-card, .filter-bar, .pill, .pdata-table…).
 * ========================================================================== */
:root{
  /* Primary palette aligned w/ design_guidelines.json */
  --primary:#248A3D;
  --primary-hover:#1D7032;
  --primary-light:#E9F5EC;
  --primary-ghost:rgba(36,138,61,.10);
  --danger:#C1272D;
  --danger-hover:#A11F24;
  --danger-light:#FDEDED;
  --warning:#F59E0B;
  --warning-light:#FEF3C7;
  --blue-accent:#0ea5e9;
  --blue-light:#e0f2fe;
  /* Surface system */
  --bg-app:#F8FAFC;
  --bg-surface:#FFFFFF;
  --bg-surface-hover:#F1F5F9;
  --text-main:#0F172A;
  --text-muted:#64748B;
  --text-placeholder:#94A3B8;
  --pr-border:#E2E8F0;
  --pr-border-light:#F1F5F9;
  /* Spacing */
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:20px;
  --sp-6:24px; --sp-8:32px; --sp-12:48px;
  /* Radii */
  --rad-sm:6px; --rad-md:10px; --rad-lg:16px; --rad-xl:24px; --rad-full:9999px;
  /* Shadows */
  --sh-sm:0 1px 2px 0 rgba(0,0,0,.05);
  --sh-card:0 2px 5px rgba(0,0,0,.04), 0 1px 1.5px rgba(0,0,0,.02);
  --sh-drawer:-10px 0 30px rgba(0,0,0,.10);
  --sh-dropdown:0 10px 15px -3px rgba(0,0,0,.10), 0 4px 6px -4px rgba(0,0,0,.05);
  /* Type scale */
  --text-micro:11px; --text-xs:12px; --text-sm:14px; --text-base:15px;
  --text-lg:17px; --text-xl:20px; --text-2xl:24px; --text-3xl:28px;
}

/* App-wide canvas: gentle slate background so cards float */
body{background:var(--bg-app);color:var(--text-main);}

/* Ensure no overflow clips action buttons */
@media (min-width: 1025px){
  .app-shell > .screen{ overflow-x:hidden; min-width:0; }
  .page-head-actions{ flex-shrink:1; min-width:0; }
}

/* === Premium Card primitive ============================================ */
.pcard{
  background:var(--bg-surface);
  border-radius:var(--rad-lg);
  box-shadow:var(--sh-card);
  border:1px solid var(--pr-border);
  padding:var(--sp-6);
  transition:transform .2s ease, box-shadow .2s ease;
}
.pcard:hover{ box-shadow:var(--sh-dropdown); }
.pcard-tight{ padding:var(--sp-4); }

/* === Buttons ============================================================ */
.pbtn{
  display:inline-flex; align-items:center; justify-content:center; gap:var(--sp-2);
  padding:10px 16px; border-radius:var(--rad-md);
  font-weight:600; font-size:var(--text-sm); letter-spacing:-0.005em;
  transition:background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
  cursor:pointer; border:1px solid transparent; line-height:1; white-space:nowrap;
}
.pbtn:active{ transform:translateY(1px); }
.pbtn-primary{ background:var(--primary); color:#fff; box-shadow:var(--sh-sm); }
.pbtn-primary:hover{ background:var(--primary-hover); }
.pbtn-danger{ background:var(--danger); color:#fff; }
.pbtn-danger:hover{ background:var(--danger-hover); }
.pbtn-outline{ background:#fff; border-color:var(--pr-border); color:var(--text-main); }
.pbtn-outline:hover{ background:var(--bg-surface-hover); border-color:var(--text-muted); }
.pbtn-ghost{ background:transparent; color:var(--text-muted); padding:6px 10px; }
.pbtn-ghost:hover{ background:var(--bg-surface-hover); color:var(--text-main); }
.pbtn-sm{ padding:6px 12px; font-size:var(--text-xs); border-radius:var(--rad-sm); }

/* === Page Header (Stripe-style: H1 + subtitle, right CTA cluster) ====== */
.screen .page-head,
.screen .kpi-strip,
.screen .pfilter-bar,
.screen .pdata-wrap,
.screen #planning-list,
.screen #moniteurs-list,
.screen #vehicles-list{
  margin-left:24px; margin-right:24px; max-width:calc(100% - 48px);
}
@media (max-width: 1024px){
  .screen .page-head,
  .screen .kpi-strip,
  .screen .pfilter-bar,
  .screen .pdata-wrap,
  .screen #planning-list,
  .screen #moniteurs-list,
  .screen #vehicles-list{ margin-left:16px; margin-right:16px; }
}
.page-head{
  display:flex; align-items:flex-end; justify-content:space-between;
  gap:var(--sp-4); flex-wrap:wrap; padding:var(--sp-2) 0 var(--sp-6);
  border-bottom:1px solid var(--pr-border-light); margin-bottom:var(--sp-6);
  min-width:0; max-width:100%;
}
.page-head > div:first-child{ min-width:0; flex:1 1 240px; }
.page-head-actions{
  display:flex; gap:var(--sp-2); align-items:center; flex-wrap:wrap;
  justify-content:flex-end;
}
.page-head h1{
  font-family:'Cairo',sans-serif; font-weight:800; font-size:var(--text-3xl);
  letter-spacing:-0.025em; line-height:1.1; color:var(--text-main);
}
.page-head .page-sub{ color:var(--text-muted); font-size:var(--text-sm); margin-top:6px; }

/* === KPI Card ========================================================== */
.kpi-strip{
  display:grid; grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
  gap:var(--sp-4); margin-bottom:var(--sp-6);
}
.kpi-card{
  background:var(--bg-surface); border:1px solid var(--pr-border);
  border-radius:var(--rad-lg); padding:var(--sp-5);
  display:flex; flex-direction:column; gap:var(--sp-3);
  box-shadow:var(--sh-card); transition:box-shadow .2s ease;
}
.kpi-card:hover{ box-shadow:var(--sh-dropdown); }
.kpi-card .kpi-label{
  display:flex; justify-content:space-between; align-items:center;
  font-size:var(--text-xs); color:var(--text-muted); font-weight:600;
  text-transform:uppercase; letter-spacing:.06em;
}
.kpi-card .kpi-icon{
  width:32px; height:32px; border-radius:8px;
  background:var(--bg-surface-hover); color:var(--text-muted);
  display:inline-flex; align-items:center; justify-content:center;
}
.kpi-card .kpi-value{
  font-family:'Cairo',sans-serif; font-weight:800; font-size:var(--text-3xl);
  color:var(--text-main); letter-spacing:-0.025em; line-height:1.1;
  font-variant-numeric:tabular-nums;
}
.kpi-card .kpi-meta{
  display:flex; align-items:center; gap:6px;
  font-size:var(--text-xs); color:var(--text-muted);
}
.kpi-trend-up{ color:var(--primary); font-weight:700; }
.kpi-trend-down{ color:var(--danger); font-weight:700; }
.kpi-spark{ height:32px; width:100%; opacity:.8; }
.kpi-spark path{ fill:none; stroke-width:1.8; }
.kpi-spark .spark-pos{ stroke:var(--primary); }
.kpi-spark .spark-neg{ stroke:var(--danger); }
.kpi-spark .spark-fill-pos{ fill:var(--primary-ghost); stroke:none; }

/* === Filter Bar ========================================================= */
.pfilter-bar{
  display:flex; align-items:center; justify-content:space-between;
  gap:var(--sp-3); flex-wrap:wrap;
  background:var(--bg-surface); border:1px solid var(--pr-border);
  border-radius:var(--rad-md); padding:var(--sp-3) var(--sp-4); box-shadow:var(--sh-sm);
  margin-bottom:var(--sp-4);
}
.pchip-group{
  display:inline-flex; background:var(--bg-app); border:1px solid var(--pr-border);
  border-radius:var(--rad-md); padding:3px; gap:2px; overflow-x:auto; max-width:100%;
  scrollbar-width:none;
}
.pchip-group::-webkit-scrollbar{ display:none; }
.pchip{
  border:none; background:transparent; color:var(--text-muted);
  font-size:var(--text-sm); font-weight:600; padding:6px 14px;
  border-radius:var(--rad-sm); cursor:pointer; transition:all .15s ease;
  white-space:nowrap;
}
.pchip:hover{ color:var(--text-main); }
.pchip.active{ background:var(--bg-surface); color:var(--text-main); box-shadow:var(--sh-sm); }
.psearch{
  position:relative; flex:0 0 280px; max-width:100%;
}
.psearch input{
  width:100%; padding:9px 14px 9px 36px; border:1px solid var(--pr-border);
  border-radius:var(--rad-md); font-size:var(--text-sm);
  background:var(--bg-surface); color:var(--text-main);
  transition:border-color .15s, box-shadow .15s; outline:none;
}
.psearch input:focus{ border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-ghost); }
.psearch input::placeholder{ color:var(--text-placeholder); }
.psearch .psearch-icon{
  position:absolute; left:11px; top:50%; transform:translateY(-50%);
  width:16px; height:16px; color:var(--text-muted); pointer-events:none;
}
.pselect{
  padding:9px 28px 9px 12px; border:1px solid var(--pr-border);
  border-radius:var(--rad-md); font-size:var(--text-sm); background:var(--bg-surface);
  color:var(--text-main); font-weight:500; cursor:pointer; appearance:none;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat:no-repeat; background-position:right 10px center;
}
.pselect:focus{ outline:none; border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-ghost); }

/* === Status Pill ======================================================== */
.pill{
  display:inline-flex; align-items:center; gap:6px;
  padding:3px 10px; border-radius:var(--rad-full);
  font-size:var(--text-micro); font-weight:700; letter-spacing:.02em;
  background:var(--bg-surface-hover); color:var(--text-muted);
}
.pill::before{
  content:""; width:6px; height:6px; border-radius:50%; background:currentColor;
}
.pill-success{ background:var(--primary-light); color:var(--primary); }
.pill-danger{ background:var(--danger-light); color:var(--danger); }
.pill-warn{ background:var(--warning-light); color:#92400e; }
.pill-info{ background:var(--blue-light); color:var(--blue-accent); }
.pill-neutral{ background:var(--bg-surface-hover); color:var(--text-muted); }

/* === Data Table ========================================================= */
.pdata-wrap{
  background:var(--bg-surface); border:1px solid var(--pr-border);
  border-radius:var(--rad-lg); overflow:hidden; box-shadow:var(--sh-card);
}
.pdata-table{ width:100%; border-collapse:collapse; }
.pdata-table thead th{
  padding:12px 20px; text-align:left;
  font-size:var(--text-micro); font-weight:700; color:var(--text-muted);
  text-transform:uppercase; letter-spacing:.06em;
  background:var(--bg-app); border-bottom:1px solid var(--pr-border);
  white-space:nowrap;
}
.pdata-table{ table-layout:auto; }
.pdata-table tbody td{
  padding:14px 20px; font-size:var(--text-sm); color:var(--text-main);
  vertical-align:middle; white-space:nowrap;
}
.pdata-table tbody td:nth-child(2){ white-space:normal; }
.pdata-table tbody td:first-child{ min-width:280px; white-space:normal; }
.pdata-table tbody tr{
  border-bottom:1px solid var(--pr-border-light);
  transition:background .12s ease;
}
.pdata-table tbody tr:last-child{ border-bottom:none; }
.pdata-table tbody tr:hover{ background:var(--bg-surface-hover); }
.pdata-table tbody td{
  padding:14px 20px; font-size:var(--text-sm); color:var(--text-main);
  vertical-align:middle;
}
.pdata-table .amount{ font-variant-numeric:tabular-nums; font-weight:700; text-align:right; white-space:nowrap; }
.pdata-table .amount-pos{ color:var(--primary); }
.pdata-table .amount-neg{ color:var(--danger); }
.pdata-table .col-action{ width:48px; text-align:right; }
.pdata-row-avatar{
  display:flex; align-items:center; gap:12px;
}
.pdata-row-avatar .avatar{
  width:38px; height:38px; border-radius:var(--rad-full);
  background:var(--blue-light); color:var(--blue-accent);
  display:inline-flex; align-items:center; justify-content:center;
  font-weight:700; font-size:13px; flex-shrink:0; overflow:hidden;
}
.pdata-row-avatar .avatar img{ width:100%; height:100%; object-fit:cover; }
.pdata-row-avatar .name{ font-weight:700; color:var(--text-main); font-size:var(--text-sm); }
.pdata-row-avatar .sub{ font-size:var(--text-xs); color:var(--text-muted); margin-top:2px; }
.pbar{ width:100%; height:6px; background:var(--bg-app); border-radius:var(--rad-full); overflow:hidden; }
.pbar > span{ display:block; height:100%; background:var(--primary); border-radius:var(--rad-full); transition:width .3s ease; }
.pbar-meta{ font-size:var(--text-micro); color:var(--text-muted); margin-top:4px; font-weight:500; }
.pdata-empty{
  padding:48px 20px; text-align:center; color:var(--text-muted);
}
.pdata-empty .em-i{ font-size:48px; margin-bottom:14px; opacity:.4; }
.pdata-empty h3{ font-family:'Cairo'; font-weight:700; color:var(--text-main); font-size:var(--text-lg); margin-bottom:6px; }
.pdata-empty p{ font-size:var(--text-sm); }

/* === Kebab Menu ========================================================= */
.pkebab{
  position:relative; display:inline-block;
}
.pkebab-btn{
  width:32px; height:32px; border-radius:var(--rad-md); background:transparent;
  border:none; color:var(--text-muted); cursor:pointer;
  display:inline-flex; align-items:center; justify-content:center;
  transition:background .15s ease;
}
.pkebab-btn:hover{ background:var(--bg-surface-hover); color:var(--text-main); }
.pkebab-menu{
  position:absolute; right:0; top:calc(100% + 4px); z-index:50;
  background:var(--bg-surface); border:1px solid var(--pr-border);
  border-radius:var(--rad-md); box-shadow:var(--sh-dropdown);
  min-width:200px; padding:4px; display:none;
}
.pkebab.open .pkebab-menu{ display:block; }
.pkebab-menu button{
  display:flex; align-items:center; gap:10px; width:100%;
  padding:8px 12px; background:transparent; border:none; cursor:pointer;
  font-size:var(--text-sm); color:var(--text-main); text-align:left;
  border-radius:var(--rad-sm); font-weight:500; transition:background .12s;
}
.pkebab-menu button:hover{ background:var(--bg-surface-hover); }
.pkebab-menu button.danger{ color:var(--danger); }
.pkebab-menu .divider{ height:1px; background:var(--pr-border-light); margin:4px 0; }

/* === Sheet Drawer (right slide-in) ====================================== */
.psheet-overlay{
  position:fixed; inset:0; z-index:9998;
  background:rgba(15,23,42,.4); backdrop-filter:blur(6px);
  opacity:0; pointer-events:none; transition:opacity .2s ease;
}
.psheet-overlay.open{ opacity:1; pointer-events:auto; }
.psheet{
  position:fixed; right:0; top:0; bottom:0; z-index:9999;
  width:min(560px, 100vw); background:var(--bg-app);
  box-shadow:var(--sh-drawer);
  transform:translateX(100%); transition:transform .25s ease-out;
  display:flex; flex-direction:column;
}
.psheet.open{ transform:translateX(0); }
.psheet-head{
  background:var(--bg-surface); border-bottom:1px solid var(--pr-border);
  padding:18px 24px; display:flex; align-items:center; justify-content:space-between;
}
.psheet-head h2{ font-family:'Cairo'; font-size:var(--text-xl); font-weight:800; letter-spacing:-0.02em; }
.psheet-tabs{
  background:var(--bg-surface); border-bottom:1px solid var(--pr-border);
  padding:0 24px; display:flex; gap:24px; overflow-x:auto;
}
.psheet-tab{
  border:none; background:transparent; padding:14px 0;
  font-size:var(--text-sm); font-weight:700; color:var(--text-muted);
  cursor:pointer; border-bottom:2px solid transparent; transition:color .15s, border-color .15s;
  white-space:nowrap;
}
.psheet-tab.active{ color:var(--primary); border-bottom-color:var(--primary); }
.psheet-tab:hover{ color:var(--text-main); }
.psheet-body{ flex:1; overflow-y:auto; padding:24px; display:flex; flex-direction:column; gap:16px; }

/* === Empty State (premium) ============================================== */
.pempty{
  background:var(--bg-surface); border:1px dashed var(--pr-border);
  border-radius:var(--rad-lg); padding:48px 24px; text-align:center;
}
.pempty .em-i{ width:56px; height:56px; border-radius:var(--rad-full);
  background:var(--bg-app); margin:0 auto 16px; display:flex;
  align-items:center; justify-content:center; color:var(--text-muted); }
.pempty h3{ font-family:'Cairo'; font-weight:700; font-size:var(--text-lg); color:var(--text-main); margin-bottom:4px; }
.pempty p{ color:var(--text-muted); font-size:var(--text-sm); }

/* === Mobile collapses =================================================== */
@media (max-width: 640px){
  .kpi-strip{ grid-template-columns:repeat(auto-fit, minmax(180px, 1fr)); gap:var(--sp-3); }
  .pdata-table thead{ display:none; }
  .pdata-table, .pdata-table tbody, .pdata-table tr, .pdata-table td{ display:block; width:100%; }
  .pdata-table tbody tr{ padding:14px 18px; }
  .pdata-table tbody td{ padding:6px 0; }
  .pdata-table .col-action{ position:absolute; right:14px; top:14px; width:auto; }
  .pdata-table tbody tr{ position:relative; }
  .page-head h1{ font-size:var(--text-2xl); }
  .psheet{ width:100vw; }
  .pfilter-bar{ flex-direction:column; align-items:stretch; }
  .psearch{ flex:1 1 auto; }
}

/* === Lucide icon sizing helper ========================================= */
.licon{ width:18px; height:18px; stroke-width:2; flex-shrink:0; }
.licon-sm{ width:14px; height:14px; stroke-width:2; flex-shrink:0; }
.licon-lg{ width:22px; height:22px; stroke-width:2; flex-shrink:0; }
