/* ============================================
   SchmerzTrack - Rechner-Tools
   Kopfschmerztage-Zähler (hd-*) und Arztgespräch-Zettel (ds-*).
   Baut auf tools.css auf (Schritte, Chips, Regler, Zusammenfassung).
   ============================================ */

/* --- Gemeinsam --- */
.calc-warn {
  background: #fff4e0;
  border: 1px solid #e8c27a;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 15px;
}
.calc-redflags {
  border: 2px solid var(--color-charcoal);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin: 2rem 0;
  background: var(--color-white);
}
.calc-redflags h2,
.calc-redflags .h5 {
  margin-top: 0 !important;
  font-weight: 600;
}
.calc-table td,
.calc-table th {
  vertical-align: top;
  font-size: 15px;
}
.calc-table small {
  color: var(--color-text-muted);
}
.calc-sources li {
  margin-bottom: 6px;
  font-size: 15px;
}
.calc-app-bridge {
  margin-top: 2rem;
}

/* --- Kopfschmerztage: Kalender --- */
.hd-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 12px;
}
.hd-month {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  text-align: center;
  flex: 1 1 auto;
}
.hd-nav {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  background: var(--color-cream);
  border: 0;
}
.hd-weekdays,
.hd-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.hd-weekdays span {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  padding-bottom: 4px;
}
.hd-day {
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 40px;
  border: 1px solid var(--color-parchment);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  color: var(--color-text);
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 6px;
  line-height: 1;
}
.hd-day.is-blank {
  border: 0;
  background: transparent;
}
.hd-day:hover:not(:disabled) {
  border-color: var(--color-lavender);
}
.hd-day:focus-visible {
  outline: 2px solid var(--color-mysteria);
  outline-offset: 2px;
}
.hd-day.is-today {
  border: 2px solid var(--color-charcoal);
}
.hd-day.is-future {
  color: #b3afab;
  background: #faf9f7;
}
.hd-day.has-headache,
.hd-swatch.is-h {
  background: rgba(155, 81, 224, 0.22);
  border-color: var(--color-mysteria);
}
.hd-day.is-selected {
  box-shadow: 0 0 0 3px rgba(175, 115, 230, 0.55);
}
.hd-pill {
  position: absolute;
  right: 5px;
  bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  color: #5c2d91;
}
.hd-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 12px;
}
.hd-legend .btn-link {
  margin-left: auto;
  color: var(--color-link);
  padding: 0;
}
.hd-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--color-parchment);
  vertical-align: -3px;
  margin-right: 6px;
}
.hd-swatch-pill {
  color: #5c2d91;
  margin-right: 6px;
  font-weight: 700;
}
.hd-editor {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-parchment);
}
.hd-editor-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}
.hd-editor-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.hd-editor-actions .btn {
  min-height: 44px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* --- Kopfschmerztage: Auswertung --- */
.hd-result {
  border: 1px solid var(--color-parchment);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  background: var(--color-white);
  margin-bottom: 16px;
}
.hd-res-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 10px;
}
.hd-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 12px;
}
.hd-stats div {
  background: #f7f5f2;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.hd-stats dt {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  line-height: 1.25;
}
.hd-stats dd {
  font-size: 26px;
  font-weight: 600;
  margin: 2px 0 0;
}
.hd-rule-label {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.hd-bar {
  height: 8px;
  border-radius: 4px;
  background: #eeeae5;
  overflow: hidden;
}
.hd-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--color-lavender);
  transition: width 0.2s ease;
}
.hd-rule.is-over span,
.hd-groups li.is-over .hd-bar span {
  background: #b3261e;
}
.hd-groups {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}
.hd-groups li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  font-size: 14px;
  margin-bottom: 8px;
}
.hd-groups .hd-bar {
  grid-column: 1 / -1;
  height: 6px;
}
.hd-g-count {
  font-weight: 600;
}
.hd-light {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  border-left: 6px solid;
}
.hd-light.is-green {
  background: #edf7ee;
  border-color: #2e7d32;
}
.hd-light.is-yellow {
  background: #fff6e0;
  border-color: #c77800;
}
.hd-light.is-red {
  background: #fdecea;
  border-color: #b3261e;
}
.hd-light-label {
  font-weight: 700;
  margin-bottom: 4px;
}
.hd-light-msgs {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 14px;
  line-height: 1.45;
}
.hd-light-msgs li + li {
  margin-top: 4px;
}

/* Druckansicht: auf dem Bildschirm unsichtbar */
.hd-print {
  display: none;
}

/* --- Arztgespräch-Zettel --- */
.ds-progress {
  position: sticky;
  top: calc(var(--navbar-height) + 4px);
  z-index: 5;
  background: var(--color-white);
  border: 1px solid var(--color-parchment);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 16px;
  font-size: 14px;
}
.ds-progress .hd-bar {
  margin-top: 6px;
}
.ds-progress .hd-bar span {
  background: var(--color-mysteria);
}
.ds-med-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.ds-med-row .btn {
  min-height: 44px;
}
.ds-flag-hint {
  margin-top: 12px;
}
.ds-suggest .tool-chip > span {
  font-size: 14px;
}
.ds-sheet .summary-list dd {
  font-size: 14px;
}
.ds-sheet .ds-flag-note {
  font-size: 13px;
  border-top: 1px solid var(--color-parchment);
  padding-top: 8px;
  margin-top: 12px;
}
.ds-draft-note {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 8px;
}

@media (max-width: 575.98px) {
  .hd-grid,
  .hd-weekdays {
    gap: 4px;
  }
  .hd-day {
    padding: 4px;
    font-size: 14px;
  }
  .hd-stats dd {
    font-size: 22px;
  }
  .ds-med-row {
    grid-template-columns: 1fr;
  }
}

/* --- Druck --- */
@media print {
  @page {
    size: A4;
    margin: 12mm 14mm;
  }
  #mainNav,
  .site-footer,
  #cookieBanner,
  .d-print-none {
    display: none !important;
  }
  body {
    padding-top: 0 !important;
    font-size: 10pt;
  }
  .hd-print {
    display: block;
    color: #000;
  }
  .hd-print-head {
    border-bottom: 2px solid #000;
    margin-bottom: 4mm;
  }
  .hd-print-head h2 {
    font-size: 16pt;
    margin: 0;
  }
  .hd-print-head p {
    margin: 1mm 0 2mm;
    font-size: 9pt;
  }
  .hd-print-body {
    display: flex;
    gap: 6mm;
  }
  .hd-print-table {
    flex: 1 1 60%;
    border-collapse: collapse;
    font-size: 8.5pt;
  }
  .hd-print-table th,
  .hd-print-table td {
    border-bottom: 0.3mm solid #bbb;
    padding: 0.6mm 1.5mm;
    text-align: left;
  }
  .hd-print-table tr.is-h td {
    background: #ece2f7;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .hd-print-side {
    flex: 1 1 40%;
    font-size: 9pt;
  }
  .hd-print-side h3 {
    font-size: 10.5pt;
    margin: 0 0 2mm;
  }
  .hd-print-side ul {
    padding-left: 4mm;
    margin-bottom: 4mm;
  }
  .hd-print-note {
    font-size: 8pt;
    color: #444;
  }
  .hd-print .summary-foot {
    font-size: 8pt;
    margin-top: 3mm;
  }

  /* Arztzettel: nur der Zettel */
  .ds-sheet-wrap {
    position: static;
  }
  .ds-sheet {
    border: 0 !important;
    padding: 0 !important;
  }
  .ds-sheet .summary-list {
    column-count: 2;
    column-gap: 8mm;
  }
  .ds-sheet .summary-list dt {
    break-after: avoid;
    font-size: 7.5pt;
    margin-top: 2.5mm;
  }
  .ds-sheet .summary-list dd {
    break-inside: avoid;
    font-size: 9.5pt;
    line-height: 1.3;
  }
  .ds-sheet .summary-title {
    font-size: 15pt;
  }
  .ds-sheet .summary-figures {
    float: right;
    flex-direction: row;
    margin: 0 0 2mm 4mm;
  }
  .ds-sheet .summary-figures svg {
    width: 16mm;
  }
}

/* Lange Zusammenfassungen bleiben in der klebenden Spalte erreichbar. */
@media screen and (min-width: 992px) {
  .calc-scroll {
    max-height: calc(100vh - var(--navbar-height) - 32px);
    overflow-y: auto;
    padding-right: 4px;
  }
}
