/* ==========================================================================
   GLPI Front — App CSS (v2)
   - Dark par défaut, Light si :root[data-theme="light"]
   - Safari-friendly selects, focus rings, UI propre & accessible
   ========================================================================== */

/* ---------------------- Design tokens (Dark) ---------------------- */
:root{
  --bg: #0f172a;                /* slate-900 */
  --panel: #0b1220;             /* deep panel */
  --soft: #111827;              /* gray-900 */
  --text: #e5e7eb;              /* gray-200 */
  --muted: #94a3b8;             /* slate-400 */
  --border: rgba(255,255,255,.12);
  --hair: rgba(255,255,255,.08);

  --primary: #60a5fa;           /* blue-400 */
  --primary-2: #3b82f6;         /* blue-500 */
  --accent: #22d3ee;            /* cyan-400 */
  --ok: #34d399;                /* green-400 */
  --warn: #f59e0b;              /* amber-500 */
  --err: #f87171;               /* red-400 */

  --radius: 12px;
  --shadow: 0 10px 25px rgba(0,0,0,.28);
  --ring: 0 0 0 3px rgba(96,165,250,.35);
}

/* ---------------------- Light override ---------------------- */
:root[data-theme="light"]{
  --bg: #f8fafc;                /* slate-50 */
  --panel: #ffffff;
  --soft: #f1f5f9;              /* slate-100 */
  --text: #0f172a;              /* slate-900 */
  --muted: #475569;             /* slate-600 */
  --border: rgba(2,6,23,.14);
  --hair: rgba(2,6,23,.08);

  --primary: #2563eb;           /* blue-600 */
  --primary-2: #1d4ed8;         /* blue-700 */
  --accent: #06b6d4;

  --shadow: 0 10px 24px rgba(2,6,23,.08);
  --ring: 0 0 0 3px rgba(37,99,235,.25);
}

/* ---------------------- Base / Reset ---------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body{
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* ---------------------- Layout helpers ---------------------- */
.container { max-width: 1000px; margin: 32px auto; padding: 0 16px; }

.panel{
  background: linear-gradient(180deg, var(--soft), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 280px; }

.grid { display: grid; gap: 14px; }
@media (min-width: 840px){ .grid.cols-2 { grid-template-columns: 1fr 1fr; } }

/* ---------------------- Headings ---------------------- */
h1,h2,h3 { margin: 0 0 10px; }
h1 { font-size: 28px; letter-spacing:.2px; }
h2 { font-size: 20px; color: color-mix(in hsl, var(--text) 85%, transparent); }
h3 { font-size: 18px; color: color-mix(in hsl, var(--text) 80%, transparent); }

.hr{
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--hair), transparent);
  margin: 12px 0 18px;
}

/* ---------------------- Forms: inputs / textarea ---------------------- */
label { display: block; font-weight: 600; margin: 8px 0 6px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="url"], textarea {
  width: 100%;
  background: var(--soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  background-clip: padding-box; /* Safari border artifact fix */
}

textarea { 
  min-height: 120px; 
  resize: vertical;
}

input:focus, textarea:focus { box-shadow: var(--ring); border-color: var(--primary); }

input[disabled], textarea[disabled], select[disabled]{
  opacity: .6; cursor: not-allowed;
}

/* ---------------------- Buttons ---------------------- */
button, .btn, input[type="submit"]{
  appearance: none; border: 0; cursor: pointer; font-weight: 700;
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  color: white;
  border-radius: 12px; padding: 10px 14px;
  box-shadow: 0 6px 18px color-mix(in hsl, var(--primary) 45%, transparent);
  transition: transform .06s ease, filter .2s ease;
}
button:hover, .btn:hover, input[type="submit"]:hover{ filter: brightness(1.05); }
button:active, .btn:active, input[type="submit"]:active{ transform: translateY(1px); }

.btn.secondary{
  background: linear-gradient(180deg, #94a3b8, #64748b);
  color: #0b1220;
  box-shadow: 0 6px 18px rgba(100,116,139,.28);
}
.btn.ghost{
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.danger{
  background: linear-gradient(180deg, #ef4444, #dc2626);
  box-shadow: 0 6px 18px rgba(239,68,68,.28);
}

/* Sticky action bar (si utilisée) */
.actionbar{
  position: sticky; bottom: 12px; z-index: 5;
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 10px 0;
}

/* ---------------------- Selects (Safari-friendly) ---------------------- */
select{
  width: 100%;
  -webkit-appearance: none; /* Safari iOS/macOS */
  appearance: none;
  background-color: var(--soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 42px 10px 12px; /* espace pour la flèche */
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  background-clip: padding-box; /* Safari fix */

  /* Flèche custom (dark) */
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none' stroke='%23e5e7eb' stroke-width='1.8'><polyline points='6 8 10 12 14 8'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
:root[data-theme="light"] select{
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none' stroke='%230f172a' stroke-width='1.8'><polyline points='6 8 10 12 14 8'/></svg>");
}
select:focus { box-shadow: var(--ring); border-color: var(--primary); }
select[multiple]{ background-image: none; padding-right: 12px; }

/* Option groups: meilleure lisibilité */
optgroup { color: var(--text); font-weight: 700; background: transparent; }
option { color: var(--text); }

/* ---------------------- Checkboxes / Radios (jolis par défaut) ---------------------- */
input[type="checkbox"], input[type="radio"]{
  width: 16px; height: 16px; vertical-align: middle; cursor: pointer;
  accent-color: var(--primary-2); /* support moderne */
}

/* ---------------------- Alerts ---------------------- */
.alert{ padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--soft); }
.alert.ok{ border-color: color-mix(in hsl, var(--ok) 45%, transparent); }
.alert.err{ border-color: color-mix(in hsl, var(--err) 45%, transparent); }

/* ---------------------- Tables ---------------------- */
table { width: 100%; border-collapse: collapse; margin: 10px 0; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--hair); }
thead th { font-weight: 700; color: color-mix(in hsl, var(--text) 88%, transparent); }

/* ---------------------- Header (optionnel) ---------------------- */
.header{
  /* position: sticky; top: 0; z-index: 10; */
  backdrop-filter: blur(8px);
  background: color-mix(in hsl, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--hair);
}
.header-inner{ display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; margin-top: 0px; margin-bottom: 0px;}
.brand{ display: flex; align-items: center; gap: 10px; font-weight: 800; }
#logo svg { height: 32px; width: auto; fill:var(--text)}

/* ---------------------- Theme toggle (bouton) ---------------------- */
/* 2 hooks supportés: .theme-toggle (class) ou #themeToggle (id) */
.theme-toggle, #themeToggle{
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 999px;
  background: var(--soft);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
}
.theme-toggle:hover, #themeToggle:hover { filter: brightness(1.05); }
.theme-toggle:active, #themeToggle:active { transform: translateY(1px); }
.theme-toggle svg, #themeToggle svg { width: 16px; height: 16px; }

/* ---------------------- Dropzone (si présente) ---------------------- */
#dz{
  border: 1px dashed var(--border);
  border-radius: 12px; padding: 14px;
  background: color-mix(in hsl, var(--panel) 92%, transparent);
  transition: border-color .15s ease, background .15s ease;
}
#dz.dragover{
  background: color-mix(in hsl, var(--accent) 18%, transparent);
  border-color: color-mix(in hsl, var(--accent) 50%, transparent);
}
#previews{
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(180px,1fr));
  margin-top: 10px;
}
#previews .preview, #previews .item{
  display: flex; gap: 10px; align-items: center;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 10px;
}
#previews img{
  width: 42px; height: 42px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--hair);
}

/* ---------------------- Utilities ---------------------- */
.muted { color: var(--muted); }
.center { text-align: center; }
.right { text-align: right; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* ---------------------- Motion / Focus ---------------------- */
:focus-visible { outline: none; box-shadow: var(--ring); }
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after { animation: none !important; transition: none !important; }
}