/* Sleep Module CSS */
.sleep-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

.sleep-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 8px;
}

.sleep-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Quick Stats Row */
.sleep-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.sleep-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sleep-stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.sleep-stat-card .stat-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.sleep-stat-card .stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.text-accent {
  color: #a855f7 !important;
}

/* Sleep Cards Common */
.sleep-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow);
}

.sleep-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.sleep-card-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

/* Hero Night Card */
.hero-sleep-card {
  background: linear-gradient(145deg, #1e1b4b 0%, var(--bg-card) 60%);
  border-color: rgba(139, 92, 246, 0.3);
}

.hero-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-date-badge {
  font-size: 1.1rem;
  font-weight: 700;
  color: #e2e8f0;
}

.hero-time-range {
  font-size: 0.85rem;
  color: #c4b5fd;
  margin-top: 2px;
  font-weight: 500;
}

.hero-score-box {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
}

.hero-score-box.score-good {
  background: rgba(34, 197, 94, 0.18);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #4ade80;
}

.hero-score-box.score-fair {
  background: rgba(234, 179, 8, 0.18);
  border: 1px solid rgba(234, 179, 8, 0.4);
  color: #facc15;
}

.hero-score-box.score-poor {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.score-number {
  font-size: 1.4rem;
}

.score-max {
  font-size: 0.85rem;
  opacity: 0.7;
}

.score-label {
  font-size: 0.8rem;
  margin-left: 6px;
  font-weight: 600;
}

.hero-main-duration {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.duration-big {
  font-size: 2.25rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.5px;
}

.duration-sub {
  font-size: 0.9rem;
}

/* Phases Stacked Bar */
.sleep-phases-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.phases-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.phases-stacked-bar {
  display: flex;
  height: 16px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  width: 100%;
}

.phase-bar {
  height: 100%;
  transition: width 0.3s ease;
}

.phase-bar.deep { background: #8b5cf6; }    /* Violet */
.phase-bar.light { background: #38bdf8; }   /* Sky Blue */
.phase-bar.rem { background: #10b981; }     /* Emerald */
.phase-bar.awake { background: #f97316; }   /* Orange */

.phases-legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 4px;
}

.legend-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.legend-pill .dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.dot-deep { background: #8b5cf6; }
.dot-light { background: #38bdf8; }
.dot-rem { background: #10b981; }
.dot-awake { background: #f97316; }

.legend-pill .val {
  color: var(--text-primary);
  margin-left: auto;
}

/* Recovery Badges Footer */
.hero-recovery-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.recovery-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 12px;
  border-radius: var(--radius-md);
}

.recovery-badge .badge-icon {
  font-size: 1.25rem;
}

.recovery-badge .badge-title {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.recovery-badge .badge-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Empty State */
.empty-sleep-card {
  text-align: center;
  align-items: center;
  padding: 40px 20px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

/* Trend Chart */
.sleep-trend-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 150px;
  padding: 16px 0 0 0;
  width: 100%;
}

.trend-bar-col {
  flex: 1;
  /* bez tego etykiety rozpychają kolumny i ostatnie słupki wypadają poza kartę */
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 4px;
}

.trend-bar-val {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.trend-bar-track {
  width: 100%;
  max-width: 28px;
  height: 100px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  display: flex;
  align-items: flex-end;
}

.trend-bar-fill {
  width: 100%;
  border-radius: 4px;
  transition: height 0.3s ease;
}

.trend-bar-fill.bar-good {
  background: linear-gradient(to top, var(--series-6), var(--accent-info));
}

/* Krótka noc to sygnał, nie alarm — bursztyn zamiast czerwieni. Przy
   typowym tygodniu prawie wszystkie słupki były czerwone i wykres krzyczał. */
.trend-bar-fill.bar-short {
  background: linear-gradient(to top, rgb(245 158 11 / 0.55), var(--accent-warning));
}

/* Linia celu (8 h) — dotąd była tylko zapowiedziana w nagłówku karty */
.trend-bar-track {
  position: relative;
}

.trend-bar-track::after {
  content: '';
  position: absolute;
  left: -4px;
  right: -4px;
  bottom: var(--target-pct, 89%);
  border-top: 1px dashed rgb(255 255 255 / 0.35);
  pointer-events: none;
}

.trend-bar-date {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Sleep Calculator */
.calc-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.calc-tab-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}

.calc-tab-btn {
  min-height: 36px;
}

.calc-tab-btn.active {
  background: var(--series-6);
  border-color: var(--series-6);
  color: #ffffff;
  font-weight: 600;
}

.calc-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 16px 0;
}

.calc-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

/* Karty wyników kalkulatora. Arkusz stylował dotąd `.calc-res-card`, a JS
   od dawna generuje `.calc-time-card` — wyniki wyświetlały się jako goły
   tekst rozsypany w kolumnach. */
.calc-time-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calc-time-card:has(.badge-recommended) {
  border-color: rgb(168 85 247 / 0.6);
  background: rgb(168 85 247 / 0.1);
}

.calc-time-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.calc-time-big {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.calc-badge {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.calc-badge.badge-optimal {
  color: var(--accent-success);
  background: rgb(16 185 129 / 0.15);
}

.calc-badge.badge-recommended {
  color: var(--accent-sleep);
  background: rgb(168 85 247 / 0.18);
}

.calc-badge.badge-good {
  color: var(--accent-info);
  background: rgb(56 189 248 / 0.15);
}

.calc-badge.badge-warning {
  color: var(--accent-warning);
  background: rgb(245 158 11 / 0.15);
}

.calc-time-label {
  font-size: var(--fs-md);
  color: var(--text-secondary);
  font-weight: 500;
}

.calc-time-sub {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.calc-wake-form > label {
  font-size: var(--fs-base);
  color: var(--text-secondary);
}

.calc-time-input {
  max-width: 140px;
  padding: 0.5rem 0.75rem;
  color-scheme: dark;
}

.calc-input-row .btn {
  min-height: var(--tap-min);
}

/* History List */
.sleep-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sleep-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  gap: 12px;
  transition: background var(--transition);
}

.sleep-history-item:hover {
  background: var(--bg-hover);
}

.item-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-date {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.item-times {
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.source-tag {
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
}

.item-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.item-duration {
  font-size: 1.05rem;
  font-weight: 700;
  color: #c4b5fd;
}

.item-phases-mini {
  display: flex;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.item-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-score {
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.85rem;
}

.badge-score.score-good { background: rgba(34, 197, 94, 0.2); color: #4ade80; }
.badge-score.score-fair { background: rgba(234, 179, 8, 0.2); color: #facc15; }
.badge-score.score-poor { background: rgba(239, 68, 68, 0.2); color: #f87171; }

/* ── 🌟 Training Readiness Hero Card ─────────────────────────── */
.readiness-hero-card {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(30, 27, 75, 0.95) 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
  position: relative;
  overflow: hidden;
}

.readiness-main-row {
  display: flex;
  align-items: center;
  gap: 24px;
}

.readiness-gauge-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.readiness-ring {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: conic-gradient(var(--score-color, #10b981) var(--score-pct, 0%), rgba(255, 255, 255, 0.08) var(--score-pct, 0%));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
  transition: all 0.5s ease;
}

.readiness-ring-inner {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.readiness-score-val {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}

.readiness-score-max {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.readiness-badge-tag {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.readiness-badge-prime {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.readiness-badge-good {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.readiness-badge-fatigued {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.readiness-badge-recovery {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.readiness-info-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-grow: 1;
}

.readiness-advice-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.readiness-today-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #38bdf8;
  font-weight: 700;
}

.readiness-advice-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

.readiness-advice-text {
  font-size: 0.95rem;
  color: #e2e8f0;
  line-height: 1.45;
  margin: 0;
}

.readiness-factors-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 4px;
}

.factor-item {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.factor-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 600;
}

.factor-name {
  color: var(--text-secondary);
}

.factor-pct {
  color: var(--text-primary);
  font-weight: 700;
}

.factor-bar {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.factor-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.factor-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 📊 Workload & ACWR Management Section ────────────────────── */
.workload-section-card {
  background: var(--bg-card);
  border-color: rgba(99, 102, 241, 0.25);
}

.acwr-status-pill {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid;
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.2);
}

.workload-summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.workload-metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.wm-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.wm-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
}

.wm-value small {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.wm-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.workload-chart-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.chart-legend-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-box {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
}

.legend-line {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}

.legend-zone {
  width: 14px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.workload-canvas {
  width: 100%;
  height: 240px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
}

/* Responsive Mobile */
@media (max-width: 768px) {
  .sleep-container {
    gap: 12px;
  }
  .sleep-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .sleep-header-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .readiness-main-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .readiness-gauge-box {
    flex-direction: row;
    width: 100%;
    justify-content: space-between;
    align-items: center;
  }
  .readiness-factors-grid {
    grid-template-columns: 1fr 1fr;
  }
  .workload-summary-row {
    grid-template-columns: 1fr;
  }
  .sleep-stats-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .sleep-card {
    padding: 14px;
    gap: 12px;
  }
  .sleep-trend-bars {
    gap: 3px;
  }
  .trend-bar-val {
    font-size: 0.55rem;
  }
  .trend-bar-unit {
    display: none;
  }
  .duration-big {
    font-size: 1.75rem;
  }
  .hero-recovery-metrics {
    grid-template-columns: 1fr 1fr;
  }
  .sleep-history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .item-center {
    align-items: flex-start;
  }
  .item-right {
    width: 100%;
    justify-content: space-between;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 6px;
  }
}

/* Telefon: trzy szybkie statystyki w jednym rzędzie zamiast trzech
   pełnych kart jedna pod drugą */
@media (max-width: 600px) {
  .sleep-header .page-title {
    font-size: 1.45rem;
  }

  .sleep-stats-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .sleep-stat-card {
    padding: 10px 8px;
  }

  .sleep-stat-card .stat-label {
    font-size: 0.68rem;
    line-height: 1.25;
  }

  .sleep-stat-card .stat-val {
    font-size: 1.1rem;
    white-space: nowrap;
  }

  .sleep-stat-card .stat-sub {
    font-size: 0.65rem;
  }

  .sleep-card {
    padding: 14px;
  }

  .sleep-trend-bars {
    gap: 3px;
  }

  .trend-bar-val {
    font-size: 0.55rem;
  }

  .calc-tabs {
    flex-wrap: wrap;
  }

  .calc-results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .calc-time-card {
    padding: 10px;
  }

  .calc-time-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .calc-time-big {
    font-size: 1.35rem;
  }
}
