/* Initiotech Ops — composants de base (v1.0)
 * Minimal, tokens-driven. Les vues peuvent étendre librement.
 */

/* Container central */
.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--space-4);
}

/* sr-only — contenu visuellement caché mais lu par les lecteurs d'écran */
.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;
}

/* Cards */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: var(--space-6);
}

/* Form */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); }
.form-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-control {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-2);
  color: var(--ink-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.form-control:focus {
  outline: 0;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(30, 123, 61, 0.25);
}
.form-control::placeholder { color: var(--ink-4); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-500); color: #fff; }
.btn-primary:hover { background: var(--brand-600); text-decoration: none; color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--ink-1); text-decoration: none; }
.btn-block { width: 100%; }

/* Alerts */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid;
  font-size: var(--fs-sm);
}
.alert-danger { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.5); color: #FCA5A5; }
.alert-warning { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.5); color: #FCD34D; }
.alert-success { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.5); color: #86EFAC; }
[data-theme="light"] .alert-danger { color: #B91C1C; }
[data-theme="light"] .alert-warning { color: #B45309; }
[data-theme="light"] .alert-success { color: #047857; }

/* Header global */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg-1) 85%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.app-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  max-width: 1440px;
  margin-inline: auto;
}
.app-header__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--ink-1);
  font-weight: 700;
  text-decoration: none;
}
.app-header__brand:hover { text-decoration: none; color: var(--ink-1); }
.app-header__brand img { height: 28px; width: auto; display: block; }
.app-header__nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.app-header__nav a {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
}
.app-header__nav a:hover { background: var(--bg-2); color: var(--ink-1); text-decoration: none; }
.app-header__nav a[aria-current="page"] {
  color: var(--brand-500);
  background: color-mix(in srgb, var(--brand-500) 12%, transparent);
}
.app-header__actions { display: flex; align-items: center; gap: var(--space-2); }
.app-header__avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--brand-500);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-2);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-sm);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.theme-toggle:hover { background: var(--bg-2); color: var(--ink-1); }
.theme-toggle[aria-pressed="true"] { color: var(--brand-500); border-color: var(--brand-500); }

/* Admin sub-navigation shared by admin detail pages */
.admin-subnav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
  flex-wrap: wrap;
}

.admin-subnav a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-3);
  color: var(--ink-2);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.admin-subnav a:hover {
  background: var(--bg-2);
  color: var(--ink-1);
  text-decoration: none;
}

.admin-subnav .admin-subnav__home {
  color: var(--brand-500);
  font-weight: 700;
  gap: var(--space-2);
}

.admin-subnav__spacer {
  flex: 1 1 auto;
  min-width: 0;
}

.admin-subnav__user {
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.admin-theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-1);
  color: var(--ink-1);
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.admin-theme-toggle:hover {
  background: var(--bg-2);
}

.admin-theme-toggle__icon {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  border: 2px solid currentColor;
  box-shadow: inset -6px 0 0 currentColor;
}

/* Command palette */
.command-palette[hidden] {
  display: none;
}

.command-palette__scrim {
  position: fixed;
  inset: 0;
  z-index: 1090;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(3px);
}

.command-palette__dialog {
  position: fixed;
  z-index: 1091;
  top: min(12vh, 90px);
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 24px));
  background: var(--bg-1);
  color: var(--ink-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.command-palette__search {
  display: grid;
  grid-template-columns: 24px 1fr 36px;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.command-palette__search input {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink-1);
  font: inherit;
  min-height: 44px;
}

.command-palette__search button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.command-palette__hint {
  padding: var(--space-2) var(--space-3) 0;
  color: var(--ink-4);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.command-palette__results {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2);
  max-height: min(58vh, 460px);
  overflow-y: auto;
}

.command-palette__item {
  width: 100%;
  display: grid;
  grid-template-columns: 24px 1fr 24px;
  align-items: center;
  gap: var(--space-3);
  min-height: 52px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-1);
  text-align: left;
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  font: inherit;
}

.command-palette__item:hover,
.command-palette__item:focus {
  outline: 0;
  background: var(--bg-2);
}

.command-palette__item span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.command-palette__item strong {
  font-size: var(--fs-sm);
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-palette__item small {
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.command-palette__empty {
  color: var(--ink-3);
  padding: var(--space-5);
  text-align: center;
}

body.command-palette-open {
  overflow: hidden;
}

/* Admin sidebar shared partial */
.admin-sidebar__brand {
  padding-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.admin-sidebar__brand-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.admin-sidebar__collapse {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.admin-sidebar__section {
  padding: 14px 24px 4px;
  font-size: 0.65rem;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.admin-sidebar__role {
  padding: 16px 24px 8px;
  font-size: 0.7rem;
  color: var(--ink-3);
  text-transform: uppercase;
  font-weight: 600;
}

body.admin-sidebar-collapsed {
  --sidebar-width: 76px;
}

body.admin-sidebar-collapsed .admin-sidebar__brand-link,
body.admin-sidebar-collapsed .admin-sidebar__section,
body.admin-sidebar-collapsed .admin-sidebar__role,
body.admin-sidebar-collapsed .admin-sidebar__tech-head,
body.admin-sidebar-collapsed .tech-list,
body.admin-sidebar-collapsed .admin-sidebar__user-text,
body.admin-sidebar-collapsed .nav-label {
  display: none !important;
}

body.admin-sidebar-collapsed .admin-sidebar .nav-item {
  justify-content: center;
  padding-inline: 0;
  margin-inline: 8px;
  border-radius: var(--radius-md);
}

/* Burger menu (mobile) */
.app-header__burger {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-2);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
@media (max-width: 720px) {
  .app-header__burger { display: inline-flex; align-items: center; justify-content: center; }
  .app-header__nav { display: none; }
  .app-header__nav.is-open {
    display: flex;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--bg-1);
    flex-direction: column;
    gap: 0;
    padding: var(--space-2);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--card-shadow);
  }
  .app-header__nav.is-open a {
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    width: 100%;
  }
}
