/* ══════════════════════════════════════════════
   Analytics Dashboard — Styles
   ══════════════════════════════════════════════ */

.analytics-page {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-base);
}

/* Sidebar structure */
.sidebar {
  width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
}

.sidebar-nav {
  padding: 24px 16px;
  flex: 1;
}

.sidebar-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all .2s;
}

.sidebar-nav a:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.sidebar-nav li.active a {
  background: var(--accent-muted);
  color: var(--accent);
}

/* Main content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
}
.topbar-content {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}
.topbar-actions {
  display: flex;
  gap: 12px;
}

/* Dashboard container */
.dashboard-container {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
  background: var(--bg-base);
}

/* Dashboard Cards */
.dash-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
  transition: transform .2s, box-shadow .2s;
}

.dash-card:hover {
  box-shadow: 0 8px 32px rgba(88,166,255,0.05);
}

/* Stat Cards */
.stat-header {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 12px;
}
.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.stat-trend {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.trend-up { color: var(--success); }
.trend-neutral { color: var(--text-muted); }

/* Chart Cards */
.chart-card {
  padding: 20px 24px;
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.chart-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.chart-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.chart-container {
  flex: 1;
  position: relative;
  width: 100%;
  min-height: 200px;
}

.summary-card {
  justify-content: center;
}

.summary-header {
  margin-bottom: 12px;
}

.summary-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
}

.summary-label {
  font-size: 14px;
  color: var(--text-muted);
}

.summary-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.summary-revenue {
  font-size: 28px;
  font-weight: 700;
  color: var(--success);
}

/* List container */
.list-container {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
}
.list-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}
.list-item:last-child {
  border-bottom: none;
}
.list-item-label {
  color: var(--text-secondary);
}
.list-item-value {
  font-weight: 600;
  color: var(--text-primary);
}

/* GridStack Overrides */
.grid-stack-item-content {
  inset: 0 !important;
}
.grid-stack > .grid-stack-item > .ui-resizable-se {
  right: 8px;
  bottom: 8px;
  filter: invert(1);
  opacity: 0.2;
}

@media (max-width: 1100px) {
  .topbar {
    padding: 0 16px;
  }

  .dashboard-container {
    padding: 16px;
  }
}

@media (max-width: 900px) {
  .analytics-page {
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-nav {
    padding: 12px 16px;
  }

  .sidebar-nav ul {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .main-content {
    overflow: visible;
  }
}

@media (max-width: 768px) {
  .analytics-page {
    display: block;
  }

  .sidebar-header {
    padding: 14px 16px;
  }

  .sidebar-nav {
    padding: 10px 12px;
    overflow-x: auto;
  }

  .sidebar-nav ul {
    flex-wrap: nowrap;
    width: max-content;
    min-width: 100%;
  }

  .sidebar-nav a {
    padding: 9px 12px;
    white-space: nowrap;
  }

  .main-content {
    min-height: 0;
  }

  .topbar {
    height: auto;
    min-height: 64px;
    padding: 12px;
  }

  .topbar-content {
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 17px;
  }

  .topbar-actions {
    width: 100%;
    gap: 8px;
  }

  .topbar-actions .btn {
    flex: 1;
    justify-content: center;
    padding-inline: 10px;
  }

  .dashboard-container {
    padding: 12px;
    overflow: visible;
  }

  .grid-stack {
    height: auto !important;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .grid-stack > .grid-stack-item {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .grid-stack > .grid-stack-item > .grid-stack-item-content {
    position: relative !important;
    inset: auto !important;
    height: auto !important;
  }

  .dash-card {
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,.16);
  }

  .dash-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,.16);
  }

  .stat-value {
    font-size: 28px;
  }

  .chart-card {
    min-height: 320px;
  }

  .summary-card {
    min-height: 220px;
  }

  .chart-header {
    gap: 12px;
    align-items: flex-start;
  }

  .chart-header h3 {
    min-width: 0;
    line-height: 1.3;
  }

  .chart-container {
    min-height: 240px;
  }

  .list-container {
    min-height: 220px;
  }

  .grid-stack > .grid-stack-item > .ui-resizable-se {
    display: none !important;
  }
}
