/* ============================================================================
 * DRC HQ shell — visual chrome for sibling tools.
 * Keep in sync with drc-hq/src/styles/shell.css (+ sidebar__back for tools).
 * ========================================================================== */

:root {
  --bg: #0b0b0c;
  --fg: #e6e6e6;
  --muted: #9aa0a6;
  --card: #141416;
  --panel: #111317;
  --sidebar-bg: #0e0e10;
  --border: #26272b;
  --border-strong: #3a3b40;
  --accent: #6aa3ff;
  --header-bg: rgba(11, 11, 12, 0.9);

  --sidebar-width: 260px;
  --header-height: 56px;

  --radius-sm: 8px;
  --radius-md: 10px;

  --ease: 0.15s ease;
  --focus-ring: 0 0 0 2px rgba(106, 163, 255, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
#app {
  margin: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

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

/* -------------------------------------------------------------------------- */
/* Shell layout                                                                */
/* -------------------------------------------------------------------------- */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}

.app-stage {
  display: grid;
  grid-template-rows: var(--header-height) minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* -------------------------------------------------------------------------- */
/* Sidebar                                                                     */
/* -------------------------------------------------------------------------- */

.sidebar {
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100vh;
  padding: 18px 12px;
  border-right: 1px solid var(--border);
  background: var(--sidebar-bg);
  overflow: auto;
  z-index: 2;
}

/* Tools replace HQ’s “TOOLS” label with a back affordance. */
.sidebar__back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  margin: 0 0 14px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
  outline: none;
  transition:
    background var(--ease),
    border-color var(--ease),
    color var(--ease);
}

.sidebar__back-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: inherit;
}

.sidebar__back-arrow svg {
  display: block;
}

.sidebar__back:hover {
  color: #e8f0ff;
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.06);
}

.sidebar__back:active {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.08);
}

.sidebar__back:focus-visible {
  border-color: rgba(106, 163, 255, 0.45);
  box-shadow: var(--focus-ring);
  color: var(--fg);
}

.sidebar__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 10px 12px;
}

.app-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin: 0;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: #cbd5e1;
  background: transparent;
  outline: none;
  transition:
    background var(--ease),
    border-color var(--ease),
    box-shadow var(--ease),
    transform var(--ease),
    color var(--ease);
}

.app-nav-item:hover {
  /* Card stays dark — only the icon lights up (matches HQ tools pane). */
  transform: translateX(3px);
  color: #e8f0ff;
}

.app-nav-item:hover .app-nav-item__icon {
  border-color: rgba(106, 163, 255, 0.28);
  background: rgba(106, 163, 255, 0.08);
}

.app-nav-item:active {
  transform: translateX(1px);
}

.app-nav-item:focus-visible {
  outline: none;
}

.app-nav-item:focus-visible .app-nav-item__icon {
  border-color: rgba(106, 163, 255, 0.45);
  box-shadow: var(--focus-ring);
}

.app-nav-item__icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  transition:
    background var(--ease),
    border-color var(--ease);
}

.app-nav-item__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.app-nav-item__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.app-nav-item__title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-nav-item__subtitle {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-nav-item:hover .app-nav-item__subtitle {
  color: #a8b0ba;
}

.app-nav-item.is-active {
  color: #e8f0ff;
}

.app-nav-item.is-active .app-nav-item__icon {
  border-color: rgba(106, 163, 255, 0.28);
  background: rgba(106, 163, 255, 0.08);
}

.app-nav-item__icon svg {
  width: 20px;
  height: 20px;
  display: block;
  flex-shrink: 0;
  color: var(--muted);
}

.app-nav-item:hover .app-nav-item__icon svg,
.app-nav-item.is-active .app-nav-item__icon svg {
  color: var(--accent);
}

.sidebar__viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  overflow: auto;
  padding-right: 4px;
}

.sidebar__empty {
  margin: 8px 10px;
  color: var(--muted);
  font-size: 13px;
}

/* -------------------------------------------------------------------------- */
/* Header                                                                      */
/* -------------------------------------------------------------------------- */

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  height: var(--header-height);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  z-index: 1;
  min-width: 0;
}

.app-header__side {
  display: flex;
  align-items: center;
  min-width: 0;
}

.app-header__side--left {
  justify-content: flex-start;
}

.app-header__side--right {
  justify-content: flex-end;
  gap: 10px;
}

.app-header__center {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.app-header__center > * {
  pointer-events: auto;
}

.header-logo__link {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  outline: none;
}

.header-logo__link:focus-visible {
  box-shadow: var(--focus-ring);
}

.header-logo__img {
  height: 24px;
  width: auto;
}

/* -------------------------------------------------------------------------- */
/* Settings button                                                             */
/* -------------------------------------------------------------------------- */

.settings-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  flex-shrink: 0;
  outline: none;
  transition:
    background var(--ease),
    border-color var(--ease),
    color var(--ease);
}

.settings-btn svg {
  width: 16px;
  height: 16px;
}

.settings-btn:hover {
  color: var(--fg);
  border-color: var(--border-strong);
  background: #16181b;
}

.settings-btn:active {
  background: #1a1c20;
  border-color: var(--border-strong);
}

.settings-btn:focus-visible {
  border-color: rgba(106, 163, 255, 0.45);
  box-shadow: var(--focus-ring);
  color: var(--fg);
}

.settings-btn.is-active {
  color: var(--fg);
  border-color: rgba(106, 163, 255, 0.35);
  background: rgba(106, 163, 255, 0.12);
}

/* -------------------------------------------------------------------------- */
/* Drawer button (mobile)                                                      */
/* -------------------------------------------------------------------------- */

.drawer-btn {
  appearance: none;
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  flex-shrink: 0;
  outline: none;
  transition:
    background var(--ease),
    border-color var(--ease),
    color var(--ease);
}

.drawer-btn svg {
  width: 18px;
  height: 18px;
}

.drawer-btn:hover {
  color: var(--fg);
  border-color: var(--border-strong);
  background: #16181b;
}

.drawer-btn:active {
  background: #1a1c20;
  border-color: var(--border-strong);
}

.drawer-btn:focus-visible {
  border-color: rgba(106, 163, 255, 0.45);
  box-shadow: var(--focus-ring);
  color: var(--fg);
}

.drawer-btn.is-open {
  color: var(--fg);
  border-color: rgba(106, 163, 255, 0.35);
  background: rgba(106, 163, 255, 0.12);
}

/* -------------------------------------------------------------------------- */
/* Main content                                                                */
/* -------------------------------------------------------------------------- */

.main-content {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}

/* Demo placeholder only — tools replace this with real UI. */
.hq-shell-placeholder {
  display: grid;
  place-content: start;
  gap: 8px;
  padding: 32px 28px;
  max-width: 640px;
}

.hq-shell-placeholder h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
}

.hq-shell-placeholder p {
  margin: 0;
  color: var(--muted);
}

.hq-shell-placeholder code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #c7d2fe;
}

/* -------------------------------------------------------------------------- */
/* Motion preferences                                                          */
/* -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .app-nav-item,
  .app-nav-item__icon,
  .settings-btn,
  .drawer-btn,
  .sidebar__back {
    transition: none;
  }

  .app-nav-item:hover,
  .app-nav-item:active {
    transform: none;
  }
}

/* -------------------------------------------------------------------------- */
/* Narrow desktop                                                              */
/* -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  :root {
    --sidebar-width: 220px;
  }

  .app-header {
    padding: 0 12px;
  }

  .app-header__side--right {
    gap: 8px;
  }
}

/* -------------------------------------------------------------------------- */
/* Mobile drawer (≤768px) — matches HQ                                         */
/* -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .drawer-btn {
    display: inline-flex;
  }

  .sidebar {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    padding: 20px 16px 28px;
    border-right: none;
    z-index: 5;
  }

  .app-shell.is-drawer-open .sidebar {
    display: flex;
  }

  .app-shell.is-drawer-open .main-content {
    visibility: hidden;
    pointer-events: none;
  }

  .sidebar__back {
    margin-bottom: 18px;
    font-size: 13px;
    padding: 10px 12px;
  }

  .sidebar__nav {
    gap: 8px;
    padding-right: 0;
  }

  .app-nav-item {
    padding: 14px 14px;
    gap: 14px;
  }

  .app-nav-item:hover,
  .app-nav-item:active {
    transform: none;
  }

  .app-nav-item__icon {
    width: 48px;
    height: 48px;
  }

  .app-nav-item__icon img {
    width: 28px;
    height: 28px;
  }

  .app-nav-item__icon svg {
    width: 24px;
    height: 24px;
  }

  .app-nav-item__title {
    font-size: 16px;
  }

  .app-nav-item__subtitle {
    font-size: 13px;
  }

  .header-logo__img {
    height: 20px;
  }

  .app-header {
    padding: 0 10px;
  }

  .hq-shell-placeholder {
    padding: 24px 16px;
  }
}
