/* ==========================================================================
   LAYOUT — MIND ID ENTERPRISE DASHBOARD
   ========================================================================== */

/* ── APP SHELL ───────────────────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--surface-canvas);
}

/* ── SIDEBAR ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--surface-base);
  border-right: 1px solid var(--surface-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--dur-slow) var(--ease-smooth),
              min-width var(--dur-slow) var(--ease-smooth);
  z-index: var(--z-sidebar);
  flex-shrink: 0;
}

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

/* Sidebar Brand — full logo image, no subtitle */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 var(--space-3);
  height: var(--header-height);
  border-bottom: 1px solid var(--surface-border);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-brand-logo-wrap {
  display: flex; align-items: center;
  width: 100%; height: 100%;
  overflow: hidden;
}
.sidebar-logo-img {
  height: 45px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
  transition: opacity var(--dur-fast);
}
[data-theme="dark"] .sidebar-logo-img { filter: brightness(1.05); }
[data-theme="light"] .sidebar-logo-img { filter: none; }

/* Theme-specific logo visibility rules */
[data-theme="dark"] .logo-dark-only { display: block !important; }
[data-theme="dark"] .logo-light-only { display: none !important; }
[data-theme="light"] .logo-dark-only { display: none !important; }
[data-theme="light"] .logo-light-only { display: block !important; }

/* collapsed: show only the icon portion (left ~30px) */
.sidebar.collapsed .sidebar-brand-logo-wrap { width: 32px; }
.sidebar.collapsed .sidebar-logo-img {
  width: 32px; height: 32px;
  object-position: left center;
}
.sidebar-brand-text { display: none; }

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-3) 0;
}
.sidebar-section {
  margin-bottom: var(--space-2);
}
.sidebar-section-label {
  font-size: 9px; font-weight: var(--fw-bold);
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-disabled);
  padding: var(--space-3) var(--space-4) var(--space-1);
  white-space: nowrap; overflow: hidden;
}

.sidebar.collapsed .sidebar-section-label { opacity: 0; }

/* Nav Items */
.nav-item {
  display: flex; align-items: center;
  gap: var(--space-3);
  padding: 7px var(--space-4);
  cursor: pointer;
  border-radius: 0;
  color: var(--text-secondary);
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  transition: all var(--dur-fast) var(--ease-smooth);
  white-space: nowrap; overflow: hidden;
  border-left: 2px solid transparent;
  position: relative;
}

.nav-item:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--brand-gold-dim);
  color: var(--brand-gold);
  border-left-color: var(--brand-gold);
}

.nav-item .nav-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

.nav-item .nav-label {
  flex: 1; overflow: hidden; text-overflow: ellipsis;
}

.nav-item .nav-badge {
  flex-shrink: 0;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px;
  background: var(--color-negative-bg);
  color: var(--color-negative);
  border-radius: 100px;
  transition: opacity var(--dur-fast);
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .sidebar-brand-text { opacity: 0; pointer-events: none; }

/* Entity Sub-items */
.nav-sub {
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--dur-slow) var(--ease-smooth);
}
.nav-sub.open { max-height: 600px; }

.nav-sub-item {
  display: flex; align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-4) 6px 38px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: var(--text-sm);
  transition: all var(--dur-fast) var(--ease-smooth);
  white-space: nowrap; overflow: hidden;
}
.nav-sub-item:hover { background: var(--surface-elevated); color: var(--text-secondary); }
.nav-sub-item.active { color: var(--brand-gold); }

/* Entity dot color */
.nav-entity-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}

/* Sidebar collapse toggle */
.sidebar-footer {
  border-top: 1px solid var(--surface-border);
  padding: var(--space-2);
  flex-shrink: 0;
}
.sidebar-toggle {
  width: 100%; display: flex; align-items: center;
  gap: var(--space-3); padding: var(--space-2) var(--space-3);
  color: var(--text-muted); font-size: var(--text-sm);
  border-radius: var(--radius-md);
  transition: all var(--dur-fast) var(--ease-smooth);
}
.sidebar-toggle:hover { background: var(--surface-elevated); color: var(--text-secondary); }

/* ── MAIN AREA ───────────────────────────────────────────────────────────── */
.main-area {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
}

/* ── HEADER ──────────────────────────────────────────────────────────────── */
.header {
  height: var(--header-height);
  background: var(--surface-base);
  border-bottom: 1px solid var(--surface-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  flex-shrink: 0;
  z-index: var(--z-header);
  backdrop-filter: blur(8px);
}

.header-left { display: flex; align-items: center; gap: var(--space-3); flex: 1; min-width: 0; }
.header-right { display: flex; align-items: center; gap: var(--space-3); flex-shrink: 0; }

.header-breadcrumb {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-md); color: var(--text-secondary);
  overflow: hidden;
}
.breadcrumb-sep { color: var(--text-disabled); font-size: 12px; }
.breadcrumb-current { color: var(--text-primary); font-weight: var(--fw-semibold); white-space: nowrap; }

/* Header search */
.header-search {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--surface-elevated);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 5px var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-smooth);
  white-space: nowrap;
}
.header-search:hover { border-color: var(--surface-border-md); color: var(--text-secondary); }
.header-search kbd {
  font-size: 10px; padding: 1px 5px;
  background: var(--surface-raised);
  border: 1px solid var(--surface-border-md);
  border-radius: 3px; color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Header icons */
.header-icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all var(--dur-fast) var(--ease-smooth);
  position: relative;
}
.header-icon-btn:hover { background: var(--surface-elevated); color: var(--text-primary); }
.header-icon-btn .badge {
  position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-negative);
  border: 1.5px solid var(--surface-base);
}

/* Data freshness chip */
.freshness-chip {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: 11px; color: var(--text-muted);
  padding: 4px var(--space-3);
  background: var(--surface-elevated);
  border: 1px solid var(--surface-border);
  border-radius: 100px;
}
.freshness-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-positive);
  box-shadow: 0 0 6px var(--color-positive);
}

/* Theme toggle */
.theme-toggle {
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all var(--dur-fast) var(--ease-smooth);
}
.theme-toggle:hover { background: var(--surface-elevated); color: var(--brand-gold); }

/* User avatar */
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-gold) 0%, var(--brand-copper) 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #000;
  cursor: pointer; flex-shrink: 0;
}

/* ── FILTER BAR ──────────────────────────────────────────────── */
.filter-bar {
  background: var(--surface-base);
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  flex-direction: column;
  padding: 5px var(--space-5);
  gap: 4px;
  flex-shrink: 0;
  height: auto; /* override fixed height */
}
.filter-bar::-webkit-scrollbar { height: 0; }

/* Two rows inside filter bar */
.filter-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { height: 0; }

/* ── PILL GROUP ──────────────────────────────────────────────── */
.filter-pill-group {
  display: flex; align-items: center; gap: 2px;
  background: var(--surface-elevated);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
  padding: 2px 3px;
  flex-shrink: 0;
}
.filter-pill-label {
  font-size: 9px; font-weight: var(--fw-bold); letter-spacing: 0.7px;
  color: var(--text-disabled); text-transform: uppercase;
  padding: 0 6px; white-space: nowrap; flex-shrink: 0;
}
.filter-pill {
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px; font-weight: var(--fw-medium);
  color: var(--text-muted); cursor: pointer;
  transition: all var(--dur-fast) var(--ease-smooth);
  white-space: nowrap; user-select: none; border: none;
  background: transparent; font-family: inherit; line-height: 1.4;
}
.filter-pill:hover { color: var(--text-secondary); background: var(--surface-raised); border-radius: var(--radius-full); }
.filter-pill.active {
  background: linear-gradient(135deg, var(--brand-gold) 0%, var(--brand-copper) 100%);
  color: #000; font-weight: var(--fw-bold);
  box-shadow: 0 2px 8px rgba(201,151,58,0.4);
}

/* Entity pills with color dot */
.filter-pill-entity { display: inline-flex; align-items: center; gap: 5px; }
.filter-pill-entity .edot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.filter-pill.active .edot { box-shadow: 0 0 0 2px rgba(0,0,0,0.4); }

/* Commodity pills */
.filter-pill-commodity { display: inline-flex; align-items: center; gap: 5px; }
.filter-pill-commodity .cdot { width: 5px; height: 5px; border-radius: 2px; flex-shrink: 0; }

.filter-separator { width: 1px; height: 14px; background: var(--surface-border-md); flex-shrink: 0; margin: 0 2px; }

.filter-reset-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px; font-weight: var(--fw-medium);
  color: var(--text-muted);
  transition: all var(--dur-fast) var(--ease-smooth);
  white-space: nowrap; flex-shrink: 0; border: none; font-family: inherit;
  background: transparent; cursor: pointer;
}
.filter-reset-btn:hover { background: var(--color-negative-bg); color: var(--color-negative); }

.filter-export-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 11px;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
  font-size: 11px; font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  transition: all var(--dur-fast) var(--ease-smooth);
  white-space: nowrap; flex-shrink: 0;
  background: var(--surface-elevated);
  cursor: pointer; font-family: inherit;
}
.filter-export-btn:hover { border-color: var(--brand-gold); color: var(--brand-gold); box-shadow: 0 0 10px rgba(201,151,58,0.2); }

/* adjust main area since filter bar is now auto height */
.main-area {
  display: flex; flex-direction: column;
  flex: 1; overflow: hidden; min-width: 0;
}

/* ── MAIN CONTENT ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: var(--space-4) var(--space-5);
  min-height: 0;
}

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
}
.page-header-left {}
.page-title { color: var(--text-primary); margin-bottom: 2px; }
.page-subtitle { font-size: var(--text-sm); color: var(--text-secondary); display: flex; align-items: center; gap: var(--space-2); }

.section { margin-bottom: var(--space-4); }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-3);
}
.section-title { color: var(--text-primary); }
.section-actions { display: flex; align-items: center; gap: var(--space-2); }

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  :root { --sidebar-width: 220px; }
  .main-content { padding: var(--space-4); }
}
@media (max-width: 1024px) {
  .sidebar { position: fixed; left: -100%; transition: left var(--dur-slow) var(--ease-smooth), width var(--dur-slow) var(--ease-smooth); }
  .sidebar.mobile-open { left: 0; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5, .grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5, .grid-6 { grid-template-columns: repeat(2, 1fr); }
  .gc-4, .gc-5, .gc-6, .gc-7, .gc-8 { grid-column: span 12; }
  .filter-bar { flex-wrap: wrap; height: auto; padding: var(--space-2) var(--space-4); }
  .header { padding: 0 var(--space-4); }
}
