/* ==========================================================================
   Dashboard Layout
   ========================================================================== */

body.dashboard-layout {
  display: flex;
  overflow: hidden; /* Main app container takes full height */
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
  width: 280px;
  height: 100vh;
  background-color: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--bg-white);
  font-size: 1.5rem;
  font-weight: 700;
  text-decoration: none;
}

.sidebar-menu {
  flex-grow: 1;
  padding: 1rem 0;
  overflow-y: auto;
  list-style: none;
}

.sidebar-item {
  margin: 0.25rem 1rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  font-weight: 500;
}

.sidebar-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--sidebar-active);
}

.sidebar-item.active .sidebar-link {
  background-color: var(--primary);
  color: var(--bg-white);
  box-shadow: var(--shadow);
}

.sidebar-icon {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
}

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-profile-sm {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--bg-white);
}

.user-profile-sm img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.user-info-sm h6 {
  margin: 0;
  font-size: 0.875rem;
}

.user-info-sm p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--sidebar-text);
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.main-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.header {
  height: 80px;
  background-color: rgba(247,246,242,.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  z-index: 90;
  position: sticky;
  top: 0;
}

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

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-primary);
  cursor: pointer;
}

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

.header-search {
  position: relative;
  width: 300px;
}

.header-search input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border-radius: 30px;
  border: none;
  background-color: var(--bg-white);
  box-shadow: var(--shadow);
  color: var(--text-primary);
}

.header-search i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
}

/* Content Area */
.content-area {
  flex-grow: 1;
  padding: 2rem;
  overflow-y: auto;
}

.page-header {
  margin-bottom: 2rem;
}

.page-title {
  margin-bottom: 0.25rem;
}

/* ==========================================================================
   Dashboard Widgets
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background-color: var(--bg-white);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--bg-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--primary);
  flex-shrink: 0;
}

.stat-info {
  flex-grow: 1;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0;
}

.stat-change {
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

/* Dashboard Layout Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-container {
  background-color: var(--bg-white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  height: 100%;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-container {
  background-color: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-header-wrapper {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: 1rem 1.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-primary);
  font-size: 0.875rem;
}

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

.table tbody tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   Mobile Responsive
   ========================================================================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 95;
  opacity: 0;
  transition: opacity 0.3s ease;
}

@media (max-width: 992px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  .mobile-toggle {
    display: block;
  }
  
  .sidebar-overlay.show {
    display: block;
    opacity: 1;
  }
  
  .header-search {
    display: none; /* Hide complex search on small screens */
  }
  
  .content-area {
    padding: 1rem;
  }
}

/* ChambaYa — Responsive fixes */
html, body { overflow-x: hidden; }

@media (max-width: 768px) {
  .header { padding: 0 1rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 1rem; }
  .page-header h1 { font-size: 1.5rem; }
  .table-responsive { -webkit-overflow-scrolling: touch; }
}
