// Community Analytics Dashboard Styles
// =====================================
// Mobile-first responsive design für das Analytics Dashboard

.analytics-dashboard {
  // Header Section
  &__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;

    @media (max-width: 768px) {
      flex-direction: column;
    }
  }

  &__title {
    h1 {
      margin: 0;
      font-size: 1.75rem;
      font-weight: 600;
      color: var(--theme-text);
    }
  }

  &__nav {
    margin-bottom: 0.5rem;
  }

  &__back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--theme-elevation-600);
    text-decoration: none;
    transition: color 0.2s ease;

    &:hover {
      color: var(--theme-text);
    }
  }

  &__subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--theme-elevation-800);
  }

  &__filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
  }

  &__filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;

    label {
      font-size: 0.875rem;
      color: var(--theme-elevation-800);
      white-space: nowrap;
    }
  }

  &__select {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--theme-elevation-150);
    border-radius: 6px;
    background: var(--theme-elevation-0);
    color: var(--theme-text);
    cursor: pointer;

    &:hover {
      border-color: var(--theme-elevation-250);
    }

    &:focus {
      outline: none;
      border-color: var(--theme-elevation-400);
    }
  }

  // KPI Cards Grid
  &__kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;

    @media (max-width: 480px) {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  // Charts Grid
  &__charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;

    @media (max-width: 1024px) {
      grid-template-columns: 1fr;
    }
  }

  // Card Base
  &__card {
    background: var(--theme-elevation-50);
    border-radius: 8px;
    padding: 1.25rem;

    h3 {
      margin: 0 0 1rem;
      font-size: 1rem;
      font-weight: 600;
      color: var(--theme-text);
    }

    &--wide {
      grid-column: span 1;
    }
  }
}

// KPI Card Component
.kpi-card {
  background: var(--theme-elevation-50);
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;

  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }

  &__icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--theme-elevation-100);

    &--blue { background: rgba(59, 130, 246, 0.15); }
    &--green { background: rgba(16, 185, 129, 0.15); }
    &--purple { background: rgba(139, 92, 246, 0.15); }
    &--yellow { background: rgba(245, 158, 11, 0.15); }
    &--red { background: rgba(239, 68, 68, 0.15); }
    &--gray { background: var(--theme-elevation-100); }
  }

  &__value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--theme-text);
    line-height: 1.2;
  }

  &__label {
    font-size: 0.75rem;
    color: var(--theme-elevation-800);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
  }

  &__trend {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;

    &--up {
      color: #10B981;
      background: rgba(16, 185, 129, 0.1);
    }

    &--down {
      color: #EF4444;
      background: rgba(239, 68, 68, 0.1);
    }

    &--neutral {
      color: var(--theme-elevation-600);
      background: var(--theme-elevation-100);
    }
  }

  &--loading {
    min-height: 140px;
    justify-content: center;
  }

  &__skeleton {
    width: 60%;
    height: 24px;
    background: linear-gradient(90deg,
      var(--theme-elevation-100) 25%,
      var(--theme-elevation-150) 50%,
      var(--theme-elevation-100) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
  }

  &--error {
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
    padding: 2rem;
  }
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

// Chart States
.chart-loading,
.chart-error,
.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--theme-elevation-600);
  font-size: 0.875rem;
}

.chart-error {
  color: #EF4444;
}

// Sentiment Trend Chart
.sentiment-trend-chart {
  min-height: 300px;

  .recharts-legend-wrapper {
    font-size: 0.75rem;
  }
}

// Response Metrics
.response-metrics {
  display: flex;
  flex-direction: column;
  gap: 1rem;

  &__item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }

  &__label {
    font-size: 0.75rem;
    color: var(--theme-elevation-800);
    font-weight: 500;
  }

  &__value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--theme-text);
  }

  &__bar {
    height: 6px;
    background: var(--theme-elevation-150);
    border-radius: 3px;
    overflow: hidden;
  }

  &__bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
  }

  &__target {
    font-size: 0.625rem;
    color: var(--theme-elevation-600);
  }

  &__priority-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--theme-elevation-150);

    h4 {
      margin: 0 0 0.75rem;
      font-size: 0.875rem;
      font-weight: 600;
      color: var(--theme-text);
    }
  }

  &__priority-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  &__priority {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;

    &--urgent {
      background: rgba(239, 68, 68, 0.1);
      .response-metrics__priority-label { color: #EF4444; }
    }

    &--high {
      background: rgba(245, 158, 11, 0.1);
      .response-metrics__priority-label { color: #F59E0B; }
    }

    &--normal {
      background: rgba(59, 130, 246, 0.1);
      .response-metrics__priority-label { color: #3B82F6; }
    }

    &--low {
      background: var(--theme-elevation-100);
      .response-metrics__priority-label { color: var(--theme-elevation-600); }
    }
  }

  &__priority-label {
    font-weight: 600;
  }

  &__priority-count {
    font-weight: 700;
    color: var(--theme-text);
  }

  &__priority-time {
    color: var(--theme-elevation-600);
  }
}

.metrics-loading,
.metrics-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--theme-elevation-600);
  font-size: 0.875rem;
}

// Channel Comparison Table
.channel-comparison {
  overflow-x: auto;

  &__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;

    th, td {
      padding: 0.75rem;
      text-align: left;
      border-bottom: 1px solid var(--theme-elevation-150);
    }

    th {
      font-weight: 600;
      color: var(--theme-elevation-800);
      font-size: 0.75rem;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    td {
      color: var(--theme-text);
    }

    tr:hover td {
      background: var(--theme-elevation-100);
    }
  }

  &__channel {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
  }

  &__platform {
    font-size: 0.625rem;
    color: var(--theme-elevation-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  &__sentiment {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
  }

  &__rate {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    background: var(--theme-elevation-100);

    &--good {
      background: rgba(16, 185, 129, 0.15);
      color: #10B981;
    }
  }

  &__topics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  &__topic-tag {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    font-size: 0.625rem;
    background: var(--theme-elevation-150);
    border-radius: 3px;
    color: var(--theme-elevation-700);
  }

  &-loading,
  &-error,
  &-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    color: var(--theme-elevation-600);
    font-size: 0.875rem;
  }
}

// Top Content List
.top-content {
  &__header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
  }

  &__sort {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;

    label {
      color: var(--theme-elevation-600);
    }

    select {
      padding: 0.375rem 0.5rem;
      font-size: 0.875rem;
      border: 1px solid var(--theme-elevation-150);
      border-radius: 4px;
      background: var(--theme-elevation-0);
      color: var(--theme-text);
    }
  }

  &__loading,
  &__error,
  &__empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    color: var(--theme-elevation-600);
    font-size: 0.875rem;
  }

  &__list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  &__item {
    display: grid;
    grid-template-columns: 32px 80px 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem;
    background: var(--theme-elevation-0);
    border-radius: 6px;
    border: 1px solid var(--theme-elevation-100);

    @media (max-width: 768px) {
      grid-template-columns: 32px 60px 1fr;
      grid-template-rows: auto auto;

      .top-content__stats {
        grid-column: 1 / -1;
        justify-content: flex-start;
      }
    }
  }

  &__rank {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--theme-elevation-400);
    text-align: center;
  }

  &__thumbnail {
    width: 80px;
    height: 45px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--theme-elevation-100);

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    @media (max-width: 768px) {
      width: 60px;
      height: 34px;
    }
  }

  &__thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
  }

  &__info {
    min-width: 0;
  }

  &__title {
    margin: 0 0 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--theme-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  &__channel {
    font-size: 0.75rem;
    color: var(--theme-elevation-600);
  }

  &__topics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.375rem;
  }

  &__topic {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    font-size: 0.625rem;
    background: var(--theme-elevation-100);
    border-radius: 3px;
    color: var(--theme-elevation-700);
  }

  &__stats {
    display: flex;
    gap: 1.5rem;
    justify-content: flex-end;
  }

  &__stat {
    text-align: center;

    &--medical {
      .top-content__stat-value {
        color: #EF4444;
      }
    }
  }

  &__stat-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--theme-text);
  }

  &__stat-label {
    display: block;
    font-size: 0.625rem;
    color: var(--theme-elevation-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
}

// Topic Cloud
.topic-cloud {
  &__container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    padding: 1rem;
  }

  &__tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    cursor: default;
    transition: transform 0.2s ease;
    border-radius: 4px;

    &:hover {
      transform: scale(1.1);
      background: var(--theme-elevation-100);
    }
  }

  &__legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--theme-elevation-150);
  }

  &__legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--theme-elevation-600);
  }

  &-loading,
  &-error,
  &-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--theme-elevation-600);
    font-size: 0.875rem;
  }
}
