/* =========================================================
   DARK THEME (base = ta version) + responsive fixes
   ========================================================= */

/* --- grilles & charts --- */
.grid2 { display:grid; grid-template-columns: 1.2fr 1fr; gap: 12px; align-items:start; }
.chart-box { position:relative; height:260px; max-height:260px; overflow:hidden; }

/* --- base sidebar layout --- */
body { margin:0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 260px; background: #0f172a; color: #fff;
  padding: 16px 12px; overflow-y: auto;
}
.brand { font-weight: 700; letter-spacing: .5px; margin-bottom: 12px; }
.menu { display: flex; flex-direction: column; gap: 6px; }
.menu .item, .menu .sub, .menu summary {
  color: #e2e8f0; text-decoration: none; border-radius: 8px; padding: 8px 10px;
}
.menu .item:hover, .menu .sub:hover, .menu summary:hover { background: rgba(255,255,255,.08); cursor: pointer; }
.menu details { border-radius: 10px; padding: 4px; }
.menu details[open] { background: rgba(255,255,255,.03); }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display:none; }
.menu .sub { display:block; margin: 2px 0 2px 12px; font-size: 0.95rem; }

.container.with-sidebar, .footer.with-sidebar { margin-left: 260px; }
.container.with-sidebar { padding: 16px; min-height: calc(100dvh - 48px); } /* NEW: un peu moins haut */
.footer.with-sidebar { padding: 10px 16px; border-top: 1px solid #1f2937; } /* NEW: border plus dark */

/* --- lien actif --- */
.menu a.active, .menu .sub.active { background: rgba(99,102,241,.25); color: #fff; }

/* --- listes compactes --- */
.list-compact { margin: 0; padding-left: 1rem; }
.list-compact li { margin: 2px 0; }

/* --- badges de rang --- */
.rb { display: inline-block; margin-right: 6px; }
.rb-gold  { filter: saturate(1.2); }
.rb-silver{ filter: saturate(0.9); }
.rb-bronze{ filter: saturate(0.9); }
.rb-final { opacity: 0.9; }

.card h3 { display: flex; align-items:center; gap: .5rem; }
.idx { opacity: .7; margin-left: .4rem; }
.ctx { opacity: .6; margin-left: .3rem; font-style: italic; }

/* --- chart boxing --- */
.chart-box {
  position: relative;
  height: 280px;
  max-height: 280px;
  overflow: hidden;
}
.chart-box canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* --- palette --- */
:root{
  --bg:#0b0c10;
  --surface:#111317;
  --muted:#1a1d24;
  --text:#e5e7eb;
  --text-dim:#9aa3b2;
  --primary:#4f8cff;
  --accent:#1dd1a1;
  --danger:#ff6b6b;
  --warning:#feca57;
  --border:#2a2f3a;
  --radius:12px;

  /* NEW: inputs/select height & spacing */
  --ctl-h: 36px;
  --pad-x: 10px;
  --pad-y: 8px;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Arial,sans-serif;
  background:var(--bg); color:var(--text);
}

/* --- topbar --- */
.topbar{
  position:sticky; top:0; z-index:10;
  background:linear-gradient(180deg,var(--surface),#0b0c1000);
  border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between;
  padding:8px 12px; /* NEW: moins haut */
}
.brand{font-weight:700; letter-spacing:.5px}
.nav a{
  color:var(--text-dim); text-decoration:none; margin:0 6px; padding:6px 10px; border-radius:8px;
}
.nav a:hover{background:var(--muted); color:var(--text)}

/* --- container/sections --- */
.container{max-width:1200px; margin:0 auto; padding:12px} /* NEW: moins de padding */
.section{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:14px; margin-bottom:14px} /* NEW: compacité */
.section h2{margin:0 0 10px 0}

/* --- forms --- */
.form{
  display:grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap:10px; margin-bottom:12px;
}
label{font-size:14px; color:var(--text-dim); display:flex; flex-direction:column; gap:6px}
input[type="text"],input[type="date"],input[type="number"],select,textarea{
  background:var(--muted); color:var(--text); border:1px solid var(--border); border-radius:8px;
  padding: var(--pad-y) var(--pad-x); min-height: var(--ctl-h);
}
textarea{min-height:90px; resize:vertical}

/* NEW: jolis selects (caret custom) */
select{
  appearance:none; -webkit-appearance:none; -moz-appearance:none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%),
    linear-gradient(to right, transparent, transparent);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px),
    100% 0;
  background-size:6px 6px, 6px 6px, 2.5em 100%;
  background-repeat:no-repeat;
  padding-right: 38px;
}

/* boutons */
button{
  background:var(--primary); color:white; border:none; border-radius:10px; padding:9px 14px; cursor:pointer; font-weight:600
}
button.secondary{background:var(--muted); color:var(--text)}
button.danger{background:var(--danger)}
button:disabled{opacity:.6; cursor:not-allowed}

/* --- tables --- */
table{width:100%; border-collapse:collapse; background:var(--surface); border-radius:var(--radius); overflow:hidden}
th,td{border:1px solid var(--border); padding:8px; font-size:14px}
thead th{background:var(--muted); text-align:left}
td[contenteditable]{background:#161a22}

/* badges */
.badge{display:inline-block; padding:2px 8px; border-radius:999px; font-size:12px; border:1px solid var(--border); color:var(--text-dim)}
.badge.pb{background:rgba(29,209,161,.1); color:var(--accent); border-color:rgba(29,209,161,.4)}
.badge.sb{background:rgba(79,140,255,.1); color:var(--primary); border-color:rgba(79,140,255,.4)}

/* footer */
.footer{opacity:.7; font-size:12px; padding:10px 12px; border-top:1px solid var(--border)}

/* =========================================================
   RESPONSIVE AJOUTS
   ========================================================= */

/* --- 1) Sidebar responsive --- */
@media (max-width: 980px){
  /* la sidebar passe en top-strip */
  .sidebar{
    position: sticky; top: 0; width: 100%;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    z-index: 20;
  }
  .brand{ margin: 0 8px 0 0; }
  .menu{
    flex-direction: row; flex-wrap: wrap; gap: 6px;
    overflow-x: auto; max-width: 100%;
  }
  .menu details{ padding: 0; }
  .menu .sub{ margin: 0 0 0 8px; }

  .container.with-sidebar, .footer.with-sidebar{ margin-left: 0; }
  .container.with-sidebar{ padding-top: 12px; }
}

/* --- 2) Grilles & zones de contenu --- */
@media (max-width: 1100px){
  .grid2 { grid-template-columns: 1fr; } /* stack chart + lists */
}

/* --- 3) Tables : wrapper scroll horizontal sur petit viewport --- */
.table-wrap{ overflow:auto; -webkit-overflow-scrolling:touch; border-radius: var(--radius); }
.table-wrap table{ min-width: 640px; } /* pour éviter le tassement extrême */

/* --- 4) Compacité Desktop --- */
@media (min-width: 1200px){
  .container.with-sidebar{ max-width: 1400px; }
  .section{ padding:16px 18px; }
  .form{ gap:12px; }
}

/* --- 5) Boutons et inputs un peu plus denses sur desktop --- */
@media (min-width: 1024px){
  :root{ --ctl-h: 34px; }
  button{ padding:8px 12px; }
}

/* --- 6) Menus déroulants “plus jolis” aussi dans la topbar --- */
.topbar select{
  background:var(--muted); color:var(--text);
  border:1px solid var(--border); border-radius:8px;
  padding:6px 34px 6px 10px; min-height: 32px;
  margin-left: 6px;
}

/* --- 7) Petits helpers utiles --- */
.hide-on-mobile{ display: initial; }
@media (max-width: 640px){ .hide-on-mobile{ display:none; } }

.full-bleed{ margin: -8px -12px 0 -12px; } /* étirer une section à la largeur du container si besoin */

