.statistics-view {
  height: 100%;
  overflow: auto;
  padding: 20px;
  box-sizing: border-box;
}

.statistics-container {
  width: 100%;
  min-height: 100%;
  height: max-content;
  gap: 20px;
  display: grid;
  grid-template-columns: minmax(300px, 550px) minmax(0, 1fr) minmax(260px, auto);
  grid-template-rows: minmax(360px, 420px) minmax(300px, 340px);
  grid-template-areas:
    "file-type creator creator"
    "time time summary";
}

.chart-container {
  background: var(--bs-body-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 -2px 4px #f0f0f0;
  border: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
  min-height: 300px;
}

[data-bs-theme=dark] .chart-container {
  border-color: var(--bs-border-color);
  box-shadow: none;
}

.chart-container:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.chart-container:focus-within {
  outline: 2px solid #3498db;
  outline-offset: 2px;
}

.chart-container.file-type-chart-container {
  grid-area: file-type;
}

.chart-container.creator-chart-container {
  grid-area: creator;
}

.chart-container.time-chart-container {
  grid-area: time;
  gap: 20px;
}

.chart-container.summary-chart-container {
  grid-area: summary;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 16px;
  width: 100%;
}

.chart-header {
  width: 100%;
  height: 36px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.chart-header h4 {
  color: var(--bs-body-color);
  font-size: 14px;
  margin: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.chart-header .dropdown {
  color: var(--bs-icon-color);
}

.chart-header .dropdown:hover {
  background-color: var(--bs-hover-bg);
  border-radius: 3px;
}

.pie-chart-container,
.horizontal-bar-chart-container,
.bar-chart-container {
  flex: 1;
  display: flex;
  min-height: 0;
}

.pie-chart-container {
  justify-content: center;
  align-items: center;
  min-height: 320px;
  width: 100%;
}

.bar-chart-container {
  height: 240px;
  overflow-x: auto;
  width: 100%;
}

.horizontal-bar-chart-container {
  width: 100%;
  height: 340px;
  justify-content: center;
  align-items: center;
}

.bar-chart-responsive {
  width: 100%;
  height: 240px;
  display: flex;
  flex-direction: column;
  min-width: 0; /* allow shrink in nested flex/grid */
}

.bar-chart-responsive svg {
  flex: 1;
  height: 240px;
}

.card-container {
  display: flex;
  flex-direction: row; /* always row */
  gap: 16px;
  flex-wrap: nowrap; /* keep single row */
  width: 100%;
  overflow-x: auto;
}

.summary-card {
  width: 220px;
  height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px;
  background: #fef7ea;
  border-radius: 10px;
  flex: 0 0 auto;
}

.summary-card:nth-child(2) {
  background: #f8f9fd;
}

.summary-icon {
  width: 50px;
  height: 50px;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.summary-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  justify-content: space-between;
}

.summary-number {
  font-size: 42px;
  font-weight: 700;
  color: #212529;
  line-height: 1;
  margin: 0;
}

.summary-label {
  font-size: 16px;
  color: #666;
  font-weight: 500;
  letter-spacing: 0.5px;
  margin: 0;
}

.chart-container.time-chart-container .sf-metadata-radio-group {
  height: 28px;
  border: none;
  padding: 2px;
  background-color: #f3f3f3;
}

.chart-container.time-chart-container .sf-metadata-radio-group::before {
  content: none;
}

[data-bs-theme=dark] .chart-container.time-chart-container .sf-metadata-radio-group {
  background-color: var(--bs-nav-active-bg);
}

.chart-container.time-chart-container .sf-metadata-radio-group .sf-metadata-radio-group-option.active {
  background-color: var(--bs-body-bg);
}

.chart-container.time-chart-container .sf-metadata-time-grouping-setter .sf-metadata-radio-group-option {
  height: 24px;
  font-size: 13px;
  padding: 0 6px;
  background-color: transparent;
  border-radius: 3px;
}

.sf-metadata-time-grouping-setter[data-active="created"]::before {
  transform: translateX(0);
}

.sf-metadata-time-grouping-setter[data-active="modified"]::before {
  transform: translateX(98px);
}

.statistics-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  min-height: 400px;
}

.statistics-error {
  text-align: center;
  padding: 48px 24px;
  color: #666;
  font-size: 16px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--bs-border-color);
}

.no-data-message {
  text-align: center;
  padding: 40px 20px;
  color: #666;
  font-size: 14px;
  font-style: italic;
  background: #f8f9fa;
  border-radius: 8px;
}

.arc path,
.bar {
  transition: all 0.2s ease;
}

.arc path:hover {
  opacity: 0.8;
  stroke-width: 3px;
}

.bar:hover {
  opacity: 0.8;
}

.chart-wrapper {
  animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.arc path,
.bar {
  animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.statistics-view .domain {
  stroke: #999;
}

.statistics-view .tick line {
  stroke: #999;
}

.statistics-view .tick text {
  fill: #666;
  font-size: 12px;
}

@media (max-width: 1023.98px) {
  .statistics-view {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 100%;
    padding: 20px;
  }

  .statistics-container {
    grid-template-columns: 1fr;
    grid-template-rows: 420px 340px;
    grid-template-areas:
      "file-type"
      "creator"
      "time"
      "summary";
    max-width: 550px;
    min-width: auto;
    margin: 0 auto;
    height: auto;
  }

  .chart-container.summary-chart-container {
    justify-content: flex-start;
    align-items: stretch;
    padding: 20px;
  }

  .chart-container.summary-chart-container .card-container {
    justify-content: center;
  }

  .summary-card {
    width: 220px;
    height: 180px;
    padding: 20px;
  }

  .summary-number {
    font-size: 24px;
  }

  .summary-icon {
    font-size: 28px;
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 768px) {
  .statistics-view {
    padding: 0;
  }

  .statistics-container {
    padding: 16px;
    gap: 16px;
    max-width: 100%;
    grid-template-rows: 420px 340px;
  }

  .chart-container {
    padding: 20px;
  }

  .chart-container h4 {
    font-size: 14px;
    margin-bottom: 16px;
    padding-bottom: 8px;
  }

  .chart-header {
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
  }

  .chart-container.summary-chart-container {
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    padding: 16px;
    width: 100%;
    overflow-x: auto;
  }

  .summary-card {
    width: 220px;
    max-width: none;
    height: 140px;
    padding: 16px;
    align-self: stretch;
  }

  .summary-number {
    font-size: 20px;
  }

  .summary-icon {
    font-size: 24px;
    width: 36px;
    height: 36px;
  }
}
