/* =============================================================================
   THEME.CSS — Platform Sidebar Navigation Layer (Phase 2: Navigation Polish)
   Loaded AFTER style.css. Adds a persistent left-hand platform navigation
   sidebar without modifying style.css, app.js, or jobs-ui.js.

   The existing horizontal tab bar (.tab-bar / .tab-btn inside
   .tab-panel-container) remains fully visible and functional — its
   markup, IDs, data-tab attributes, and app.js's existing click listener
   are untouched. The sidebar represents the three primary platform
   workspaces (Dashboard / Inspections / Jobs); the horizontal tabs remain
   the tools within the Inspections workspace. All sidebar links drive the
   existing tab buttons via their own .click() method (see sidebar-nav.js)
   rather than an independent activation path.
   ============================================================================= */

:root {
  --app-sidebar: #111827;
  --app-sidebar-border: rgba(255, 255, 255, 0.1);
  --app-accent: #F97316;
  --app-background: #F8FAFC;
  --app-card: #FFFFFF;
}

/* ── Shell layout ─────────────────────────────────────────────────────────── */

.app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
  background: var(--app-background);
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */

.app-sidebar {
  flex: 0 0 auto;
  width: 232px;
  background: var(--app-sidebar);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: 20px 0 16px;
}

.app-sidebar-divider {
  border-top: 1px solid var(--app-sidebar-border);
  margin: 16px 16px;
}

/* ── Brand area ───────────────────────────────────────────────────────────────
   Enlarged, centered, and given generous breathing room so the brand feels
   like the top of a finished product rather than a cramped label. Logo and
   text-fallback share the same centered layout; only sizing/spacing changed
   here — the underlying markup/IDs are unchanged. ───────────────────────── */

.app-sidebar-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 18px 22px;
  text-align: center;
}

.app-sidebar-logo {
  max-height: 84px;
  max-width: 100%;
  object-fit: contain;
}

.app-sidebar-brand-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.3;
}

.app-sidebar-brand-primary {
  font-family: Arial, sans-serif;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #ffffff;
}

.app-sidebar-brand-secondary {
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #9ca3af;
  margin-top: 2px;
}

/* ── Platform navigation ──────────────────────────────────────────────────── */

.app-platform-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 12px;
}

.app-platform-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: #d1d5db;
  border: none;
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.app-platform-nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.app-platform-nav-link .app-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #ffffff;
}

.app-platform-nav-link .app-nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-platform-nav-link.active {
  background: var(--app-accent);
  color: #ffffff;
  font-weight: 700;
}

.app-platform-nav-link.active .app-nav-icon {
  color: #ffffff;
}

/* Dashboard has no workspace of its own yet in this phase — it forwards to
   Inspections but is never itself marked active (see sidebar-nav.js). */
.app-platform-nav-link[data-platform-section="dashboard"] {
  color: #9ca3af;
}

.app-platform-nav-link[data-platform-section="dashboard"] .app-nav-icon {
  color: #9ca3af;
}

.app-platform-nav-link[data-platform-section="dashboard"]:hover {
  color: #ffffff;
}

.app-platform-nav-link[data-platform-section="dashboard"]:hover .app-nav-icon {
  color: #ffffff;
}

.app-sidebar-spacer {
  flex: 1 1 auto;
}

/* ── Inspector profile area (anchored to the bottom) ──────────────────────── */

.app-sidebar-account {
  position: relative;
  padding: 6px 12px 2px;
}

/* Compact inspector card — avatar, name, and role stacked and centered,
   with the expand chevron below as a quiet affordance. Purely a CSS
   reflow of the existing markup (avatar → text → chevron, in DOM order);
   no elements were added, removed, or renamed. */
.app-sidebar-account-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 14px 8px 16px;
  cursor: pointer;
  color: #e5e7eb;
  font-family: inherit;
  text-align: center;
  transition: background-color 0.12s ease;
}

.app-sidebar-account-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}

.app-sidebar-account-initial {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--app-accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-sidebar-account-text {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.35;
}

.app-sidebar-account-name {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-sidebar-account-role {
  font-size: 11.5px;
  color: #9ca3af;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-sidebar-account-chevron {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
}

.app-sidebar-account-toggle[aria-expanded="true"] .app-sidebar-account-chevron {
  color: #ffffff;
}

.app-sidebar-account-menu {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% + 6px);
  background: #1f2937;
  border: 1px solid var(--app-sidebar-border);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.app-sidebar-account-menu[hidden] {
  display: none;
}

.app-sidebar-account-menu-email {
  font-size: 11.5px;
  color: #9ca3af;
  padding: 6px 10px 8px;
  border-bottom: 1px solid var(--app-sidebar-border);
  margin-bottom: 4px;
  word-break: break-all;
}

.app-sidebar-account-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: #e5e7eb;
  cursor: pointer;
}

.app-sidebar-account-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* ── Selected inspection card — orange accent, scoped to this one state ──── */

.inspections-panel .item.active {
  border-color: var(--app-accent);
  background: #fff7ed;
}

/* ── Card surfaces reuse the approved card color ─────────────────────────── */

.app-shell .panel {
  background: var(--app-card);
}

/* ── Responsive: basic tablet breakpoint ─────────────────────────────────── */

@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
    min-height: 0;
  }

  .app-sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 0;
  }

  .app-sidebar-header {
    flex-direction: row;
    flex-shrink: 0;
    gap: 8px;
    padding: 0 14px;
  }

  .app-sidebar-logo {
    max-height: 32px;
  }

  .app-sidebar-brand-fallback {
    align-items: flex-start;
    text-align: left;
  }

  .app-sidebar-brand-primary {
    font-size: 16px;
  }

  .app-sidebar-brand-secondary {
    font-size: 11px;
    margin-top: 0;
  }

  .app-sidebar-divider {
    display: none;
  }

  .app-platform-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 6px 10px;
  }

  .app-platform-nav-link {
    width: auto;
  }

  .app-sidebar-spacer {
    flex: 0 0 auto;
    width: 100%;
    height: 0;
  }

  .app-sidebar-account {
    flex-shrink: 0;
    padding: 6px 14px;
  }

  .app-sidebar-account-toggle {
    flex-direction: row;
    text-align: left;
    padding: 6px 4px;
  }

  .app-sidebar-account-text {
    align-items: flex-start;
  }

  .app-sidebar-account-initial {
    width: 30px;
    height: 30px;
    font-size: 13px;
  }

  .app-sidebar-account-menu {
    left: auto;
    right: 14px;
    bottom: auto;
    top: calc(100% + 6px);
    width: 220px;
  }
}
