/* Dashboard Layout & Components */

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

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.3s ease;
  z-index: 100;
}

.sidebar-brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-main);
}

.sidebar-brand svg {
  color: var(--primary);
}

.sidebar-nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.nav-item:hover {
  background-color: var(--bg-surface-alt);
  color: var(--text-main);
  text-decoration: none;
}

.nav-item.active {
  background-color: var(--primary-subtle);
  color: var(--primary-text);
  font-weight: 600;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-hover);
  color: var(--text-muted);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--bg-app);
}

/* Top Navbar */
.topbar {
  height: 64px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.topbar-title {
  font-size: 1.15rem;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  font-size: 0.85rem;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
}

.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  background-color: var(--bg-surface-alt);
  color: var(--text-main);
}

/* Page Content */
.content-area {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

/* Metrics Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background-color: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.stat-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Tables */
.table-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.table-header-bar {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
}

.table-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th {
  background-color: var(--bg-surface-alt);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: var(--bg-surface-alt);
}

/* Simple Responsive Charts container */
.chart-container {
  height: 260px;
  width: 100%;
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding-top: 20px;
}

.chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 70%;
  max-width: 40px;
  background: linear-gradient(180deg, var(--primary), #60a5fa);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: height 0.5s ease;
  min-height: 4px;
}

.chart-bar-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Responsive Rules */
@media (max-width: 868px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -260px;
    box-shadow: var(--shadow-xl);
  }
  .sidebar.mobile-open {
    left: 0;
  }
  .sidebar-toggle {
    display: block;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .content-area {
    padding: 16px;
  }
}

