/* Lighthouse / TAO-style SaaS shell — theme-driven surfaces and accent */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ========================================= */
/* SECTION: Layout Tokens (non-color) */
/* ========================================= */
/* CHANGE: Color tokens moved to theme-tokens.css; layout metrics remain here */
/* BEFORE: :root mixed --lh-primary hex colors with layout variables */
/* AFTER: Only structural tokens; colors use --theme-* from data-theme */
/* WHY: Global theme switch must not duplicate palette definitions */

:root {
  --lh-sidebar-width: 268px;
  --lh-sidebar-collapsed: 76px;
  --lh-topbar-height: 60px;
  --lh-radius: 12px;
  --lh-radius-sm: 10px;
  --lh-space: 1.5rem;
  --lh-space-lg: 2rem;
  --lh-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --lh-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --lh-duration: 0.28s;
}

html {
  scroll-behavior: smooth;
}

body.lh-app {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  margin-bottom: 0;
  background: var(--theme-background);
  color: var(--theme-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ----- App shell ----- */
.lh-app-shell {
  display: flex;
  min-height: 100vh;
}

.lh-sidebar {
  width: var(--lh-sidebar-width);
  flex-shrink: 0;
  background: var(--theme-surface);
  border-right: 1px solid var(--theme-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 1020;
  transition: width var(--lh-duration) var(--lh-ease-out), border-color var(--lh-duration) ease;
}

.lh-sidebar--collapsed {
  width: var(--lh-sidebar-collapsed);
}

.lh-sidebar--collapsed .lh-sidebar-brand-text,
.lh-sidebar--collapsed .lh-nav-label,
.lh-sidebar--collapsed .lh-nav-chevron,
.lh-sidebar--collapsed .lh-collapse-toggle {
  display: none !important;
}

.lh-sidebar--collapsed .lh-sidebar-brand {
  justify-content: center;
}

.lh-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.125rem;
  border-bottom: 1px solid var(--theme-border-muted);
  text-decoration: none;
  color: inherit;
  transition: background var(--lh-duration) ease, border-color var(--lh-duration) ease;
}

.lh-sidebar-brand:hover {
  background: var(--theme-surface-hover);
}

.lh-sidebar-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--theme-accent), var(--theme-accent-hover));
  color: var(--theme-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  box-shadow: 0 4px 14px var(--theme-accent-shadow);
  transition: transform var(--lh-duration) var(--lh-ease-spring), box-shadow var(--lh-duration) ease;
}

.lh-sidebar-brand:hover .lh-sidebar-logo {
  transform: scale(1.03);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--theme-accent) 40%, transparent);
}

.lh-sidebar-brand-text {
  font-weight: 600;
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--theme-text);
}

[data-bs-theme="dark"] .lh-sidebar-brand-text {
  color: var(--theme-text);
}

.lh-sidebar-brand-sub {
  font-size: 0.7rem;
  color: var(--theme-text-muted);
  font-weight: 400;
}

.lh-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
}

/* ========================================= */
/* SECTION: Company Context Sidebar */
/* ========================================= */
/* CHANGE: Label for active company name in company-scoped left nav */
/* BEFORE: No company workspace label in sidebar */
/* AFTER: .lh-sidebar-company-label truncates long company names above nav links */
/* WHY: Users need context when the global nav is replaced by company navigation */
.lh-sidebar-company-label {
  letter-spacing: 0.04em;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========================================= */
/* SECTION: Sidebar Dynamic Company List */
/* ========================================= */
/* CHANGE: Added styles for scrollable sidebar company navigation */
/* BEFORE: Sidebar had only single-link menu items with no company list panel */
/* AFTER: Companies section has header, add button, and independently scrollable list */
/* WHY: Long company lists must scroll without displacing other sidebar sections */
/* ========================================= */
/* SECTION: Companies Left Nav Item */
/* ========================================= */
/* CHANGE: Nest company list panel inside Companies nav collapse */
/* BEFORE: Company panel was a standalone sidebar block */
/* AFTER: #navCompanies .lh-sidebar-companies has no extra outer border */
/* WHY: Companies is now a top-level nav item with the list in its submenu */
#navCompanies .lh-sidebar-companies {
  border: none;
  background: transparent;
  padding: 0.15rem 0 0;
}

.lh-sidebar-companies {
  border: 1px solid var(--theme-border);
  border-radius: var(--lh-radius-sm);
  background: var(--theme-surface-hover);
  padding: 0.5rem;
}

[data-bs-theme="dark"] .lh-sidebar-companies {
  border-color: var(--theme-border);
  background: var(--theme-surface-muted);
}

.lh-sidebar-companies-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0.35rem 0.5rem;
}

.lh-sidebar-companies-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--theme-text-muted);
}

.lh-sidebar-add-company {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  line-height: 1.2;
  white-space: nowrap;
}

.lh-sidebar-company-list {
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.lh-sidebar-company-link {
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
  margin-bottom: 0.15rem;
}

.lh-sidebar-company-link .lh-nav-label {
  min-width: 0;
}

.lh-sidebar-company-empty {
  border-radius: var(--lh-radius-sm);
  background: rgba(0, 0, 0, 0.03);
}

[data-bs-theme="dark"] .lh-sidebar-company-empty {
  background: rgba(255, 255, 255, 0.04);
}

.lh-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--lh-radius-sm);
  color: var(--theme-text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition:
    background var(--lh-duration) var(--lh-ease-out),
    color var(--lh-duration) ease,
    transform var(--lh-duration) var(--lh-ease-out),
    box-shadow var(--lh-duration) ease;
}

[data-bs-theme="dark"] .lh-nav-link {
  color: var(--theme-text-subtle);
}

.lh-nav-link:hover {
  background: var(--theme-surface-hover);
  color: var(--lh-primary);
  transform: translateX(2px);
}

[data-bs-theme="dark"] .lh-nav-link:hover {
  background: var(--theme-surface-muted);
}

.lh-nav-link.active {
  background: var(--lh-primary-soft);
  color: var(--lh-primary);
  box-shadow: inset 3px 0 0 var(--lh-primary);
}

.lh-nav-link i {
  font-size: 1.1rem;
  opacity: 0.9;
}

.lh-nav-chevron {
  margin-left: auto;
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.lh-nav-link[aria-expanded="true"] .lh-nav-chevron {
  transform: rotate(180deg);
}

.lh-nav-sub {
  padding-left: 0.25rem;
    margin-top: 0.25rem;
}

.lh-nav-sub .lh-nav-link {
  padding-left: 2rem;
  font-size: 0.8125rem;
}

.lh-sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--theme-surface-muted);
}

[data-bs-theme="dark"] .lh-sidebar-footer {
  border-top-color: var(--theme-surface-muted);
}

.lh-main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.lh-topbar {
  height: var(--lh-topbar-height);
  border-bottom: 1px solid var(--theme-border);
  background: color-mix(in srgb, var(--theme-surface) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  padding: 0 1.25rem 0 1rem;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 1010;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

[data-bs-theme="dark"] .lh-topbar {
  background: color-mix(in srgb, var(--theme-surface) 90%, transparent);
  border-bottom-color: var(--theme-surface-muted);
}

.lh-topbar-search {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
}

.lh-topbar-search .form-control {
  border-radius: 999px;
  background: var(--theme-surface-muted);
  border: none;
  padding: 0.45rem 1rem 0.45rem 2.25rem;
  font-size: 0.875rem;
}

[data-bs-theme="dark"] .lh-topbar-search .form-control {
  background: var(--theme-surface-muted);
  color: var(--theme-border);
}

.lh-topbar-search-wrap {
  position: relative;
}

.lh-topbar-search-wrap i {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--theme-text-subtle);
  font-size: 0.95rem;
}

.lh-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.lh-icon-btn {
  transition:
    transform var(--lh-duration) var(--lh-ease-out),
    background var(--lh-duration) ease,
    border-color var(--lh-duration) ease,
    box-shadow var(--lh-duration) ease !important;
}

.lh-icon-btn:hover {
  transform: scale(1.04);
}

.lh-icon-btn:active {
  transform: scale(0.98);
}

.lh-avatar-btn {
  border-radius: 50%;
  transition: transform var(--lh-duration) var(--lh-ease-out);
}

.lh-avatar-btn:hover {
  transform: scale(1.06);
}

.lh-avatar-btn:focus-visible {
  outline: 2px solid var(--lh-primary);
  outline-offset: 3px;
}

.lh-avatar-circle {
  width: 36px;
  height: 36px;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px var(--theme-accent-shadow);
  transition: box-shadow var(--lh-duration) ease;
}

.lh-avatar-btn:hover .lh-avatar-circle {
  box-shadow: 0 4px 14px color-mix(in srgb, var(--theme-accent) 45%, transparent);
}

/* Dropdown menus */
.lh-topbar .dropdown-menu {
  border-radius: var(--lh-radius-sm);
  padding: 0.35rem;
  animation: lhDropdownIn 0.22s var(--lh-ease-out);
}

@keyframes lhDropdownIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.lh-topbar .dropdown-item {
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  transition: background var(--lh-duration) ease;
}

.lh-btn-pill {
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

.lh-clock {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--theme-text-muted);
  min-width: 4.5rem;
}

.lh-content {
  flex: 1;
  padding: var(--lh-space-lg) var(--lh-space);
  background: var(--lh-bg-page);
}

/* Main area entrance (full page loads only) */
.lh-motion .lh-content-reveal {
  animation: lhContentReveal 0.5s var(--lh-ease-out) both;
}

@keyframes lhContentReveal {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.lh-footer {
  padding: 1rem 1.5rem;
  margin-top: auto;
  background: var(--lh-bg-page) !important;
  border-color: var(--theme-border) !important;
  display: flex;
  align-items: center;
}

[data-bs-theme="dark"] .lh-footer {
  background: var(--theme-background) !important;
  border-color: var(--theme-surface-muted) !important;
  color: var(--theme-text-subtle) !important;
}

/* Alerts near topbar */
.lh-main-wrap > .px-3.pt-3 .alert {
  border: none;
  border-radius: var(--lh-radius-sm);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  animation: lhAlertIn 0.4s var(--lh-ease-out) both;
}

@keyframes lhAlertIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Page header (title + subtitle + actions) */
.lh-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: var(--lh-space-lg);
}

.lh-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--theme-text);
  margin: 0;
  letter-spacing: -0.02em;
}

[data-bs-theme="dark"] .lh-page-title {
  color: var(--theme-text);
}

.lh-page-subtitle {
  font-size: 0.875rem;
  color: var(--theme-text-muted);
  margin: 0.25rem 0 0;
}

/* Cards & list rows */
.lh-card {
  background: var(--theme-surface);
  border: 1px solid var(--theme-border);
  border-radius: var(--lh-radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition:
    box-shadow var(--lh-duration) ease,
    border-color var(--lh-duration) ease,
    transform var(--lh-duration) var(--lh-ease-out);
}

.lh-card:hover {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

[data-bs-theme="dark"] .lh-card:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

[data-bs-theme="dark"] .lh-card {
  background: var(--theme-surface);
  border-color: var(--theme-border);
}

.lh-list {
  border-radius: var(--lh-radius);
  overflow: hidden;
  border: 1px solid var(--theme-border);
  background: var(--theme-surface);
}

[data-bs-theme="dark"] .lh-list {
  border-color: var(--theme-border);
  background: var(--theme-surface);
}

.lh-list-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--theme-surface-muted);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

[data-bs-theme="dark"] .lh-list-row {
  border-bottom-color: var(--theme-surface-muted);
}

.lh-list-row:last-child {
  border-bottom: none;
}

.lh-list-row:hover {
  background: var(--theme-surface-hover);
}

[data-bs-theme="dark"] .lh-list-row:hover {
  background: var(--theme-surface-muted);
}

.lh-list-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--lh-primary-soft);
  color: var(--lh-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.lh-badge-soft {
  background: var(--theme-success-soft);
  color: var(--theme-success-text);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
}

/* Guest (login) layout */
.lh-guest {
  min-height: 100vh;
  background: linear-gradient(155deg, var(--lh-primary-soft) 0%, var(--theme-surface) 42%, var(--lh-bg-page) 100%);
}

.lh-guest main {
  animation: lhContentReveal 0.55s var(--lh-ease-out) both;
}

[data-bs-theme="dark"] .lh-guest {
  background: linear-gradient(160deg, var(--theme-accent-soft) 0%, var(--theme-background) 50%);
}

/* Bootstrap overrides — purple primary */
.btn-primary {
  background: linear-gradient(135deg, var(--lh-primary), var(--lh-primary-hover)) !important;
  border: none !important;
}

.btn-primary:hover {
  filter: brightness(0.95);
}

.btn-outline-primary {
  border-color: var(--lh-primary) !important;
  color: var(--lh-primary) !important;
}

.btn-outline-primary:hover {
  background: var(--lh-primary-soft) !important;
 color: var(--lh-primary-hover) !important;
}

.role-badge {
  background: linear-gradient(135deg, var(--lh-primary), var(--lh-primary-hover)) !important;
  border: none !important;
}

/* Top bar / navbar: align pill with nav text (no vertical nudge — match nav-link rhythm) */
.lh-topbar .role-badge,
.navbar .role-badge {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center;
  gap: 0.35rem;
  line-height: 1.5 !important;
  padding: 0.5rem 0.85rem !important;
  font-size: 0.875rem !important;
  font-weight: 600;
  align-self: center;
  margin: 0;
  transform: none;
  box-shadow: none !important;
}

.lh-topbar .role-badge i,
.navbar .role-badge i {
  line-height: 1;
  display: inline-flex;
  align-items: center;
  font-size: 1em;
}

/* When the badge sits in a Bootstrap navbar row, match nav link vertical alignment */
.navbar .navbar-nav {
  align-items: center;
}

/* Align legacy home/dashboard classes with purple theme */
.company-icon,
.user-avatar,
.login-logo {
  background: linear-gradient(135deg, var(--lh-primary), var(--lh-primary-hover)) !important;
}

.feature-icon,
.action-icon {
  color: var(--lh-primary) !important;
}

.action-card:hover {
  border-color: var(--lh-primary-border) !important;
}

.login-btn {
  background: linear-gradient(135deg, var(--lh-primary), var(--lh-primary-hover)) !important;
  border: none !important;
}

/* Mobile nav */
@media (max-width: 991.98px) {
  .lh-app-shell {
    flex-direction: column;
  }

  .lh-sidebar {
    position: relative;
    height: auto;
    width: 100% !important;
    border-right: none;
    border-bottom: 1px solid var(--theme-border);
  }

  .lh-sidebar--collapsed {
    width: 100% !important;
  }

  .lh-sidebar--collapsed .lh-sidebar-brand-text,
  .lh-sidebar--collapsed .lh-nav-label {
    display: block !important;
  }

  .lh-topbar-search {
    display: none;
  }

  .lh-nav-link:hover {
    transform: none;
  }

  .lh-content {
    padding: 1.25rem 1rem;
  }
}

/* ----- Accessibility: respect reduced motion ----- */
@media (prefers-reduced-motion: reduce) {
  .lh-motion .lh-content-reveal,
  .lh-guest main,
  .lh-main-wrap > .px-3.pt-3 .alert,
  .lh-topbar .dropdown-menu {
    animation: none !important;
  }

  .lh-sidebar-logo,
  .lh-nav-link,
  .lh-icon-btn,
  .lh-avatar-btn,
  .lh-card,
  .lh-list-row {
    transition: none !important;
  }

  .lh-nav-link:hover {
    transform: none !important;
  }

  .lh-card:hover {
    transform: none !important;
  }
}

/* ----- Harmonize legacy blue accents from site.css / dark-mode.css ----- */
.tile::before {
  background: linear-gradient(90deg, var(--lh-primary), var(--lh-primary-hover)) !important;
}

.form-control:focus {
  border-color: var(--lh-primary) !important;
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.22) !important;
}

.btn:focus-visible,
.form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.35) !important;
}

/* Dashboard tiles & action cards — align with Lighthouse radius and motion */
.dashboard-header {
  border-radius: var(--lh-radius) !important;
  transition: box-shadow var(--lh-duration) ease !important;
}

.action-card {
  border-radius: var(--lh-radius) !important;
  transition:
    box-shadow var(--lh-duration) var(--lh-ease-out),
    transform var(--lh-duration) var(--lh-ease-out),
    border-color var(--lh-duration) ease !important;
}

.action-card:hover {
  border-color: var(--lh-primary-border) !important;
}
