/* =====================================================================
   LINKTECK — app.css
   Charte : bleu profond #123a63 / #1e5fa8, cyan #22b3e6
   Typo   : Space Grotesk (titres) + Inter (corps) + JetBrains Mono (données)
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* --- Palette claire --- */
  --bg:            #f4f6fa;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --border:        #e6ebf2;
  --border-strong: #cdd7e3;
  --text:          #0d1b2e;
  --text-muted:    #5f7189;
  --text-faint:    #96a5b8;

  /* --- Accents charte LINKTECK --- */
  --primary:       #1e5fa8;
  --primary-dark:  #123a63;
  --primary-soft:  #eaf2fb;
  --accent:        #22b3e6;

  /* --- Sidebar --- */
  --sidebar-bg:    #0e2a47;
  --sidebar-text:  #c3d3e5;
  --sidebar-muted: #6f88a5;
  --sidebar-active:#1e5fa8;

  /* --- Statuts --- */
  --st-new:     #6366f1;
  --st-open:    #1e5fa8;
  --st-wait:    #e08c17;
  --st-progress:#0e9dc4;
  --st-resolved:#12a05f;
  --st-closed:  #5f7189;
  --st-cancel:  #96a5b8;

  /* --- Priorités --- */
  --pr-low:     #5f7189;
  --pr-normal:  #1e5fa8;
  --pr-high:    #e08c17;
  --pr-urgent:  #e2600f;
  --pr-critical:#d92d3c;

  --ok:   #12a05f;
  --err:  #d92d3c;
  --warn: #e08c17;

  /* --- Formes & profondeur --- */
  --radius:    14px;
  --radius-sm: 9px;
  --radius-xs: 6px;
  --shadow:    0 1px 2px rgba(13,27,46,.04), 0 4px 14px -4px rgba(13,27,46,.08);
  --shadow-md: 0 2px 6px rgba(13,27,46,.06), 0 12px 28px -8px rgba(13,27,46,.14);
  --shadow-lg: 0 8px 40px -8px rgba(13,27,46,.24);
  --ring:      0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);

  /* --- Typo --- */
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-sans:    "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:    "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  --sidebar-w: 244px;
  --topbar-h:  62px;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

html[data-theme="dark"] {
  --bg:            #0a1524;
  --surface:       #10203a;
  --surface-2:     #0d1a2e;
  --border:        #1f3555;
  --border-strong: #2e4870;
  --text:          #e6edf6;
  --text-muted:    #92a6c2;
  --text-faint:    #62758f;

  --primary:       #3b8fd4;
  --primary-dark:  #1e5fa8;
  --primary-soft:  #12293f;
  --accent:        #22b3e6;

  --sidebar-bg:    #071627;
  --sidebar-text:  #c3d3e5;
  --sidebar-muted: #62758f;
  --sidebar-active:#1e5fa8;

  --shadow:    0 1px 2px rgba(0,0,0,.3), 0 4px 14px -4px rgba(0,0,0,.4);
  --shadow-md: 0 2px 6px rgba(0,0,0,.35), 0 12px 28px -8px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 40px -8px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; transition: color .15s var(--ease); }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.02em; }

/* ---------------------------------------------------------------- */
/* Layout applicatif : sidebar + zone principale                    */
/* ---------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
  transition: transform .25s var(--ease);
  border-right: 1px solid rgba(34,179,230,.14);
}
.sidebar__brand {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.sidebar__brand .accent { color: var(--accent); }
.sidebar__brand .logo-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  display: grid; place-items: center;
  font-size: 15px; font-weight: 700; color: #fff;
  box-shadow: 0 3px 10px -2px rgba(34,179,230,.45);
}
.sidebar__nav { flex: 1; overflow-y: auto; padding: 16px 0 20px; }
.nav-group__label {
  padding: 0 18px;
  margin: 16px 0 7px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 18px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-link:hover {
  background: rgba(255,255,255,.05);
  color: #fff;
  text-decoration: none;
}
.nav-link.is-active {
  background: linear-gradient(90deg, color-mix(in srgb, var(--sidebar-active) 55%, transparent) 0%, transparent 100%);
  color: #fff;
  font-weight: 600;
}
.nav-link.is-active::before {
  content: "";
  position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav-link .ico { width: 18px; text-align: center; font-size: 15px; opacity: .85; }

/* --- Zone principale --- */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* --- Topbar --- */
.topbar {
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 22px;
  gap: 12px;
  position: sticky; top: 0; z-index: 30;
  flex-shrink: 0;
}
.topbar__search { position: relative; width: min(420px, 40vw); }
.topbar__search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
.topbar__search input::placeholder { color: var(--text-faint); }
.topbar__search input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: var(--ring);
}
.topbar__search .search-ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); font-size: 14px; pointer-events: none;
}
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.user-chip__avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  display: grid; place-items: center;
  color: #fff; font-size: 11.5px; font-weight: 700;
  font-family: var(--font-display);
}
.user-chip__name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-chip__role { font-size: 11px; color: var(--text-muted); line-height: 1.2; }

/* --- Contenu --- */
.content { padding: 26px 28px 40px; flex: 1; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.03em;
}
.page-subtitle { color: var(--text-muted); font-size: 13.5px; margin-top: 3px; }

/* ---------------------------------------------------------------- */
/* Composants                                                       */
/* ---------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow .2s var(--ease);
}
.card__body { padding: 20px; }
.card__head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}

/* Grille de stats dashboard */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--accent) 100%);
}
.stat.is-warn::before { background: var(--warn); }
.stat.is-err::before  { background: var(--err); }
.stat.is-ok::before   { background: var(--ok); }
.stat__label {
  font-size: 11px; color: var(--text-muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
}
.stat__value {
  font-family: var(--font-display);
  font-size: 30px; font-weight: 700; margin-top: 7px;
  letter-spacing: -0.035em;
  font-feature-settings: "tnum";
}
.stat__hint { font-size: 12px; color: var(--text-faint); margin-top: 3px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th {
  text-align: left;
  padding: 12px 16px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr { transition: background .12s var(--ease); }
table.data tbody tr:hover { background: var(--primary-soft); }
table.data tbody tr:last-child td { border-bottom: none; }

.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: -0.01em;
  font-feature-settings: "tnum";
}

/* Badges statut & priorité */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3.5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .01em;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--new      { color: var(--st-new);      background: color-mix(in srgb, var(--st-new) 12%, transparent); }
.badge--open     { color: var(--st-open);     background: color-mix(in srgb, var(--st-open) 12%, transparent); }
.badge--wait     { color: var(--st-wait);     background: color-mix(in srgb, var(--st-wait) 14%, transparent); }
.badge--progress { color: var(--st-progress); background: color-mix(in srgb, var(--st-progress) 12%, transparent); }
.badge--resolved { color: var(--st-resolved); background: color-mix(in srgb, var(--st-resolved) 12%, transparent); }
.badge--closed   { color: var(--st-closed);   background: color-mix(in srgb, var(--st-closed) 14%, transparent); }
.badge--cancel   { color: var(--st-cancel);   background: color-mix(in srgb, var(--st-cancel) 14%, transparent); }

.prio { font-weight: 600; font-size: 12.5px; display: inline-flex; align-items: center; gap: 5px; }
.prio::before { content: "▸"; }
.prio--low      { color: var(--pr-low); }
.prio--normal   { color: var(--pr-normal); }
.prio--high     { color: var(--pr-high); }
.prio--urgent   { color: var(--pr-urgent); }
.prio--critical { color: var(--pr-critical); }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 17px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s var(--ease), border-color .15s var(--ease),
              transform .12s var(--ease), box-shadow .15s var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--primary) 50%, transparent);
}
.btn--primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 14px -3px color-mix(in srgb, var(--primary) 55%, transparent);
}
.btn--ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn--ghost:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }
.btn--danger {
  background: var(--err); color: #fff;
  box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--err) 50%, transparent);
}
.btn--danger:hover { filter: brightness(.93); }
.btn--sm { padding: 6px 12px; font-size: 12.5px; border-radius: var(--radius-xs); }

/* Formulaires */
.form-row { margin-bottom: 16px; }
.form-row label {
  display: block; font-size: 12.5px; color: var(--text-muted);
  font-weight: 600; margin-bottom: 6px;
}
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
.form-row textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

/* Alertes / flash */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid;
  border-left-width: 3px;
}
.alert--ok   { background: color-mix(in srgb, var(--ok) 8%, transparent);   border-color: var(--ok);   color: var(--ok); }
.alert--err  { background: color-mix(in srgb, var(--err) 8%, transparent);  border-color: var(--err);  color: var(--err); }
.alert--warn { background: color-mix(in srgb, var(--warn) 8%, transparent); border-color: var(--warn); color: var(--warn); }
.alert--info { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }

/* Empty state */
.empty { text-align: center; padding: 52px 20px; color: var(--text-muted); }
.empty__icon { font-size: 42px; opacity: .35; margin-bottom: 14px; }
.empty__title {
  font-family: var(--font-display);
  font-weight: 600; font-size: 15.5px;
  color: var(--text); margin-bottom: 5px;
}
.empty p { margin: 0 0 16px; font-size: 13.5px; }

/* ---------------------------------------------------------------- */
/* Mobile                                                           */
/* ---------------------------------------------------------------- */
.sidebar-toggle { display: none; }
.sidebar__backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: translateX(0); }
  .main { margin-left: 0; }
  .sidebar-toggle { display: grid; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 20px 16px 32px; }
  .topbar { padding: 0 14px; }
  .topbar__search { width: auto; flex: 1; }
  .user-chip__name, .user-chip__role { display: none; }
  .sidebar__backdrop.is-open {
    display: block; position: fixed; inset: 0;
    background: rgba(7,22,39,.55); z-index: 35;
  }
}

/* Accessibilité : focus visible clavier */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
