/*
 * Truck Route Planner - desktop layout.
 * Fixed control sidebar on the left, tabbed workspace on the right.
 *
 * created by Gabor Gasko
 */

html, body { height: 100%; overflow: hidden; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 0;
}

/* -------------------------------------------------------------- sidebar */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Sections are separated by hairlines, not nested boxes. */
.sidebar__section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.sidebar__section > h3 {
  font-size: 13.5px; font-weight: 600; color: var(--brand-700);
  margin-bottom: 14px; display: flex; align-items: center; gap: 7px;
}
[data-theme="dark"] .sidebar__section > h3,
[data-theme="dark"] .sidebar details.sidebar__section > summary { color: var(--accent); }

.sidebar details.sidebar__section > summary {
  cursor: pointer; list-style: none;
  font-size: 13.5px; font-weight: 600; color: var(--brand-700);
  display: flex; align-items: center; justify-content: space-between;
  margin: -4px 0; padding: 4px 0;
}
.sidebar details.sidebar__section > summary::-webkit-details-marker { display: none; }
.sidebar details.sidebar__section > summary::after {
  content: ""; width: 7px; height: 7px; flex: none; margin-right: 4px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg); transition: transform .15s;
}
.sidebar details.sidebar__section[open] > summary::after { transform: rotate(-135deg); }
.sidebar details.sidebar__section[open] > summary { margin-bottom: 10px; }

.sidebar > .note { margin: 0; padding: 14px 20px; border-left: 0; }

.swap-row { display: flex; justify-content: center; margin: -6px 0 8px; }
.swap-btn {
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); border-radius: 999px;
  width: 30px; height: 30px; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: var(--shadow-xs);
  transition: color .15s, border-color .15s, background .15s;
}
.swap-btn svg { width: 14px; height: 14px; }
.swap-btn:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

/* ------------------------------------------------------------ workspace */

.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  flex: none;
}
.tab {
  border: 0; background: none; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--muted);
  padding: 14px 10px 12px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  transition: color .15s;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab__count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--surface-3); border-radius: 999px;
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.tab[aria-selected="true"] .tab__count { background: var(--accent-soft); color: var(--accent); }

.panels { flex: 1; min-height: 0; position: relative; }
.panel {
  position: absolute; inset: 0;
  overflow-y: auto;
  padding: 20px;
}
.panel[hidden] { display: none; }
.panel--map { padding: 0; }
.panel--map .map-shell { border-radius: 0; }
.panel--map .map-canvas { border-radius: 0; }

.panel-actions {
  display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.panel-actions .btn { width: auto; height: 36px; padding: 0 14px; font-size: 13px; }

.map-floating-actions {
  position: absolute; z-index: 500; bottom: 16px; left: 16px;
  display: flex; gap: 8px;
}
.map-floating-actions .btn { width: auto; height: 36px; padding: 0 14px; font-size: 13px; box-shadow: var(--shadow-lg); }

/* --------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .layout { grid-template-columns: 320px 1fr; }
}

@media (max-width: 900px) {
  html, body { overflow: auto; }
  .app { height: auto; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .panels { position: static; min-height: 60vh; }
  .panel { position: static; }
  .panel[hidden] { display: none; }
  .panel--map { height: 70vh; }
}

/* ------------------------------------------------------ header priority */

/*
 * The header carries a lot: brand, version, data source, the author link,
 * language, theme and two page links. Below full width the low-value
 * chrome drops out first so the author credit and the controls stay whole
 * instead of everything wrapping into each other.
 */
@media (max-width: 1280px) {
  .app-header .chip { display: none; }
}
@media (max-width: 1040px) {
  .brand__tagline { display: none; }
}
@media (max-width: 900px) {
  /* Below the two-column layout the bar grows to two rows rather than
     dropping the guide and mobile links or squeezing the product name. */
  .app-header { height: auto; min-height: var(--header-h); flex-wrap: wrap; padding: 8px 14px; row-gap: 8px; }
  .brand { flex: 1 1 100%; }
  .header-meta { margin-left: 0; flex-wrap: wrap; }
}
