@use '../variables' as v;
@use '../mixins' as m;

// ─────────────────────────────────────────────
// Dashboard welcome banner
// ─────────────────────────────────────────────
.dashboard-welcome {
  @include m.card-base;
  padding: 24px 28px;
  @include m.flex-between;
  gap: 24px;
  margin-bottom: 22px;
  overflow: hidden;
  position: relative;

  &::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 200px;
    height: 200px;
    background: var(--active-bg);
    border-radius: v.$radius-full;
    opacity: 0.6;
  }

  &-body { position: relative; z-index: 1; }

  h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
  }

  p {
    font-size: v.$font-size-sm;
    color: var(--text-secondary);
    margin-bottom: 14px;
    @include m.flex-start;
    gap: 6px;
    flex-wrap: wrap;

    a { color: var(--active-text); font-weight: 500; }
  }

  &-meta {
    @include m.flex-start;
    gap: 14px;
    flex-wrap: wrap;
    font-size: v.$font-size-xs;
    color: var(--text-secondary);

    span {
      @include m.flex-start;
      gap: 5px;

      svg { width: 13px; height: 13px; }
    }
  }

  &-illustration {
    flex-shrink: 0;
    width: 120px;
    opacity: 0.8;
    position: relative;
    z-index: 1;

    @include m.max-md { display: none; }
  }
}

// ─────────────────────────────────────────────
// Stat cards grid
// ─────────────────────────────────────────────
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;

  @include m.max-md { grid-template-columns: repeat(2, 1fr); }
  @include m.max-sm { grid-template-columns: 1fr; }
}

.stat-card {
  display: block;
  padding: 28px 24px;
  text-decoration: none;
  transition: box-shadow v.$transition-base;

  &:hover { box-shadow: v.$shadow-md; }
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 8px;
}

.stat-label {
  font-size: v.$font-size-sm;
  color: var(--text-secondary);
}

// ─────────────────────────────────────────────
// Growth chart toolbar
// ─────────────────────────────────────────────
.chart-toolbar {
  @include m.flex-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 12px;
}

.chart-title {
  font-size: v.$font-size-base;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-toolbar-actions {
  @include m.flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.chart-date-input {
  @include m.flex-start;
  gap: 6px;
  border: 1px solid var(--border-color);
  border-radius: v.$radius;
  padding: 6px 10px;
  background: var(--bg-surface);

  svg { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }

  input {
    border: none;
    outline: none;
    font-size: v.$font-size-sm;
    color: var(--text-primary);
    width: 80px;
    background: transparent;
    font-family: v.$font-family;

    &::placeholder { color: var(--text-muted); }
  }
}

.chart-date-sep {
  font-size: v.$font-size-sm;
  font-weight: 500;
  color: var(--text-primary);
}

.chart-legend {
  @include m.flex-start;
  gap: 20px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
}

.chart-legend-item {
  @include m.flex-start;
  gap: 7px;
  font-size: v.$font-size-xs;
  color: var(--text-primary);
}

.chart-legend-bar {
  width: 24px;
  height: 10px;
  background: rgba(124, 58, 237, 0.25);
  border: 1.5px solid #7c3aed;
  border-radius: 2px;
}

.chart-legend-line {
  width: 24px;
  height: 0;
  border-top: 2px dashed #38bdf8;
}

.chart-canvas-wrap {
  padding: 20px 20px 8px;
}

// ─────────────────────────────────────────────
// Quick action strip
// ─────────────────────────────────────────────
.quick-actions {
  @include m.flex-start;
  gap: 10px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

// ─────────────────────────────────────────────
// Chart card
// ─────────────────────────────────────────────
.chart-card {
  @include m.card-base;
  overflow: hidden;

  &-header {
    @include m.flex-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;

    &-left h3 {
      font-size: v.$font-size-base;
      font-weight: 600;
      color: var(--text-primary);
    }

    &-left p {
      font-size: v.$font-size-xs;
      color: var(--text-muted);
      margin-top: 2px;
    }
  }

  &-tabs {
    @include m.flex-start;
    gap: 4px;
  }

  &-tab {
    padding: 5px 12px;
    border-radius: v.$radius;
    font-size: v.$font-size-xs;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background v.$transition-base, color v.$transition-base;

    &:hover { background: var(--bg-hover-strong); color: var(--text-primary); }

    &.is-active {
      background: v.$primary;
      color: v.$white;
    }
  }

  &-body {
    padding: 20px;
    height: 280px;
    position: relative;

    canvas { width: 100% !important; height: 100% !important; }
  }

  &-legend {
    @include m.flex-start;
    gap: 16px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-hover);
    flex-wrap: wrap;

    &-item {
      @include m.flex-start;
      gap: 6px;
      font-size: v.$font-size-xs;
      color: var(--text-secondary);

      &-dot {
        width: 8px;
        height: 8px;
        border-radius: v.$radius-full;
      }
    }
  }
}

// ─────────────────────────────────────────────
// System health
// ─────────────────────────────────────────────
.health-widget {
  @include m.card-base;
  padding: 18px 20px;

  h4 {
    font-size: v.$font-size-sm;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 14px;
  }

  &-row {
    @include m.flex-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: v.$font-size-sm;

    &:last-child { border-bottom: none; }

    &-label { color: var(--text-secondary); }
  }
}
