/* ====================================================
   DASHBOARD & ADMIN LAYOUT - Monochrome & Minimalist
   ==================================================== */

.admin-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
  background-color: var(--bg-primary);
}

/* Sidebar Backdrop (Mobile Drawer) */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sidebar-backdrop.open {
  opacity: 1;
  visibility: visible;
}

/* Admin Sidebar */
.admin-sidebar {
  width: 250px;
  min-width: 250px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  z-index: 9999;
  transition: transform 0.2s ease;
  overflow-y: auto;
}

.admin-sidebar::-webkit-scrollbar {
  width: 4px;
}

.admin-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.admin-layout.sidebar-collapsed .admin-sidebar {
  transform: translateX(-250px);
}

.admin-layout.sidebar-collapsed .admin-main-wrapper {
  margin-left: 0;
  width: 100%;
}

.admin-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.admin-brand-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-xs);
}

.sidebar-close-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-elevated);
}

.admin-sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex-grow: 1;
}

.sidebar-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.75rem 0.65rem 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 0.825rem;
  font-weight: 500;
  transition: color 0.15s ease, background-color 0.15s ease;
  text-decoration: none;
}

.sidebar-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-link:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-elevated);
}

.sidebar-link.active {
  color: var(--text-primary);
  background-color: var(--bg-surface-elevated);
  border-left: 2px solid var(--accent-red);
  font-weight: 600;
}

/* Sidebar System Status Card */
.sidebar-system-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  padding: 0.65rem;
  margin-bottom: 0.65rem;
}

.system-status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.system-status-item:last-child {
  margin-bottom: 0;
}

.system-status-val {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Sidebar Footer & User Card */
.admin-sidebar-footer {
  margin-top: auto;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border-color);
}

.sidebar-user-card {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  padding: 0.65rem;
}

.sidebar-user-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
}

.user-status-dot {
  width: 6px;
  height: 6px;
  background-color: var(--color-success);
  border-radius: 50%;
  flex-shrink: 0;
}

.user-email-text {
  font-size: 0.72rem;
  color: var(--text-primary);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-actions {
  display: flex;
  gap: 0.35rem;
}

.sidebar-user-actions .btn {
  font-size: 0.72rem;
  padding: 0 0.5rem;
  height: 26px;
}

/* Main Content Area */
.admin-main-wrapper {
  margin-left: 250px;
  width: calc(100% - 250px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  transition: margin-left 0.2s ease, width 0.2s ease;
}

/* Header Bar */
.admin-header-bar {
  height: 52px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 990;
}

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

.sidebar-toggle-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.sidebar-toggle-btn:hover {
  border-color: var(--accent-red);
}

.admin-header-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

/* Admin Content Body */
.admin-content,
.admin-content-body {
  padding: 2rem 2.25rem;
  flex-grow: 1;
  width: 100%;
  box-sizing: border-box;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 2rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--border-color);
}

.dashboard-title {
  font-size: 1.45rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.dashboard-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin: 0;
  line-height: 1.5;
}

.dashboard-header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ====================================================
   STAT CARDS GRID (Top Row Metrics)
   ==================================================== */
.stat-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
  width: 100%;
}

.stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
  max-width: 100%;
  transition: border-color 0.15s ease;
}

.stat-card:hover {
  border-color: var(--border-color-strong);
}

.stat-card-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
}

.stat-card-title {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.stat-card-value {
  font-size: clamp(1.2rem, 3.5vw, 1.45rem);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-card-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ====================================================
   CHART CARDS & ANALYTICS
   ==================================================== */
.chart-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  min-width: 0;
  max-width: 100%;
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
}

.chart-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.chart-card-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0;
}

/* Period Switcher */
.period-switcher {
  display: inline-flex;
  gap: 3px;
  background: var(--bg-surface-elevated);
  padding: 3px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  max-width: 100%;
}

.period-btn {
  background: transparent;
  border: none;
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
  white-space: nowrap;
}

.period-btn:hover {
  color: var(--text-primary);
}

.period-btn.active {
  background-color: var(--text-primary);
  color: var(--bg-primary);
  font-weight: 700;
}

/* Chart Stats Summary (Quick Numbers Strip) */
.chart-stats-summary {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  padding: 0.75rem;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-xs);
  margin-bottom: 1.15rem;
  border: 1px solid var(--border-color);
  width: 100%;
}

.chart-stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chart-stat-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.chart-stat-value {
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.chart-canvas-container {
  position: relative;
  height: 260px;
  width: 100%;
  min-width: 0;
}

.chart-canvas-container-sm {
  position: relative;
  height: 200px;
  width: 100%;
  min-width: 0;
}

/* Financial & Distribution Grid */
.financial-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  width: 100%;
}

.financial-grid > * {
  min-width: 0;
  max-width: 100%;
}

.revenue-badge-pill {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  background-color: var(--color-success-bg);
  border: 1px solid var(--color-success);
  color: var(--color-success);
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-xs);
  max-width: 100%;
  word-break: break-word;
}

.package-sale-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-color);
  gap: 0.75rem;
}

.package-sale-item:last-child {
  border-bottom: none;
}

.package-sale-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  word-break: break-word;
}

.package-sale-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.package-sale-amount {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--color-success);
  white-space: nowrap;
}

/* Dashboard Split Grid (Recent Tables) */
.dashboard-split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  width: 100%;
}

.dashboard-split-grid > * {
  min-width: 0;
  max-width: 100%;
}

/* Helper Grids */
.admin-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.user-quick-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

/* User Dashboard Layout */
.user-dashboard-hero {
  padding: 2.25rem 0 1.25rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.75rem;
}

/* ====================================================
   RESPONSIVE ADJUSTMENTS
   ==================================================== */
@media (max-width: 1100px) {
  .stat-cards-grid { grid-template-columns: repeat(2, 1fr); }
  .financial-grid { grid-template-columns: 1fr; }
  .dashboard-split-grid { grid-template-columns: 1fr; }
  .chart-stats-summary { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1024px) {
  .admin-sidebar { transform: translateX(-250px); }
  .admin-sidebar.open { transform: translateX(0); }
  .sidebar-close-btn { display: flex; }
  .admin-main-wrapper { margin-left: 0; width: 100%; }
}

@media (max-width: 900px) {
  .user-quick-cards-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .admin-grid-2 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  .dashboard-header-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .dashboard-header-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
  }
  .admin-hide-mobile {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .admin-content,
  .admin-content-body {
    padding: 1rem 0.75rem;
    overflow-x: hidden;
  }
  .stat-cards-grid { grid-template-columns: 1fr; }
  .chart-stats-summary { grid-template-columns: 1fr 1fr; gap: 0.5rem; padding: 0.5rem; }
  .period-switcher {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 2px;
  }
  .period-btn {
    text-align: center;
    padding: 0.35rem 0.2rem;
    font-size: 0.7rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .chart-canvas-container { height: 210px; }
  .chart-canvas-container-sm { height: 180px; }
  .admin-header-bar { padding: 0.5rem 0.75rem; }
  .admin-header-title { font-size: 0.85rem; }
  .card { padding: 1rem 0.75rem; }
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .dashboard-header-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
  }
  .dashboard-header-actions .btn {
    width: 100%;
  }
  .period-switcher {
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
  }
  .package-sale-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  .package-sale-amount {
    align-self: flex-start;
  }
}

@media (max-width: 380px) {
  .chart-stats-summary {
    grid-template-columns: 1fr;
  }
}

/* ====================================================
   ADMIN TABS & SECTION DIVIDERS (Shared across admin)
   ==================================================== */
.admin-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  padding-bottom: 4px;
}

.admin-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.75rem 1.25rem;
  font-size: 0.925rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
}

.admin-tab-btn.active {
  color: #ffffff;
  background: var(--accent-red);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

.section-divider {
  margin: 2rem 0 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.section-divider-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.section-divider-subtitle {
  font-size: 0.825rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

/* ====================================================
   DASHBOARD LIGHT MODE OVERRIDES
   ==================================================== */
[data-theme="light"] .admin-sidebar {
  background-color: #ffffff;
  border-right-color: #e2e8f0;
}

[data-theme="light"] .admin-sidebar-header {
  border-bottom-color: #e2e8f0;
}

[data-theme="light"] .sidebar-section-title {
  color: #475569;
  font-weight: 700;
}

[data-theme="light"] .sidebar-link {
  color: #334155;
}

[data-theme="light"] .sidebar-link:hover {
  color: #09090b;
  background-color: #f1f5f9;
}

[data-theme="light"] .sidebar-link.active {
  color: #09090b;
  background-color: #f1f5f9;
  border-left-color: var(--accent-red);
  font-weight: 700;
}

[data-theme="light"] .sidebar-system-card,
[data-theme="light"] .sidebar-user-card {
  background-color: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .system-status-item {
  color: #475569;
  font-weight: 500;
}

[data-theme="light"] .system-status-val {
  color: #09090b;
  font-weight: 700;
}

[data-theme="light"] .user-email-text {
  color: #09090b;
  font-weight: 600;
}

[data-theme="light"] .admin-header-bar {
  background-color: #ffffff;
  border-bottom-color: #e2e8f0;
}

[data-theme="light"] .admin-header-title {
  color: #09090b;
}

[data-theme="light"] .sidebar-toggle-btn {
  background-color: #f8fafc;
  border-color: #cbd5e1;
  color: #09090b;
}

[data-theme="light"] .dashboard-title {
  color: #09090b;
}

[data-theme="light"] .dashboard-subtitle {
  color: #475569;
}

[data-theme="light"] .stat-card {
  background-color: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .stat-card-title {
  color: #475569;
  font-weight: 700;
}

[data-theme="light"] .stat-card-value {
  color: #09090b;
}

[data-theme="light"] .stat-card-icon {
  background-color: #f8fafc;
  border-color: #e2e8f0;
  color: #334155;
}

[data-theme="light"] .chart-card {
  background-color: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .chart-card-title {
  color: #09090b;
}

[data-theme="light"] .chart-card-subtitle {
  color: #475569;
}

[data-theme="light"] .chart-stats-summary {
  background-color: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .chart-stat-label {
  color: #475569;
}

[data-theme="light"] .chart-stat-value {
  color: #09090b;
}

[data-theme="light"] .period-switcher {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

[data-theme="light"] .period-btn {
  color: #475569;
}

[data-theme="light"] .period-btn:hover {
  color: #09090b;
}

[data-theme="light"] .period-btn.active {
  background-color: #09090b;
  color: #ffffff;
}

[data-theme="light"] .package-sale-name {
  color: #09090b;
}

[data-theme="light"] .package-sale-count {
  color: #475569;
}

[data-theme="light"] .admin-tab-btn {
  color: #475569;
}

[data-theme="light"] .admin-tab-btn:hover {
  color: #09090b;
  background-color: #f1f5f9;
}

[data-theme="light"] .admin-tab-btn.active {
  color: #ffffff;
  background-color: var(--accent-red);
}

[data-theme="light"] .section-divider-title {
  color: #09090b;
}

[data-theme="light"] .section-divider-subtitle {
  color: #475569;
}

