/*
 * Scoped subset of dsb.css for the new sidebar on _Layout.cshtml.
 *
 * _Layout.cshtml still hosts legacy Bootstrap .btn/.nav-tabs content in the main body,
 * so the full dsb.css (which resets *, html, body and overrides .btn-primary etc.) cannot
 * be loaded globally here. This file ships ONLY:
 *   - design tokens (:root)
 *   - .app / .main grid layout
 *   - sidebar component rules (.sidebar*, .nav-item*, .dealer-*, .status-dot, .brand-logo)
 *
 * Rules are copied verbatim from dsb.css; keep them in sync. Once _Layout.cshtml is
 * migrated to _LayoutSb.cshtml (which loads the full dsb.css), this file can be removed.
 */

/* ===== Tokens ===== */
:root {
  --bg: oklch(0.985 0.005 90);
  --bg-2: oklch(0.97 0.006 90);
  --surface: #ffffff;
  --ink: oklch(0.22 0.02 250);
  --ink-2: oklch(0.42 0.02 250);
  --ink-3: oklch(0.6 0.015 250);
  --muted: oklch(0.7 0.012 250);
  --line: oklch(0.92 0.006 250);
  --line-2: oklch(0.88 0.008 250);

  /* Accent — brand green from the DSB logo (#60C030 / rgb(96, 192, 48)) */
  --accent: oklch(0.74 0.2 135);
  --accent-ink: oklch(0.42 0.16 135);
  --accent-soft: oklch(0.96 0.06 135);
  --accent-pulse-mid: oklch(0.74 0.2 135 / 0.18);
  --accent-pulse-out: oklch(0.74 0.2 135 / 0.08);

  /* Row tones — preserved semantics */
  --row-yellow-fill: oklch(0.96 0.085 95);
  --row-yellow-tint: oklch(0.985 0.045 95);
  --row-yellow-edge: oklch(0.84 0.16 95);

  --row-green-fill: oklch(0.93 0.09 155);
  --row-green-tint: oklch(0.975 0.045 155);
  --row-green-edge: oklch(0.7 0.17 155);

  /* Sidebar — dark */
  --side-bg: #0F1623;
  --side-bg-2: #161E2E;
  --side-ink: oklch(0.94 0.01 240);
  --side-ink-2: oklch(0.72 0.02 240);
  --side-line: oklch(0.28 0.015 240);

  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 6px;

  --shadow-sm: 0 1px 0 oklch(0.92 0.01 250 / 0.8);
  --shadow-card: 0 1px 2px rgb(15 22 35 / 0.04), 0 8px 24px -16px rgb(15 22 35 / 0.08);

  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", monospace;
}

[data-theme="dark"] {
  --bg: #0B1019;
  --bg-2: #0F1623;
  --surface: #131B2A;
  --ink: oklch(0.96 0.01 240);
  --ink-2: oklch(0.82 0.015 240);
  --ink-3: oklch(0.68 0.018 240);
  --muted: oklch(0.55 0.02 240);
  --line: oklch(0.26 0.012 240);
  --line-2: oklch(0.32 0.014 240);
  --accent-soft: oklch(0.32 0.07 135);
  --row-yellow-fill: oklch(0.36 0.09 95);
  --row-yellow-tint: oklch(0.22 0.05 95);
  --row-green-fill: oklch(0.36 0.1 155);
  --row-green-tint: oklch(0.22 0.05 155);
  --shadow-card: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px -12px rgb(0 0 0 / 0.5);
}

/* ===== Layout ===== */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

/* Mobile nav chrome — hidden on desktop, shown at <=900px via the media query below. */
.mobile-topbar { display: none; }
.sidebar-overlay { display: none; }
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--side-ink);
  cursor: pointer;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  background: var(--bg);
}

/* Sticky footer: margin-top:auto pushes it to the bottom of the flex column,
   so it sits at the viewport bottom when content is short and after content otherwise. */
.main > .footer-content {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 12px;
}
.main > .footer-content p { margin: 0; }

/* ===== Sidebar ===== */
.sidebar {
  background: var(--side-bg);
  color: var(--side-ink);
  padding: 22px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid oklch(0 0 0 / 0.4);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 8px 0;
}
.brand-logo {
  width: 100%;
  height: auto;
  max-width: 180px;
  display: block;
}
.sidebar--light .sidebar__brand {
  background: var(--side-bg);
  padding: 10px 12px;
  border-radius: var(--r-md);
}

.sidebar__dealer {
  background: var(--side-bg-2);
  border: 1px solid var(--side-line);
  border-radius: var(--r-md);
  padding: 12px;
}
.dealer-eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--side-ink-2);
  margin-bottom: 4px;
}
.dealer-name { font-weight: 600; font-size: 13.5px; }
.dealer-meta {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--side-ink-2);
  font-family: var(--font-mono);
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  box-shadow: 0 0 0 3px var(--accent-pulse-mid);
}
.status-dot--live { animation: pulse 2s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent-pulse-mid); }
  50%      { box-shadow: 0 0 0 6px var(--accent-pulse-out); }
}

.sidebar__nav {
  display: flex; flex-direction: column; gap: 2px;
  flex: 1;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  border-radius: 8px;
  color: var(--side-ink-2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 120ms, background 120ms;
}
.nav-item:hover { color: var(--side-ink); background: oklch(1 0 0 / 0.04); }
.nav-item--active {
  color: #0F1623;
  background: var(--accent);
}
.nav-item--active:hover { background: var(--accent); color: #0F1623; }
.nav-item--muted { color: var(--side-ink-2); }

.sidebar__foot { border-top: 1px solid var(--side-line); padding-top: 8px; }

.sidebar--light {
  background: var(--surface);
  color: var(--ink);
  border-right: 1px solid var(--line);
  --side-bg-2: var(--bg-2);
  --side-ink: var(--ink);
  --side-ink-2: var(--ink-3);
  --side-line: var(--line);
}
.sidebar--light .nav-item--active { color: var(--accent-ink); background: var(--accent-soft); }

/* Location switcher combobox inside the sidebar — themed to the dark sidebar. */
.sidebar__locswitch {
  margin-top: -12px;
}
.sidebar__locswitch .combobox-container { width: 100% !important; }
.sidebar__locswitch .combobox-container .input-group { width: 100%; display: table; }

/* Text input */
.sidebar__locswitch .combobox-container input.combobox,
.sidebar__locswitch .combobox-container input.form-control {
  width: 100% !important;
  height: 38px;
  padding: 0 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--side-ink);
  background: var(--side-bg-2);
  border: 1px solid var(--side-line);
  border-radius: var(--r-md);
  box-shadow: none;
  outline: none;
}
.sidebar__locswitch .combobox-container .input-group input.combobox,
.sidebar__locswitch .combobox-container .input-group input.form-control {
  border-radius: var(--r-md) 0 0 var(--r-md);
}
.sidebar__locswitch .combobox-container input.combobox:focus,
.sidebar__locswitch .combobox-container input.form-control:focus {
  border-color: var(--accent);
}
.sidebar__locswitch .combobox-container input::-webkit-input-placeholder { color: var(--side-ink-2); }
.sidebar__locswitch .combobox-container input::-moz-placeholder { color: var(--side-ink-2); opacity: 1; }
.sidebar__locswitch .combobox-container input:-ms-input-placeholder { color: var(--side-ink-2); }
.sidebar__locswitch .combobox-container input::placeholder { color: var(--side-ink-2); }

/* Caret / clear add-on button */
.sidebar__locswitch .combobox-container .input-group-addon,
.sidebar__locswitch .combobox-container .add-on {
  width: 36px;
  padding: 0;
  text-align: center;
  vertical-align: middle;
  background: var(--side-bg-2);
  border: 1px solid var(--side-line);
  border-left: 0;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  color: var(--side-ink-2);
  cursor: pointer;
}
.sidebar__locswitch .combobox-container .caret { border-top-color: var(--side-ink-2); }
.sidebar__locswitch .combobox-container .glyphicon-remove { color: var(--side-ink-2); }

/* Dropdown list */
.sidebar__locswitch .dropdown-menu {
  width: 100%;
  margin-top: 4px;
  padding: 4px;
  background: var(--side-bg-2);
  border: 1px solid var(--side-line);
  border-radius: var(--r-md);
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.55);
}
.sidebar__locswitch .dropdown-menu > li > a {
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--side-ink);
  white-space: normal;
}
.sidebar__locswitch .dropdown-menu > li > a:hover,
.sidebar__locswitch .dropdown-menu > li > a:focus,
.sidebar__locswitch .dropdown-menu > li.active > a {
  background: oklch(1 0 0 / 0.06);
  color: var(--side-ink);
}

/* Cursor affordance for switchable dealer card */
.sidebar__dealer--switchable {
  cursor: pointer;
}
.sidebar__dealer--switchable:hover {
  border-color: oklch(0.38 0.015 240);
}

/* ===== Mobile: sidebar becomes an off-canvas drawer behind a hamburger ===== */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }

  /* Fixed top bar with the hamburger + logo */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    padding: 0 12px;
    background: var(--side-bg);
    border-bottom: 1px solid oklch(0 0 0 / 0.4);
    z-index: 1030; /* above content, below Bootstrap modal backdrop (1040) */
  }
  .mobile-topbar__logo { height: 26px; width: auto; display: block; }

  /* Push page content below the fixed top bar */
  .main { padding-top: 52px; }

  /* Sidebar slides in from the left */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 248px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1100;
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: 0 0 40px -8px rgba(0, 0, 0, 0.6); }

  /* Dim backdrop while the drawer is open */
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 1090;
  }
  .sidebar-overlay.is-open { opacity: 1; visibility: visible; }
}
