/* ================================
   Stats Overview
   ================================ */
.stats-overview {
  padding: 2rem 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent, var(--accent-blue));
  box-shadow: var(--shadow-lg);
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent, var(--gradient-primary));
  opacity: 0.8;
}

.stat-primary {
  --accent: var(--accent-blue);
}
.stat-success {
  --accent: var(--accent-green);
}
.stat-warning {
  --accent: var(--accent-orange);
}
.stat-info {
  --accent: var(--accent-purple);
}

.stat-icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.stat-card:hover .stat-icon-wrapper {
  transform: scale(1.1) rotate(-5deg);
  background: color-mix(in srgb, var(--accent) 25%, transparent);
}

.stat-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.5px;
}

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.25rem 0.625rem;
  background: var(--bg-secondary);
  border-radius: 20px;
  align-self: flex-start;
}

.stat-trend.trend-up {
  color: var(--accent-green);
  background: rgba(129, 199, 132, 0.1);
}
.stat-trend.trend-down {
  color: var(--accent-red);
  background: rgba(129, 199, 132, 0.1);
}

/* ================================
   Charts Section
   ================================ */
.charts-section {
  padding: 2rem 0;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: var(--transition);
}

.chart-card:hover {
  border-color: var(--border-color);
  box-shadow: var(--shadow-md);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.chart-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.chart-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chart-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.7rem;
  padding: 0.25rem 0.625rem;
  background: rgba(129, 199, 132, 0.1);
  color: var(--accent-green);
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.3);
  }
}

/* Bar Chart */
.bar-chart {
  min-height: 300px;
}

.bars-container {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  height: 240px;
  padding: 0 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  cursor: pointer;
  min-width: 30px;
  opacity: 0;
  animation: barFadeIn 0.6s forwards;
  animation-delay: var(--delay);
}

@keyframes barFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bar-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bar {
  width: 70%;
  max-width: 48px;
  background: var(--border-color);
  border-radius: 8px 8px 0 0;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  animation: barGrow 1s ease-out forwards;
  transform-origin: bottom;
}

@keyframes barGrow {
  from {
    transform: scaleY(0);
  }
  to {
    transform: scaleY(1);
  }
}

.bar-active {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--gradient-primary);
  border-radius: 8px 8px 0 0;
}

.bar-item:hover .bar {
  filter: brightness(1.2);
}

.bar-item:hover .bar-tooltip {
  opacity: 1;
  transform: translateY(-5px);
  visibility: visible;
}

.bar-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.bar-value {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.bar-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  z-index: 10;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  pointer-events: none;
}

.bar-tooltip strong {
  color: var(--text-primary);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border-color);
}

.bar-tooltip span {
  color: var(--text-secondary);
}

.chart-legend {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.25rem;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* Donut Chart */
.donut-chart-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.donut-chart {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: donutSpin 1s ease-out;
}

@keyframes donutSpin {
  from {
    transform: rotate(-180deg);
    opacity: 0;
  }
  to {
    transform: rotate(0);
    opacity: 1;
  }
}

.donut-center {
  width: 65%;
  height: 65%;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.donut-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.donut-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.legend-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.625rem 0.875rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.legend-row:hover {
  background: var(--bg-card-hover);
  transform: translateX(2px);
}

.legend-text {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
}

.legend-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.legend-percent {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.125rem 0.5rem;
  background: var(--bg-card);
  border-radius: 20px;
  font-weight: 600;
}

/* Empty State */
.empty-chart,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  text-align: center;
  gap: 1rem;
}

.empty-chart svg {
  opacity: 0.3;
}

.empty-chart p,
.empty-state p {
  font-size: 0.9rem;
}

/* ================================
   Bottom Section
   ================================ */
.bottom-section {
  padding: 2rem 0 4rem;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.25rem;
}

.table-card,
.recent-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: var(--transition);
}

.table-card:hover,
.recent-card:hover {
  border-color: var(--border-color);
  box-shadow: var(--shadow-md);
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.table-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.table-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.view-all {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--accent-blue);
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}

.view-all:hover {
  gap: 0.5rem;
  color: var(--accent-purple);
}

/* Rank List (Top Provinsi) */
.rank-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.rank-item {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  transition: var(--transition);
  border: 1px solid transparent;
}

.rank-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color);
  transform: translateX(4px);
}

.rank-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.rank-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rank-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.rank-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.rank-stats .separator {
  color: var(--text-muted);
  font-size: 0.6rem;
}

.rank-stats .text-success {
  color: var(--accent-green);
  font-weight: 600;
}

.rank-progress {
  width: 100%;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s ease-out;
  animation: progressGrow 1s ease-out;
}

@keyframes progressGrow {
  from {
    width: 0 !important;
  }
}

/* Recent List (KSB Terbaru) */
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recent-item {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0.875rem 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: var(--transition);
  border: 1px solid transparent;
}

.recent-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
  transform: translateX(4px);
}

.recent-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.recent-content {
  flex: 1;
  min-width: 0;
}

.recent-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}

.recent-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  align-items: center;
}

.recent-meta .separator {
  color: var(--text-muted);
  font-size: 0.5rem;
}

.recent-date {
  color: var(--text-muted);
}

.recent-status {
  flex-shrink: 0;
}

.status-badge {
  font-size: 0.7rem;
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}

.status-active {
  background: rgba(129, 199, 132, 0.15);
  color: var(--accent-green);
}

.status-inactive {
  background: rgba(239, 83, 80, 0.15);
  color: var(--accent-red);
}

/* ================================
   Responsive Design
   ================================ */
@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .bottom-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .chart-card,
  .table-card,
  .recent-card {
    padding: 1.25rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .bars-container {
    height: 180px;
    gap: 0.375rem;
  }

  .bar-label {
    font-size: 0.65rem;
  }

  .donut-chart {
    width: 160px;
    height: 160px;
  }

  .donut-value {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }

  .stat-icon-wrapper {
    width: 56px;
    height: 56px;
  }

  .stat-content {
    flex: 1;
  }

  .stat-trend {
    align-self: auto;
  }

  .rank-item {
    padding: 0.875rem;
    gap: 0.75rem;
  }

  .rank-name {
    font-size: 0.85rem;
  }

  .rank-stats {
    font-size: 0.7rem;
  }

  .recent-name {
    font-size: 0.85rem;
  }

  .legend-row {
    grid-template-columns: auto 1fr auto;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
  }

  .legend-percent {
    display: none;
  }
}

/* ================================
   Animations
   ================================ */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stats-overview,
.charts-section,
.bottom-section {
  animation: slideInUp 0.6s ease-out;
}

.charts-section {
  animation-delay: 0.1s;
  animation-fill-mode: both;
}

.bottom-section {
  animation-delay: 0.2s;
  animation-fill-mode: both;
}

/* ================================
   Scrollbar
   ================================ */
.table-wrapper,
.recent-list {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.table-wrapper::-webkit-scrollbar,
.recent-list::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.table-wrapper::-webkit-scrollbar-thumb,
.recent-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
