/**
 * LEIT app shell — design tokens and layout primitives for static HTML pages.
 * Load after Bootstrap and /static/css/styles.css. See docs/guides/UI_SHELL_CONVENTIONS.md.
 */

:root {
  /* Typography scale (prefer Bootstrap utilities; use tokens for custom components) */
  --leit-font-heading-weight: 600;
  --leit-page-title-size: 1.125rem; /* aligns with .h4 */

  /* Surfaces */
  --leit-header-border: var(--bs-border-color);
  --leit-header-border-width: 1px;
  --leit-section-gap: 1rem;

  /* Density — tables / toolbars */
  --leit-table-header-bg: var(--bs-secondary-bg);
  --leit-toolbar-gap: 0.5rem;

  /* Focus ring (align with Bootstrap focus-visible where possible) */
  --leit-focus-ring: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.35);

  /* Page-specific tokens promoted into the shared shell layer */
  --exec-sparkline: var(--bs-primary);
}

/* Full-page app scaffold: navbar is injected into #leit-navbar by nav.js */
.leit-app-shell {
  min-height: 100vh;
}

/* Primary content column — always pair with Bootstrap .container-fluid (or .container) + padding utilities */
main.leit-main,
.leit-main {
  /* Reserve space so footers / toasts don’t clash; pages keep their own py-* */
  min-height: calc(100vh - 3.5rem);
}

/* Page title row: optional wrapper for h1 + subtitle + actions */
.leit-page-header {
  padding-bottom: var(--leit-section-gap);
  margin-bottom: var(--leit-section-gap);
  border-bottom: var(--leit-header-border-width) solid var(--leit-header-border);
}

.leit-page-header .h1,
.leit-page-header .h4,
.leit-page-header .h5 {
  font-weight: var(--leit-font-heading-weight);
}

/* Toolbar strip (filters, period selectors, primary actions) */
.leit-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--leit-toolbar-gap);
}

.leit-toolbar > * {
  flex: 0 0 auto;
}

.leit-toolbar.compact > * {
  margin-bottom: 0;
}

.leit-page-header .leit-toolbar {
  justify-content: flex-end;
}

/* Card sections — slightly clearer separation on dense pages */
.leit-section-card.card {
  border-color: var(--bs-border-color-translucent);
}

/* Table readability */
.leit-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.table.leit-table-dense thead th {
  background-color: var(--leit-table-header-bg);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--bs-secondary-color);
}

.leit-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  align-items: center;
}

/* Toast / overlay z-index (above Bootstrap modals where needed) */
.leit-toast-container {
  z-index: 1080;
}

/* Subtle metadata badges (framework-style “meta” chip) */
.leit-badge-meta {
  font-size: 0.7em;
  font-weight: normal;
}

.leit-text-tight {
  line-height: 1.35;
}

.leit-details-summary {
  cursor: pointer;
}

/* Readable hint width for dense admin copy */
.leit-max-w-read {
  max-width: 42rem;
}

/* Chart / code blocks */
.leit-chart-host-tall {
  max-height: 20rem;
}

.leit-pre-code-scroll {
  white-space: pre-wrap;
  max-height: 14rem;
  overflow: auto;
}

.leit-scroll-max-h-340 {
  max-height: 340px;
  overflow: hidden;
}

/* Thin progress bars (Tabler-style KPI strips) */
.leit-progress-thin {
  height: 8px;
}

.leit-progress-thinner {
  height: 6px;
}

.leit-progress-md {
  height: 12px;
}

.leit-scroll-y-400 {
  max-height: 400px;
  overflow-y: auto;
}

.leit-scroll-y-360 {
  max-height: 360px;
  overflow-y: auto;
}

.leit-scroll-y-280 {
  max-height: 280px;
  overflow-y: auto;
}

.leit-scroll-y-320 {
  max-height: 320px;
  overflow-y: auto;
}

.leit-max-w-280 {
  max-width: 280px;
}

.leit-capacity-bars-max {
  max-width: 480px;
}

.leit-card-clickable {
  cursor: pointer;
}

.leit-planning-log {
  max-height: 280px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.85rem;
}

.leit-min-w-12em {
  min-width: 12em;
}

/* Hiring candidates table (planning tab): tall scroll + sticky header */
.leit-hiring-candidates-scroll {
  max-height: min(70vh, 720px);
  overflow: auto;
}

.leit-table-sticky-header table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: var(--bs-body-bg);
  box-shadow: inset 0 -1px 0 var(--bs-border-color-translucent);
}

.leit-min-h-320 {
  min-height: 320px;
}

.leit-input-max-140 {
  max-width: 140px;
}

.leit-input-w-230 {
  max-width: 230px;
  width: 100%;
}

/* Skeleton placeholder widths (avoid inline styles in static HTML) */
.leit-skeleton-w-95 {
  width: 95%;
}

.leit-skeleton-w-70 {
  width: 70%;
}

.leit-skeleton-w-80 {
  width: 80%;
}

.leit-skeleton-w-60 {
  width: 60%;
}

.leit-skeleton-w-85 {
  width: 85%;
}

.leit-skeleton-w-90 {
  width: 90%;
}

.leit-skeleton-w-75 {
  width: 75%;
}

/* Table / form helpers */
.leit-th-w-36 {
  width: 36px;
}

.leit-input-max-400 {
  max-width: 400px;
}

.leit-input-max-260 {
  max-width: 260px;
}

.leit-input-max-160 {
  max-width: 160px;
}

.leit-input-w-12em {
  width: 12em;
  max-width: 100%;
}

.leit-input-tier-narrow {
  max-width: 5.5rem;
}

.leit-input-max-10rem {
  max-width: 10rem;
}

.leit-min-w-8rem {
  min-width: 8rem;
}

.leit-min-w-10rem {
  min-width: 10rem;
}

.leit-min-h-0 {
  min-height: 0;
}

/* Full-width detail pages (list + split view) */
.leit-detail-main {
  width: 100%;
  min-height: calc(100vh - 3.5rem);
}

.leit-min-h-60vh {
  min-height: 60vh;
}

.leit-detail-research-pane {
  min-height: 50vh;
  overflow-y: auto;
}

.leit-overflow-visible {
  overflow: visible;
}

/* Scrollable research panes (prospect / company detail) */
.leit-research-scroll {
  max-height: 60vh;
  min-height: 280px;
  overflow-y: auto;
}

.leit-scroll-y-220 {
  max-height: 220px;
  overflow-y: auto;
}

.leit-scroll-y-120 {
  max-height: 120px;
  overflow-y: auto;
}

.leit-suggestions-popover {
  z-index: 1050;
}

.leit-badge-tiny {
  font-size: 0.65rem;
}

.leit-text-tracked {
  letter-spacing: 0.03em;
}

.leit-pre-wrap-block {
  white-space: pre-wrap;
}

/* Optional filter strip inside a card (reference: Tabler filter bar) */
.leit-filter-bar {
  background-color: var(--bs-secondary-bg);
  border: 1px solid var(--bs-border-color-translucent);
  border-radius: var(--bs-border-radius);
  padding: 0.5rem 0.75rem;
  margin-bottom: var(--leit-section-gap);
}

/* Stat / summary cards on dashboard-style pages */
.card.leit-stat-surface {
  border-color: var(--bs-border-color-translucent);
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.04);
}

/* Exec dashboard primitives */
.exec-kpi-card {
  min-height: 100px;
}

.exec-kpi-sparkline {
  color: var(--exec-sparkline);
  height: 20px;
  width: 100%;
}

.exec-sparkline-svg polyline {
  stroke: var(--exec-sparkline);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.exec-drill,
.exec-ph-row,
.exec-rev-cell {
  cursor: pointer;
}

.exec-drill:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

.exec-overview-compact .exec-kpi-card {
  min-height: auto;
}

.exec-overview-compact .exec-kpi-card .card-body {
  padding-top: 0.35rem !important;
  padding-bottom: 0.35rem !important;
}

.exec-overview-compact .exec-kpi-card .h5 {
  font-size: 1rem;
}

.exec-table-numeric {
  text-align: right;
}

/* Deals / AI prompt helpers */
.td-describe-change {
  min-width: 320px;
  width: 28%;
  vertical-align: middle !important;
}

.describe-prompt {
  width: 100%;
  min-height: 4.5em;
  resize: vertical;
  font-size: 1rem;
}

.describe-change-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--bs-primary);
  margin-bottom: 0.25rem;
}

.prompt-key-info {
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
  margin-bottom: 0.35rem;
}

.prompt-key-info strong {
  color: var(--bs-primary);
  font-weight: 600;
}

/* Deals page: scroll panels and fixed-width controls (replaces inline styles) */
.leit-scroll-y-200 {
  max-height: 200px;
  overflow-y: auto;
}

.leit-scroll-y-260 {
  max-height: 260px;
  overflow-y: auto;
}

.leit-scroll-auto-260 {
  max-height: 260px;
  overflow: auto;
}

.leit-select-w-sm {
  max-width: 14rem;
}

.leit-select-w-md {
  max-width: 220px;
}

.leit-select-w-lg {
  max-width: 28rem;
}

.leit-th-w-40 {
  width: 40px;
}

.leit-th-w-42 {
  width: 42px;
}

.leit-th-w-80 {
  width: 80px;
}

.leit-th-w-90 {
  width: 90px;
}

.leit-th-w-100 {
  width: 100px;
}

.leit-th-w-120 {
  width: 120px;
}

/* Auth/setup pages: footer link on gradient background */
.leit-auth-footer-link {
  color: rgba(232, 237, 242, 0.8);
}

.leit-th-w-160 {
  width: 160px;
}

.leit-th-w-200 {
  width: 200px;
}

/* Allocations project picker dropdown */
.leit-dropdown-scroll {
  z-index: 1050;
  max-height: 260px;
  overflow-y: auto;
  width: calc(100% - 24px);
}

/* Empty / placeholder state */
.leit-empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--bs-secondary-color);
}

.leit-empty-state .leit-empty-title {
  font-weight: var(--leit-font-heading-weight);
  color: var(--bs-body-color);
  margin-bottom: 0.35rem;
}

/* --- Hiring candidates: sortable headers --- */
.hc-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.hc-sortable::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 4px;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 4px solid var(--bs-secondary-color);
  opacity: 0.25;
  transition: opacity 0.15s, transform 0.15s;
}
.hc-sortable.hc-sort-active::after {
  opacity: 0.85;
}
.hc-sortable.hc-sort-desc::after {
  border-bottom: none;
  border-top: 4px solid var(--bs-primary);
}
.hc-sortable.hc-sort-asc::after {
  border-bottom: 4px solid var(--bs-primary);
  border-top: none;
}
.hc-sortable:hover::after {
  opacity: 0.6;
}

/* --- Hiring candidates: skeleton shimmer --- */
@keyframes hc-shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}
.hc-skeleton-cell {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bs-secondary-bg) 25%, var(--bs-tertiary-bg, #e9ecef) 50%, var(--bs-secondary-bg) 75%);
  background-size: 400px 100%;
  animation: hc-shimmer 1.2s ease-in-out infinite;
}

/* --- Hiring candidates: active filter pills --- */
#hiring-active-filters .badge {
  font-weight: 500;
  font-size: 0.78rem;
}
#hiring-active-filters .badge .btn-close {
  font-size: 0.55rem;
  margin-left: 0.35rem;
  vertical-align: middle;
  filter: invert(1);
  opacity: 0.7;
}
#hiring-active-filters .badge .btn-close:hover {
  opacity: 1;
}

/* --- Hiring candidates: row detail expand --- */
.hc-detail-row td {
  background-color: var(--bs-tertiary-bg, #f8f9fa);
  border-top: none;
  padding: 0.5rem 0.75rem;
}
.hc-detail-row .hc-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}
.hc-detail-row .hc-detail-item label {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.hc-detail-row .hc-detail-item .hc-detail-val {
  font-size: 0.85rem;
}

/* --- Hiring candidates: empty state --- */
.hc-empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
}
.hc-empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 0.75rem;
  opacity: 0.4;
}

/* --- Hiring candidates: responsive card view --- */
@media (max-width: 767.98px) {
  .hiring-candidates-wrap table.leit-table-dense {
    display: none;
  }
  .hc-card-list {
    display: flex !important;
    flex-direction: column;
    gap: 0.5rem;
  }
  .hc-card-list .hc-card {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: 0.75rem;
    background: var(--bs-body-bg);
  }
  .hc-card-list .hc-card-name {
    font-weight: 600;
  }
  .hc-card-list .hc-card-field {
    font-size: 0.82rem;
  }
  .hc-card-list .hc-card-field label {
    font-weight: 600;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-right: 0.25rem;
  }
}
@media (min-width: 768px) {
  .hc-card-list {
    display: none !important;
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

@media print {
  .no-print {
    display: none !important;
  }

  .tab-pane {
    display: block !important;
  }

  body {
    background: #fff !important;
  }

  .exec-kpi-card {
    break-inside: avoid;
  }
}
