/* ============================================================
   Phygital-Recon  —  Dashboard-Specific Styles
   dashboard.css
   ============================================================ */

/* ── Dashboard Body ─────────────────────────────────────────── */
.dashboard-body {
  padding:        28px;
  display:        flex;
  flex-direction: column;
  gap:            24px;
  flex:           1;
  position:       relative;
}

.dashboard-body::before {
  content: '';
  position: fixed;
  top: 92px;
  right: 5vw;
  width: 34vw;
  height: 34vw;
  min-width: 360px;
  min-height: 360px;
  pointer-events: none;
  background: radial-gradient(circle, rgba(97,218,251,0.16), transparent 62%);
  filter: blur(8px);
  z-index: -1;
}

/* ── Section Headers ─────────────────────────────────────────── */
.section-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  margin-bottom:   4px;
  gap:             12px;
  flex-wrap:       wrap;
}

.section-title {
  font-family:    'Space Grotesk', sans-serif;
  font-size:      16px;
  font-weight:    700;
  color:          var(--text-primary);
  letter-spacing: -0.2px;
}

.section-subtitle {
  font-size: 12px;
  color:     var(--text-muted);
  margin-top: 2px;
}

/* ── KPI Grid ────────────────────────────────────────────────── */
.kpi-grid {
  display:               grid;
  grid-template-columns: repeat(3, 1fr);
  gap:                   18px;
}

.kpi-card {
  background:     var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border:         1px solid rgba(255,255,255,0.15);
  border-radius:  18px;
  padding:        20px;
  display:        flex;
  align-items:    center;
  gap:            14px;
  position:       relative;
  overflow:       hidden;
  transition:     var(--transition);
  box-shadow:     var(--glass-shadow);
  animation:      fadeInUp 0.6s ease-out both;
}

.kpi-card::before {
  content:  '';
  position: absolute;
  inset:    0;
  background:
    linear-gradient(120deg, rgba(255,255,255,0.24), transparent 32%),
    radial-gradient(circle at top right, rgba(255,255,255,0.10), transparent 42%);
  pointer-events: none;
}

.kpi-card:hover {
  border-color: var(--border-glow);
  transform:    translateY(-2px);
  box-shadow:   0 26px 80px rgba(0,0,0,0.42), 0 0 0 1px var(--border-glow), inset 0 1px 0 rgba(255,255,255,0.20);
}

/* Individual card left-border accent colors */
.kpi-card:nth-child(1) { border-left: 3px solid var(--accent); }
.kpi-card:nth-child(2) { border-left: 3px solid var(--accent-green); }
.kpi-card:nth-child(3) { border-left: 3px solid var(--accent-orange); }
.kpi-card:nth-child(4) { border-left: 3px solid var(--accent-cyan); }

/* Stagger animation delays */
.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.10s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.20s; }

.kpi-icon {
  width:            48px;
  height:           48px;
  border-radius:    14px;
  display:          flex;
  align-items:      center;
  justify-content:  center;
  flex-shrink:      0;
}

.kpi-icon-accent,
.kpi-icon-green,
.kpi-icon-orange,
.kpi-icon-cyan,
.kpi-icon-purple {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 12px 26px rgba(0,0,0,0.16);
}

.kpi-icon-accent  { color: var(--accent); }
.kpi-icon-green   { color: var(--accent-green); }
.kpi-icon-orange  { color: var(--accent-orange); }
.kpi-icon-cyan    { color: var(--accent-cyan); }
.kpi-icon-purple  { color: var(--accent-purple); }

.kpi-info {
  flex: 1;
  min-width: 0;
}

.kpi-label {
  font-size:      12px;
  text-transform: uppercase;
  font-weight:    600;
  letter-spacing: 0.6px;
  color:          var(--text-muted);
  margin-bottom:  4px;
}

.kpi-value {
  font-family:    'Space Grotesk', sans-serif;
  font-size:      32px;
  font-weight:    700;
  color:          var(--text-primary);
  letter-spacing: -1px;
  line-height:    1;
}

.kpi-change {
  font-size:  11.5px;
  font-weight: 500;
  margin-top: 4px;
}

.kpi-change.positive { color: var(--accent-green); }
.kpi-change.negative { color: #f43f5e; }

/* ── Chart Cards ─────────────────────────────────────────────── */
.chart-card {
  background:    var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border:        1px solid rgba(255,255,255,0.15);
  border-radius: 18px;
  padding:       22px;
  transition:    var(--transition);
  box-shadow:    var(--glass-shadow);
  animation:     fadeInUp 0.6s ease-out both;
  position:      relative;
  overflow:      hidden;
}

.chart-card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(255,255,255,0.16), transparent 26%),
    radial-gradient(circle at 88% 0%, rgba(97,218,251,0.08), transparent 34%);
}

.chart-card:hover {
  border-color: var(--border-glow);
  box-shadow:   0 26px 80px rgba(0,0,0,0.38), 0 0 0 1px var(--border-glow), inset 0 1px 0 rgba(255,255,255,0.18);
}

.chart-header {
  display:         flex;
  align-items:     flex-start;
  justify-content: space-between;
  margin-bottom:   18px;
  gap:             12px;
  flex-wrap:       wrap;
}

.chart-title {
  font-family:    'Space Grotesk', sans-serif;
  font-size:      15px;
  font-weight:    700;
  color:          var(--text-primary);
  letter-spacing: -0.2px;
}

.chart-subtitle {
  font-size:  12px;
  color:      var(--text-muted);
  margin-top: 3px;
}

.chart-wrap {
  position: relative;
  height:   280px;
}

.chart-wrap canvas {
  max-height: 280px !important;
}

.analytics-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.analytics-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.graph-select {
  min-width: 160px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  outline: none;
  padding: 9px 34px 9px 12px;
}

.graph-select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.analytics-chart-wrap {
  height: 330px;
}

.analytics-chart-wrap canvas {
  max-height: 330px !important;
}

/* ── Charts Row ──────────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr;
  gap:     18px;
}

@media (min-width: 1200px) {
  .charts-row {
    grid-template-columns: 1.7fr 1fr;
  }
}

/* ── City Stats Row ──────────────────────────────────────────── */
.city-stats-row {
  display: grid;
  grid-template-columns: 1fr;
  gap:     18px;
}

@media (min-width: 1100px) {
  .city-stats-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Map Card ────────────────────────────────────────────────── */
.map-card {
  background:    var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border:        1px solid var(--border);
  border-radius: var(--radius-xl);
  padding:       22px;
  transition:    var(--transition);
  box-shadow:    0 8px 32px 0 rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  animation:     fadeInUp 0.6s ease-out 0.25s both;
}

.map-card:hover {
  border-color: var(--border-glow);
  box-shadow:   0 8px 32px rgba(0,0,0,0.3);
}

#mapContainer {
  height:        420px;
  border-radius: var(--radius-md);
  overflow:      hidden;
  border:        1px solid var(--border-glow);
  margin-top:    14px;
}

/* Leaflet theme overrides */
.leaflet-container {
  background: var(--bg-primary) !important;
  font-family: 'Inter', sans-serif !important;
}

.leaflet-control-zoom a {
  background:   var(--bg-card) !important;
  color:        var(--text-secondary) !important;
  border-color: var(--border) !important;
}

.leaflet-control-zoom a:hover {
  background:  var(--bg-card-hover) !important;
  color:       var(--text-primary) !important;
}

.leaflet-popup-content-wrapper {
  background:    var(--bg-card) !important;
  color:         var(--text-primary) !important;
  border:        1px solid var(--border-glow) !important;
  border-radius: var(--radius-md) !important;
  box-shadow:    0 8px 32px rgba(0,0,0,0.5) !important;
}

.leaflet-popup-tip {
  background: var(--bg-card) !important;
}

.leaflet-popup-content {
  margin:    12px 16px !important;
  font-size: 13px !important;
}

.visit-popup {
  font-family: 'Inter', sans-serif;
  min-width: 220px;
  color: var(--text-primary);
}

.visit-popup-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.visit-popup-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.visit-popup-row span {
  color: var(--text-muted);
  font-size: 12px;
}

.visit-popup-row strong {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.visit-popup-accent {
  color: var(--accent) !important;
}

/* Cluster markers */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(99,102,241,0.85) !important;
  border-radius:    50% !important;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: rgba(99,102,241,0.7) !important;
  color:            #fff !important;
  font-weight:      700 !important;
  font-family:      'Space Grotesk', sans-serif !important;
}

/* Custom pin */
.custom-marker {
  width:         14px;
  height:        14px;
  border-radius: 50% 50% 50% 0;
  transform:     rotate(-45deg);
  border:        2px solid rgba(255,255,255,0.6);
}

.custom-marker.accent   { background: var(--accent); }
.custom-marker.green    { background: var(--accent-green); }
.custom-marker.orange   { background: var(--accent-orange); }
.custom-marker.cyan     { background: var(--accent-cyan); }

/* Map legend */
.map-legend {
  display:   flex;
  gap:       16px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.ml-item {
  display:     flex;
  align-items: center;
  gap:         6px;
  font-size:   11.5px;
  color:       var(--text-muted);
}

.ml-dot {
  width:         10px;
  height:        10px;
  border-radius: 50%;
  flex-shrink:   0;
}

/* ── Table Section ───────────────────────────────────────────── */
.table-section {
  width: 100%;
}

.table-card {
  background:    var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border:        1px solid var(--border);
  border-radius: var(--radius-xl);
  padding:       22px;
  transition:    var(--transition);
  box-shadow:    0 8px 32px 0 rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  animation:     fadeInUp 0.6s ease-out 0.3s both;
  overflow:      hidden;
}

.table-card:hover {
  border-color: var(--border-glow);
}

.table-controls {
  display:     flex;
  gap:         10px;
  flex-wrap:   wrap;
  align-items: center;
  margin-bottom: 16px;
}

.table-search {
  width:         200px;
  background:    var(--bg-card);
  border:        1px solid var(--border);
  border-radius: var(--radius-md);
  color:         var(--text-primary);
  font-size:     13px;
  padding:       8px 12px;
  outline:       none;
  transition:    var(--transition);
  font-family:   inherit;
}

.table-search:focus {
  border-color: var(--accent);
  box-shadow:   0 0 0 3px rgba(99,102,241,0.1);
}

.table-search::placeholder {
  color: var(--text-muted);
}

.table-select {
  background:    var(--bg-card);
  border:        1px solid var(--border);
  border-radius: var(--radius-md);
  color:         var(--text-primary);
  font-size:     13px;
  padding:       8px 12px;
  outline:       none;
  transition:    var(--transition);
  cursor:        pointer;
  font-family:   inherit;
}

.table-select:focus {
  border-color: var(--accent);
  box-shadow:   0 0 0 3px rgba(99,102,241,0.1);
}

.table-select option {
  background: var(--bg-card);
  color:      var(--text-primary);
}

.table-wrap {
  overflow-x: auto;
}

.student-table {
  width:           100%;
  border-collapse: collapse;
  font-size:       13.5px;
}

.student-table thead th {
  font-size:      11px;
  text-transform: uppercase;
  font-weight:    600;
  letter-spacing: 0.8px;
  color:          var(--text-muted);
  border-bottom:  1px solid var(--border);
  padding:        12px 14px;
  background:     var(--bg-secondary);
  white-space:    nowrap;
  text-align:     left;
}

.student-table thead th:first-child {
  border-radius: 8px 0 0 0;
}

.student-table thead th:last-child {
  border-radius: 0 8px 0 0;
}

.student-table tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition:    var(--transition);
}

.student-table tbody tr:hover {
  background: rgba(99,102,241,0.05);
}

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

.student-table td {
  padding:        11px 14px;
  color:          var(--text-secondary);
  vertical-align: middle;
}

.student-table td .cell-primary {
  color:       var(--text-primary);
  font-weight: 500;
  font-size:   13.5px;
}

.student-table td .cell-secondary {
  font-size:  11.5px;
  color:      var(--text-muted);
  margin-top: 2px;
}

/* ── Table Footer / Pagination ───────────────────────────────── */
.table-footer {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding-top:     16px;
  margin-top:      8px;
  border-top:      1px solid var(--border);
  flex-wrap:       wrap;
  gap:             10px;
}

.table-info {
  font-size: 12px;
  color:     var(--text-muted);
}

.pagination {
  display: flex;
  gap:     4px;
}

.page-btn {
  background:    var(--bg-card);
  border:        1px solid var(--border);
  border-radius: var(--radius-md);
  color:         var(--text-secondary);
  font-size:     12px;
  font-weight:   500;
  padding:       5px 10px;
  cursor:        pointer;
  min-width:     32px;
  text-align:    center;
  transition:    var(--transition);
  font-family:   inherit;
}

.page-btn:hover {
  border-color: var(--accent);
  color:        var(--accent);
}

.page-btn.active {
  background:   linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: transparent;
  color:        #fff;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor:  default;
}

.page-btn:disabled:hover {
  border-color: var(--border);
  color:        var(--text-secondary);
}

/* ── Pie / Donut Legend ──────────────────────────────────────── */
.pie-legend {
  display:        flex;
  flex-direction: column;
  gap:            10px;
  margin-top:     16px;
}

.pie-leg-item {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  gap:             8px;
}

.pie-leg-left {
  display:     flex;
  align-items: center;
  gap:         8px;
  font-size:   12px;
  color:       var(--text-secondary);
}

.pie-leg-dot {
  width:         10px;
  height:        10px;
  border-radius: 50%;
  flex-shrink:   0;
}

.pie-leg-pct {
  font-size:   12px;
  font-weight: 600;
  color:       var(--text-primary);
}

/* ── Revenue Card Specific ───────────────────────────────────── */
.revenue-card {
  background:     linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.08));
  border:         1px solid rgba(99,102,241,0.25);
  border-radius:  var(--radius-xl);
  padding:        22px;
  transition:     var(--transition);
}

.revenue-card:hover {
  border-color: var(--border-glow);
  box-shadow:   0 8px 32px rgba(99,102,241,0.2);
}

/* ── Responsive Breakpoints ──────────────────────────────────── */
@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .dashboard-body {
    padding: 16px;
    gap:     16px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi-value {
    font-size: 26px;
  }

  .chart-wrap {
    height: 220px;
  }

  #mapContainer {
    height: 280px;
  }

  .table-search {
    width: 100%;
  }

  .table-footer {
    flex-direction: column;
    align-items:    flex-start;
  }
}

/* KPI Card Progress Bar Styling */
.kpi-bar {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-top: 8px;
  width: 100%;
}

.kpi-bar-fill {
  height: 100%;
  border-radius: inherit;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Glassmorphism dashboard overrides */
.dashboard-card,
.map-card,
.table-card {
  background: var(--glass-bg) !important;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,255,255,0.15) !important;
  border-radius: 18px !important;
  box-shadow: var(--glass-shadow);
  position: relative;
  overflow: hidden;
}

.dashboard-card::before,
.map-card::before,
.table-card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(255,255,255,0.14), transparent 28%),
    radial-gradient(circle at 92% 2%, rgba(97,218,251,0.08), transparent 36%);
}

.chart-card-header,
.chart-header,
.analytics-card-header,
.table-controls,
.chart-wrap,
#mapContainer,
.data-table,
.pagination {
  position: relative;
  z-index: 1;
}

.year-toggle-btn,
.year-chip,
.page-btn,
.graph-select,
.form-control,
.table-search,
.table-select {
  background: rgba(255,255,255,0.075) !important;
  border: 1px solid rgba(255,255,255,0.14) !important;
  color: var(--text-secondary) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.10);
}

.year-toggle-btn:hover,
.year-chip:hover,
.page-btn:hover,
.graph-select:hover,
.form-control:focus,
.graph-select:focus {
  background: rgba(255,255,255,0.12) !important;
  border-color: var(--border-glow) !important;
  color: var(--text-primary) !important;
}

.year-toggle-btn.active,
.year-chip.active,
.page-btn.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.42), rgba(97,218,251,0.16)) !important;
  border-color: rgba(97,218,251,0.42) !important;
  color: var(--accent) !important;
  box-shadow: 0 12px 26px rgba(99,102,241,0.18), inset 0 1px 0 rgba(255,255,255,0.18);
}

.kpi-bar {
  background: rgba(255,255,255,0.12) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.kpi-bar-fill {
  box-shadow: 0 0 18px rgba(255,255,255,0.22);
}

#mapContainer {
  border: 1px solid rgba(255,255,255,0.16) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.10), 0 18px 48px rgba(0,0,0,0.24);
}

.leaflet-control-zoom a,
.leaflet-popup-content-wrapper {
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.data-table {
  overflow: hidden;
}

.data-table thead th {
  background: rgba(255,255,255,0.08) !important;
  border-bottom: 1px solid rgba(255,255,255,0.12) !important;
  color: var(--text-muted) !important;
}

.data-table tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.075);
}

.data-table tbody tr:hover {
  background: rgba(255,255,255,0.075);
}

.data-table td {
  color: var(--text-secondary);
}

.badge {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12);
}

.single-graph-subtitle + .chart-subtitle {
  display: none;
}

/* Theme consistency fixes */
[data-theme="dark"] .kpi-card,
[data-theme="dark"] .chart-card,
[data-theme="dark"] .dashboard-card,
[data-theme="dark"] .map-card,
[data-theme="dark"] .table-card {
  background: linear-gradient(145deg, rgba(24,31,58,0.58), rgba(9,15,31,0.46)) !important;
  border-color: rgba(142, 205, 255, 0.18) !important;
}

[data-theme="dark"] .graph-select,
[data-theme="dark"] .form-control,
[data-theme="dark"] .year-toggle-btn,
[data-theme="dark"] .year-chip,
[data-theme="dark"] .page-btn {
  background: rgba(6, 10, 22, 0.44) !important;
  color: var(--text-secondary) !important;
}

[data-theme="light"] .kpi-card,
[data-theme="light"] .chart-card,
[data-theme="light"] .dashboard-card,
[data-theme="light"] .map-card,
[data-theme="light"] .table-card {
  background: linear-gradient(145deg, rgba(255,255,255,0.84), rgba(238,247,255,0.56)) !important;
  border-color: rgba(255,255,255,0.78) !important;
  box-shadow: 0 22px 60px rgba(82, 105, 148, 0.14), inset 0 1px 0 rgba(255,255,255,0.92);
}

[data-theme="light"] .graph-select,
[data-theme="light"] .form-control,
[data-theme="light"] .year-toggle-btn,
[data-theme="light"] .year-chip,
[data-theme="light"] .page-btn {
  background: rgba(255,255,255,0.62) !important;
  color: var(--text-secondary) !important;
  border-color: rgba(255,255,255,0.78) !important;
}

