/* ==========================================================================
   LAYOUTS & STRUCTURAL GRID
   Sidebar, Header, Main Canvas, Filter Bars
   ========================================================================== */

#app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* ==========================================================================
   SIDEBAR NAVIGATION
   ========================================================================== */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: width var(--transition-base), background-color var(--transition-base);
}

.sidebar-brand {
  padding: 1.5rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-icon-box {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #00f59b 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #080c14;
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  box-shadow: 0 0 16px rgba(0, 245, 155, 0.4);
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.brand-title span {
  color: var(--primary);
}

.brand-subtitle {
  font-size: 0.72rem;
  color: #94a3b8;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 700;
  padding: 0.75rem 0.75rem 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 0.95rem;
  border-radius: var(--radius-md);
  color: #94a3b8;
  font-weight: 500;
  font-size: 0.88rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
  text-decoration: none;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  transition: transform var(--transition-fast), stroke var(--transition-fast);
}

.nav-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.nav-item:hover svg {
  transform: translateX(2px);
  stroke: var(--primary);
}

.nav-item.active {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(0, 245, 155, 0.12) 0%, rgba(6, 182, 212, 0.04) 100%);
  border: 1px solid rgba(0, 245, 155, 0.25);
  font-weight: 600;
}

.nav-item.active svg {
  stroke: var(--primary);
}

.nav-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(244, 63, 94, 0.2);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.nav-badge.badge-primary {
  background: var(--primary-subtle);
  color: var(--primary);
  border-color: rgba(0, 245, 155, 0.3);
}

/* SIDEBAR FOOTER */
.sidebar-footer {
  padding: 1.1rem 1rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.db-status-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.76rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-dot.danger {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.user-profile-widget {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.25rem;
}

.user-avatar-box {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.2;
}

.user-role {
  font-size: 0.7rem;
  color: #94a3b8;
}

.btn-icon-ghost {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-icon-ghost:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   MAIN CONTENT WRAPPER & HEADER
   ========================================================================== */
#main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}

#top-header {
  height: var(--header-height);
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  transition: background-color var(--transition-base);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.page-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.quick-stats-ticker {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card-inner);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.95rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
}

.ticker-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.ticker-label {
  color: var(--text-dim);
}

.ticker-value {
  font-weight: 700;
  color: var(--text-main);
}

/* ==========================================================================
   GLOBAL FILTER BAR
   ========================================================================== */
.global-filter-bar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.filters-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-select, .filter-input {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.filter-select:focus, .filter-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-subtle);
}

/* CONTENT CANVAS CONTAINER */
.content-canvas {
  flex: 1;
  padding: 1.75rem 2rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* GRIDS */
.grid-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.grid-charts-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

.grid-charts-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.5rem;
}

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

@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: -100%;
    transition: left var(--transition-base);
  }
  #sidebar.open {
    left: 0;
  }
  #top-header {
    padding: 0 1rem;
  }
  .content-canvas {
    padding: 1rem;
  }
  .global-filter-bar {
    padding: 0.75rem 1rem;
  }
}
