/* --- /styles/hea_backoffice_shell.css --- */
/* Backoffice admin shell: layout, navigation, shared components.
   Builds on hea_tokens.css — never duplicates its variables. */

/* =========================
   1) Backoffice tokens
   ========================= */
:root {
  --bo-sidebar-w: 220px;
  --bo-header-h: 48px;
  --bo-font-xs: .68rem;   /* 11px  – th, badges, sidebar section labels */
  --bo-font-sm: .72rem;   /* 11.5px – td, card labels, breadcrumb */
  --bo-font-md: .78rem;   /* 12.5px – body, buttons, chips */
  --bo-font-lg: .82rem;   /* 13px   – section headings, tabs */
  --bo-font-xl: 1.25rem;  /* 20px   – page title */
  --bo-font-kpi: 1.5rem;  /* 24px   – KPI numbers */
}

/* =========================
   2) Shell layout
   ========================= */
.bo-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  margin: 0;
}

.bo-body {
  display: flex;
  flex: 1 0 auto;
  min-height: 0;
}

/* =========================
   3) Top header bar
   ========================= */
.bo-header {
  position: sticky;
  top: 0;
  z-index: 1001;
  height: var(--bo-header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  flex-shrink: 0;
}

.bo-header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 16px;
  box-sizing: border-box;
}

/* Logo */
.bo-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}
.bo-logo img {
  height: 28px;
  width: auto;
}

/* Breadcrumb */
.bo-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--bo-font-sm);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  min-width: 0;
}
.bo-breadcrumb a {
  color: var(--muted);
  text-decoration: none;
  transition: color .15s;
}
.bo-breadcrumb a:hover { color: var(--ink); }
.bo-sep { opacity: .35; }
.bo-current {
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

/* Header right */
.bo-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Header shortcut links */
.bo-header-link {
  font-size: var(--bo-font-sm);
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  transition: color .12s, background .12s;
  white-space: nowrap;
}
.bo-header-link:hover {
  color: var(--ink);
  background: var(--surface-2);
}

/* Hamburger (mobile only) */
.bo-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  transition: background .15s, color .15s;
  padding: 0;
  flex-shrink: 0;
}
.bo-hamburger:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.bo-hamburger svg { pointer-events: none; }

/* =========================
   4) Left sidebar
   ========================= */
.bo-sidebar {
  position: sticky;
  top: var(--bo-header-h);
  width: var(--bo-sidebar-w);
  height: calc(100vh - var(--bo-header-h));
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 10px 0 20px;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  transition: width .2s ease, padding .2s ease;
  display: flex;
  flex-direction: column;
}
.bo-sidebar::-webkit-scrollbar { width: 4px; }
.bo-sidebar::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

/* Sidebar section */
.bo-sidebar-section {
  padding: 0;
  margin: 0 0 2px;
}
.bo-sidebar-section + .bo-sidebar-section {
  margin-top: 12px;
}

.bo-sidebar-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: var(--bo-font-xs);
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  user-select: none;
}
.bo-sidebar-label svg {
  flex-shrink: 0;
  opacity: .7;
}

/* Sidebar links */
.bo-sidebar-links {
  list-style: none;
  margin: 0;
  padding: 0;
}
.bo-sidebar-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px 5px 22px;
  font-size: var(--bo-font-sm);
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: color .12s, background .12s, border-color .12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}
.bo-sidebar-link:hover {
  color: var(--ink);
  background: var(--surface-2);
}
.bo-sidebar-link.active {
  color: var(--brand1);
  border-left-color: var(--brand1);
  background: color-mix(in srgb, var(--brand1) 6%, transparent);
  font-weight: 600;
}
.bo-sidebar-link svg {
  flex-shrink: 0;
  opacity: .55;
  width: 14px;
  height: 14px;
}
.bo-sidebar-link.active svg { opacity: .85; }
.bo-sidebar-link .external-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  opacity: .4;
  margin-left: auto;
  flex-shrink: 0;
}

/* =========================
   5) Main content
   ========================= */
.bo-main {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 1400px;
  padding: 20px 24px 40px;
  box-sizing: border-box;
  transition: max-width .2s ease;
}

/* --- Sidebar collapse toggle --- */
.bo-sidebar-toggle {
  margin-top: auto;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: var(--bo-font-xs);
  font-weight: 600;
  cursor: pointer;
  transition: color .15s;
  white-space: nowrap;
}
.bo-sidebar-toggle:hover { color: var(--ink); }
.bo-sidebar-toggle svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform .2s ease;
}

/* --- Collapsed sidebar state --- */
.bo-sidebar--collapsed {
  width: 36px;
  padding: 10px 0 8px;
  border-right: 1px solid var(--line);
  overflow: hidden;
}
.bo-sidebar--collapsed .bo-sidebar-section {
  opacity: 0;
  height: 0;
  overflow: hidden;
  padding: 0;
  margin: 0;
  pointer-events: none;
}
.bo-sidebar--collapsed .bo-sidebar-toggle {
  padding: 6px 0;
  justify-content: center;
}
.bo-sidebar--collapsed .bo-sidebar-toggle span {
  display: none;
}
.bo-sidebar--collapsed .bo-sidebar-toggle svg {
  transform: rotate(180deg);
}
.bo-body:has(.bo-sidebar--collapsed) .bo-main {
  max-width: 100%;
}

/* Page title */
.bo-page-title {
  font-size: var(--bo-font-xl);
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.2;
  margin: 0 0 4px;
  color: var(--ink);
}
.bo-page-sub {
  font-size: var(--bo-font-md);
  color: var(--muted);
  margin: 0 0 20px;
  line-height: 1.45;
}

/* =========================
   6) HEA picker
   ========================= */
.bo-hea-picker {
  font-family: inherit;
  font-size: var(--bo-font-md);
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 5px 28px 5px 10px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  max-width: 200px;
}
.bo-hea-picker:hover { border-color: var(--muted); }
.bo-hea-picker:focus {
  outline: none;
  border-color: var(--brand1);
  box-shadow: 0 0 0 3px var(--ring);
}

/* =========================
   7) Cards
   ========================= */
.bo-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: transform .12s, box-shadow .12s;
}
.bo-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.bo-card--ok    { border-left: 3px solid var(--ok); }
.bo-card--warn  { border-left: 3px solid var(--warn); }
.bo-card--fail  { border-left: 3px solid var(--fail); }
.bo-card--info  { border-left: 3px solid var(--link); }

/* KPI card */
.bo-kpi-value {
  font-size: var(--bo-font-kpi);
  font-weight: 850;
  line-height: 1;
  letter-spacing: -.02em;
  color: var(--ink);
}
.bo-kpi-label {
  font-size: var(--bo-font-xs);
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Card grid */
.bo-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

/* =========================
   8) Tables
   ========================= */
.bo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--bo-font-sm);
  line-height: 1.35;
}
.bo-table th {
  font-size: var(--bo-font-xs);
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  white-space: nowrap;
}
.bo-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: top;
}
.bo-table tbody tr:nth-child(even) td {
  background: var(--surface-2);
}
.bo-table tbody tr:hover td {
  background: color-mix(in srgb, var(--link) 4%, var(--surface));
}

/* =========================
   9) Toolbar
   ========================= */
.bo-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.bo-toolbar-left {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.bo-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Filter chips */
.bo-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.bo-chip-label {
  font-size: var(--bo-font-xs);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 800;
  padding: 0 8px 0 6px;
}
.bo-chip {
  border: none;
  border-radius: calc(var(--radius-lg) - 3px);
  padding: 5px 11px;
  background: transparent;
  font-family: inherit;
  font-size: var(--bo-font-sm);
  font-weight: 650;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
  user-select: none;
  white-space: nowrap;
}
.bo-chip:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.bo-chip.active {
  background: var(--ink);
  color: var(--bg);
}

/* Search input */
.bo-search {
  font-family: inherit;
  font-size: var(--bo-font-md);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
  min-width: 160px;
}
.bo-search::placeholder { color: var(--muted); }
.bo-search:focus {
  outline: none;
  border-color: var(--brand1);
  box-shadow: 0 0 0 3px var(--ring);
}

/* =========================
   10) Section divider
   ========================= */
.bo-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 10px;
}
.bo-section-title {
  font-size: var(--bo-font-lg);
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.bo-section-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* =========================
   11) Badges
   ========================= */
.bo-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--bo-font-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
.bo-badge--ok {
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  color: var(--ok);
}
.bo-badge--warn {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  color: var(--warn);
}
.bo-badge--fail {
  background: color-mix(in srgb, var(--fail) 12%, transparent);
  color: var(--fail);
}
.bo-badge--info {
  background: color-mix(in srgb, var(--link) 12%, transparent);
  color: var(--link);
}
.bo-badge--muted {
  background: var(--surface-2);
  color: var(--muted);
}

/* =========================
   12) Buttons
   ========================= */
.bo-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-family: inherit;
  font-size: var(--bo-font-md);
  font-weight: 650;
  color: var(--ink);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s, transform .04s, box-shadow .12s;
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.35;
}
.bo-btn:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}
.bo-btn:active { transform: translateY(.5px); }
.bo-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.bo-btn--primary {
  background: var(--brand-accent);
  color: #fff;
  border-color: var(--brand-accent);
}
.bo-btn--primary:hover {
  filter: brightness(.92);
  background: var(--brand-accent);
}

.bo-btn--danger {
  background: var(--fail);
  color: #fff;
  border-color: var(--fail);
}
.bo-btn--danger:hover {
  filter: brightness(.92);
  background: var(--fail);
}

.bo-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.bo-btn--ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: transparent;
}

/* =========================
   13) Minimal shell mode
   ========================= */
.bo-shell--minimal .bo-sidebar { display: none; }
.bo-shell--minimal .bo-main {
  max-width: 1100px;
  margin: 0 auto;
}
.bo-shell--minimal .bo-hamburger { display: none !important; }

/* =========================
   14) Responsive
   ========================= */
@media (max-width: 1199px) {
  .bo-hamburger { display: flex; }

  .bo-sidebar {
    position: fixed;
    top: var(--bo-header-h);
    left: 0;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: none;
    width: 240px;
  }
  .bo-sidebar--open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.12);
  }

  .bo-main {
    padding: 16px;
  }
}

@media (max-width: 767px) {
  .bo-header-inner { padding: 0 10px; gap: 8px; }
  .bo-logo img { height: 24px; }
  .bo-current { max-width: 140px; }
  .bo-hea-picker { max-width: 150px; font-size: var(--bo-font-sm); }

  .bo-main { padding: 12px 10px 32px; }

  .bo-card-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
  }

  .bo-table { font-size: var(--bo-font-xs); }
  .bo-table th, .bo-table td { padding: 6px 8px; }
}

/* Sidebar overlay backdrop */
.bo-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--bo-header-h);
  background: rgba(0,0,0,.3);
  z-index: 999;
}
.bo-sidebar-backdrop.visible { display: block; }

/* =========================
   15) Utility classes
   ========================= */
.bo-muted { color: var(--muted); }
.bo-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.bo-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bo-flex {
  display: flex;
  gap: 8px;
  align-items: center;
}
.bo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

/* Status dots */
.bo-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.bo-dot--ok   { background: var(--ok); }
.bo-dot--warn { background: var(--warn); }
.bo-dot--fail { background: var(--fail); }
.bo-dot--info { background: var(--link); }
.bo-dot--muted { background: var(--muted); }

/* Progress bar */
.bo-progress {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
  display: flex;
}

/* Empty state */
.bo-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: var(--bo-font-md);
}
.bo-empty svg {
  margin-bottom: 12px;
  opacity: .4;
}
