/* Asgard — composants de la charte « Glacier · Cobalt » (Button, IconButton, Switch, SegmentedControl,
   SearchField, StatusBadge, Terminal), en CSS. Classes ag-* ; chaque app y rattache aussi ses propres classes. */

/* ---------- Bouton : principal (accent), secondaire (surface), texte (tertiaire) ---------- */
.ag-btn {
  height: var(--control-h);
  padding: 0 20px;
  border-radius: var(--radius-button);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-text);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.ag-btn:active:not(:disabled) { transform: scale(0.97); }
.ag-btn:disabled { opacity: 0.45; cursor: default; }
.ag-btn-sm { height: var(--control-h-sm); padding: 0 16px; font-size: 13px; }
.ag-btn-primary { background: var(--accent-fill); color: var(--on-accent-fill); box-shadow: var(--button-shadow); font-weight: 600; }
.ag-btn-glass {
  background: var(--glass-bg-1);
  -webkit-backdrop-filter: var(--glass-filter-1);
  backdrop-filter: var(--glass-filter-1);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow-1);
}
.ag-btn-text { color: var(--accent); padding: 0 12px; }

/* ---------- Bouton rond à icône ---------- */
.ag-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--text);
  cursor: pointer;
  background: var(--glass-bg-1);
  -webkit-backdrop-filter: var(--glass-filter-1);
  backdrop-filter: var(--glass-filter-1);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow-1);
}
.ag-icon-btn.is-active { color: var(--accent); background: var(--accent-soft); }

/* ---------- Interrupteur : piste 64 × 28, pouce 38 × 24 ----------
   Sur <input type="checkbox" class="ag-switch">. */
.ag-switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 64px;
  height: 28px;
  margin: 0;
  border: none;
  padding: 0;
  border-radius: 14px;
  background: var(--control-off);
  cursor: pointer;
  transition: background 0.2s ease;
}
.ag-switch:checked { background: var(--accent-fill); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12); }
.ag-switch:disabled { opacity: 0.45; cursor: default; }
.ag-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 38px;
  height: 24px;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--thumb-shadow);
  transition: left 0.22s cubic-bezier(0.3, 1.4, 0.5, 1), top 0.22s cubic-bezier(0.3, 1.4, 0.5, 1), width 0.22s cubic-bezier(0.3, 1.4, 0.5, 1),
    height 0.22s cubic-bezier(0.3, 1.4, 0.5, 1), border-radius 0.22s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.ag-switch:checked::after { left: 24px; }
/* ---------- Contrôle segmenté : 2 à 4 options, segment choisi en surface pleine ---------- */
.ag-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-button);
  font-family: var(--font-text);
  font-size: 14px;
  font-weight: 500;
  background: var(--glass-bg-1);
  -webkit-backdrop-filter: var(--glass-filter-1);
  backdrop-filter: var(--glass-filter-1);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow-1);
}
.ag-seg > button {
  padding: 8px 16px;
  border-radius: var(--radius-button);
  border: none;
  cursor: pointer;
  font: inherit;
  color: var(--text-2);
  background: transparent;
  transition: background 0.15s ease;
}
.ag-seg > button.is-on,
.ag-seg > button[aria-checked='true'] {
  color: var(--text);
  background: var(--glass-bg-3);
  box-shadow: var(--glass-shadow-3);
}

/* ---------- Champ de recherche : pilule de surface pleine ---------- */
.ag-search {
  height: var(--field-h);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  color: var(--text-2);
  background: var(--glass-bg-2);
  -webkit-backdrop-filter: var(--glass-filter-2);
  backdrop-filter: var(--glass-filter-2);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow-2);
}
.ag-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-text);
  font-size: 15px;
}

/* ---------- États système ---------- */
.ag-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--idle-soft);
  color: var(--idle);
}
.ag-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ag-status-sm { gap: 6px; padding: 3px 10px 3px 8px; font-size: 12px; }
.ag-status-sm::before { width: 6px; height: 6px; }
.ag-status.ok { background: var(--ok-soft); color: var(--ok); }
.ag-status.warn { background: var(--warn-soft); color: var(--warn); }
.ag-status.crit { background: var(--crit-soft); color: var(--crit); }
.ag-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--idle); box-shadow: 0 0 0 4px var(--idle-soft); }
.ag-dot.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.ag-dot.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.ag-dot.crit { background: var(--crit); box-shadow: 0 0 0 4px var(--crit-soft); }

/* ---------- Terminal : toujours sombre, même en thème clair ---------- */
.ag-terminal {
  border-radius: var(--radius-control);
  background: var(--terminal-bg);
  -webkit-backdrop-filter: var(--glass-filter-3);
  backdrop-filter: var(--glass-filter-3);
  box-shadow: var(--glass-shadow-3);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--terminal-text);
  overflow: hidden;
}

/* ---------- Libellé micro (mono, capitales) ---------- */
.ag-label {
  font-family: var(--font-mono);
  font-size: var(--type-label-size);
  letter-spacing: var(--type-label-tracking);
  text-transform: uppercase;
  color: var(--text-2);
}

/* ---------- Cadre desktop : barre latérale (surface 3) + barre d'outils (surface 1) ----------
   Sous 900 px : barre d'outils en haut et barre d'onglets (pilule) 28 px au-dessus du bas. */
.ag-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  min-height: 100dvh;
}
.ag-sidebar {
  position: sticky;
  top: 12px;
  height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 12px 14px;
  border-radius: var(--radius-card);
  overflow-y: auto;
}
.ag-sidebar-head {
  padding: 0 6px 16px;
}
.ag-sidebar-head > button,
.ag-sidebar-head > a {
  display: inline-flex;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}
.ag-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: var(--radius-control);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-text);
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  text-decoration: none;
}
.ag-nav-item:hover { background: var(--accent-soft); }
.ag-nav-item.is-on,
.ag-nav-item[aria-current='page'] { background: rgba(127, 127, 127, 0.16); font-weight: 600; }
.ag-nav-item svg { flex-shrink: 0; color: var(--text-2); }
.ag-nav-item.is-on svg,
.ag-nav-item[aria-current='page'] svg { color: var(--text); }
.ag-nav-count {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--accent-fill);
  color: var(--on-accent-fill);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 20px;
  text-align: center;
}
.ag-nav-count.crit { background: var(--crit); color: #fff; }
.ag-sidebar-foot {
  margin-top: auto;
  padding: 12px 6px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-text);
  font-size: var(--desk-caption);
  color: var(--text-2);
}
.ag-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.ag-toolbar {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 8px 8px 18px;
  border-radius: var(--radius-card);
}
.ag-toolbar-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ag-toolbar-logo { display: none; }
.ag-toolbar-actions { display: flex; align-items: center; gap: 8px; }
.ag-toolbar .ag-icon-btn { width: 36px; height: 36px; }
.ag-content { min-width: 0; }
.ag-tabbar {
  display: none;
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  justify-content: space-between;
  gap: 2px;
  padding: 5px;
  border-radius: 30px;
}
.ag-tabbar > button {
  position: relative;
  width: 52px;
  height: 44px;
  border-radius: 22px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-2);
  transition: background 0.15s ease;
}
.ag-tabbar > button.is-on { background: var(--accent-soft); color: var(--accent); }
.ag-tabbar .ag-nav-count { position: absolute; top: 2px; right: 4px; margin: 0; min-width: 16px; height: 16px; line-height: 16px; font-size: 10px; padding: 0 4px; }

@media (max-width: 900px) {
  .ag-shell { display: block; padding: 0 0 calc(110px + env(safe-area-inset-bottom, 0px)); }
  .ag-sidebar { display: none; }
  .ag-main { gap: 12px; }
  .ag-toolbar {
    top: 0;
    border-radius: 0;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px 16px;
  }
  .ag-toolbar-title { display: none; }
  .ag-toolbar-logo { display: flex; flex: 1; min-width: 0; }
  .ag-content { padding: 0 12px; }
  .ag-tabbar { display: flex; }
}
.ag-only-mobile { display: none !important; }
@media (max-width: 900px) {
  .ag-only-mobile { display: inline-flex !important; }
  .ag-only-desktop { display: none !important; }
}

/* Version sobre : la barre latérale et la barre d'outils sont posées, pas flottantes (ombre minimale). */
.ag-sidebar,
.ag-toolbar {
  box-shadow: var(--elev-1);
}
