/* ============================================
   SchmerzTrack - Schmerztagebuch im Browser
   Baut auf tools.css auf (Hero, Chips, Körperfigur, Ratgeber-Text).
   ============================================ */

/* Stufenfarben 0-10: ein Verlauf in der Markenfarbe, von fast weiß bis
   tiefes Violett. Text ab Stufe 6 hell. */
.d-l0 { --lv: #f4f1ec; --lv-ink: #292827; }
.d-l1 { --lv: #efe6f8; --lv-ink: #292827; }
.d-l2 { --lv: #e5d6f4; --lv-ink: #292827; }
.d-l3 { --lv: #d9c3ef; --lv-ink: #292827; }
.d-l4 { --lv: #cbaeea; --lv-ink: #292827; }
.d-l5 { --lv: #bd97e5; --lv-ink: #292827; }
.d-l6 { --lv: #a874dc; --lv-ink: #ffffff; }
.d-l7 { --lv: #9150cf; --lv-ink: #ffffff; }
.d-l8 { --lv: #7838b4; --lv-ink: #ffffff; }
.d-l9 { --lv: #5f2a93; --lv-ink: #ffffff; }
.d-l10 { --lv: #451c70; --lv-ink: #ffffff; }

.d-card {
  border: 1px solid var(--color-parchment);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  background: var(--color-white);
}
.d-h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 8px;
}
.d-muted {
  color: var(--color-text-muted);
  font-size: 14px;
}
.d-warn {
  background: #fff4e5;
  border: 1px solid #f0c98a;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 15px;
}

/* --- Eingabe --- */
.d-field {
  margin-bottom: 16px;
}
.d-levels {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 4px;
}
.d-level {
  position: relative;
  margin: 0;
  cursor: pointer;
}
.d-level input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.d-level span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: var(--radius-sm);
  background: var(--lv);
  color: var(--lv-ink);
  font-size: 18px;
  font-weight: 700;
  border: 2px solid transparent;
  transition: transform 0.1s ease;
}
.d-level:hover span {
  transform: translateY(-1px);
}
.d-level input:focus-visible + span {
  outline: 3px solid var(--color-charcoal);
  outline-offset: 2px;
}
.d-level input:checked + span {
  border-color: var(--color-charcoal);
  box-shadow: 0 0 0 2px var(--color-white) inset;
  transform: scale(1.08);
}
.d-level-scale {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
}
.d-level-out {
  font-weight: 600;
  margin: 6px 0 0;
  min-height: 1.5em;
}
.d-when-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.d-when-row .form-control,
.d-when-row .form-select {
  flex: 1 1 auto;
}
.d-when-row .btn {
  flex: 0 0 auto;
}

.d-more {
  border-top: 1px solid var(--color-parchment);
}
.d-more > summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 12px 0;
  cursor: pointer;
  list-style: none;
  min-height: 44px;
}
.d-more > summary::-webkit-details-marker {
  display: none;
}
.d-more > summary::before {
  content: "+";
  font-weight: 700;
  width: 16px;
  flex: 0 0 auto;
}
.d-more[open] > summary::before {
  content: "\2212";
}
.d-more-title {
  font-weight: 600;
  flex: 0 0 auto;
}
.d-more-sum {
  flex: 1 1 auto;
  text-align: right;
  color: var(--color-text-muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.d-more-body {
  padding: 0 0 16px;
}
.d-bm .bm-svg {
  max-width: 150px;
}
.d-sugg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.d-sugg {
  border: 1px solid var(--color-parchment);
  background: var(--color-white);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 14px;
}
.d-sugg:hover,
.d-sugg:focus-visible {
  border-color: var(--color-lavender);
}
.d-save-row {
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--color-parchment);
  padding-top: 16px;
}
.d-save-row .btn-dark {
  background: var(--color-charcoal);
  border-radius: var(--radius-sm);
  font-weight: 600;
  min-height: 48px;
  flex: 1 1 auto;
}
.d-status {
  margin: 10px 0 0;
  font-size: 15px;
  font-weight: 600;
  color: #3b6b2a;
}

/* --- Leerzustand und Beispiel --- */
.d-empty {
  background: rgba(175, 115, 230, 0.06);
}
.d-demo-banner {
  background: rgba(175, 115, 230, 0.12);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 15px;
}
.d-demo-banner .btn-link {
  color: var(--color-link);
  font-weight: 600;
  padding: 0 0 0 6px;
  vertical-align: baseline;
}

/* --- Kennzahlen und Grafik --- */
.d-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.d-stat {
  border: 1px solid var(--color-parchment);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}
.d-stat-num {
  display: block;
  font-size: 28px;
  font-weight: 540;
  line-height: 1.1;
}
.d-stat-label {
  display: block;
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.3;
}
.dc-svg {
  width: 100%;
  height: auto;
  display: block;
}
.dc-grid {
  stroke: #ece8e4;
  stroke-width: 1;
}
.dc-axis {
  font-size: 11px;
  fill: var(--color-text-muted, #6b6966);
}
.dc-bar {
  fill: var(--lv);
  stroke: rgba(41, 40, 39, 0.15);
  stroke-width: 0.5;
}
.dc-avg {
  fill: none;
  stroke: var(--color-charcoal, #292827);
  stroke-width: 1.6;
  stroke-linejoin: round;
}
.dc-none {
  stroke: #c9c3bd;
  stroke-width: 2;
}
.dc-med {
  fill: var(--color-link, #714cb6);
}
.d-legend {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 6px 0 0;
}
.d-key {
  display: inline-block;
  vertical-align: middle;
  margin: 0 4px 0 10px;
}
.d-key:first-child {
  margin-left: 0;
}
.d-key-bar {
  width: 10px;
  height: 12px;
  border-radius: 2px;
  background: #a874dc;
}
.d-key-line {
  width: 16px;
  height: 2px;
  background: var(--color-charcoal);
}
.d-key-med {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-link);
}
.d-contrast {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.d-contrast h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 4px;
}
.d-contrast ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 15px;
}

/* --- App-Hinweis --- */
.d-bridge {
  position: relative;
  border: 1px solid var(--color-lavender);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  background: rgba(175, 115, 230, 0.06);
}
.d-bridge .btn-close {
  position: absolute;
  top: 14px;
  right: 14px;
}
.d-bridge h2 {
  padding-right: 32px;
  font-weight: 600;
}
.d-bridge ul {
  font-size: 15px;
  padding-left: 1.1rem;
}

/* --- Liste --- */
.d-list-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.d-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.d-entry {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-parchment);
}
.d-entry:last-child {
  border-bottom: 0;
}
.d-entry-level {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--lv);
  color: var(--lv-ink);
  font-weight: 700;
  font-size: 18px;
}
.d-entry-when {
  margin: 0;
  font-weight: 600;
  font-size: 15px;
}
.d-entry-band {
  font-weight: 460;
  color: var(--color-text-muted);
  font-size: 13px;
  margin-left: 4px;
}
.d-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.d-tag {
  font-size: 12px;
  background: #f4f1ec;
  border-radius: 6px;
  padding: 2px 8px;
}
.d-entry-med,
.d-entry-note {
  margin: 4px 0 0;
  font-size: 14px;
}
.d-entry-note {
  color: var(--color-text-muted);
  white-space: pre-line;
}
.d-entry-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.d-entry-actions .btn-link,
#dShowAll {
  color: var(--color-link);
  padding: 2px 4px;
  font-size: 14px;
}

/* --- Daten --- */
.d-report-row {
  margin-bottom: 12px;
}
.d-report-row .btn-dark {
  background: var(--color-charcoal);
  border-radius: var(--radius-sm);
  font-weight: 600;
  min-height: 44px;
}
.d-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.d-actions .btn {
  min-height: 44px;
  font-weight: 600;
}
.d-local {
  font-size: 14px;
  color: var(--color-text-muted);
  margin: 14px 0 4px;
}
.d-danger {
  color: #a3262a;
  padding-left: 0;
  font-size: 14px;
}
.d-sources {
  font-size: 15px;
}

/* Bericht: auf dem Bildschirm nie sichtbar */
.diary-report {
  display: none;
}

@media (max-width: 575.98px) {
  .d-card {
    padding: 16px;
  }
  .d-levels {
    grid-template-columns: repeat(6, 1fr);
  }
  .d-level span {
    min-height: 52px;
  }
  .d-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .d-contrast {
    grid-template-columns: 1fr;
  }
  .d-entry {
    grid-template-columns: 40px 1fr;
  }
  .d-entry-level {
    width: 40px;
    height: 40px;
  }
  .d-entry-actions {
    grid-column: 2;
    flex-direction: row;
    justify-content: flex-start;
  }
}

/* --- Druck: Bericht für den Arzt, A4 --- */
@media print {
  @page {
    size: A4;
    margin: 14mm 14mm 12mm;
  }
  #mainNav,
  .site-footer,
  #cookieBanner,
  .d-print-none {
    display: none !important;
  }
  body {
    padding-top: 0 !important;
    font-size: 10pt;
    color: #000;
  }
  .diary-report {
    display: block;
  }
  .dr-head {
    border-bottom: 2px solid #292827;
    padding-bottom: 3mm;
    margin-bottom: 4mm;
  }
  .dr-title {
    font-size: 18pt;
    font-weight: 600;
    margin: 0;
  }
  .dr-sub,
  .dr-name {
    margin: 1mm 0 0;
    font-size: 10pt;
  }
  .diary-report h3 {
    font-size: 11pt;
    font-weight: 700;
    margin: 5mm 0 2mm;
  }
  .dr-facts {
    width: 100%;
    border-collapse: collapse;
  }
  .dr-facts th,
  .dr-facts td {
    border-bottom: 0.3mm solid #ccc;
    padding: 1.2mm 2mm 1.2mm 0;
    vertical-align: top;
    text-align: left;
  }
  .dr-facts th {
    width: 42%;
    font-weight: 600;
  }
  .dr-chart .dc-svg {
    width: 100%;
    max-height: 70mm;
  }
  .dr-legend {
    font-size: 8.5pt;
    color: #444;
    margin: 1mm 0 0;
  }
  .dr-note {
    margin: 5mm 0 1mm;
    font-weight: 600;
  }
  .dr-lines {
    height: 22mm;
    background: repeating-linear-gradient(to bottom, transparent 0, transparent 6.8mm, #bbb 6.8mm, #bbb 7.1mm);
  }
  .dr-page2 {
    break-before: page;
    page-break-before: always;
  }
  .dr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 8.5pt;
  }
  .dr-table thead {
    display: table-header-group;
  }
  .dr-table th,
  .dr-table td {
    border: 0.3mm solid #bbb;
    padding: 1mm 1.5mm;
    text-align: left;
    vertical-align: top;
  }
  .dr-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .dr-num {
    text-align: center !important;
    font-weight: 700;
  }
  .dr-foot {
    margin-top: 6mm;
    font-size: 8pt;
    color: #444;
    border-top: 0.3mm solid #ccc;
    padding-top: 2mm;
  }
  .dc-bar,
  .dc-med,
  .dc-avg {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

.d-when-row .btn-link,
.d-save-row .btn-link {
  color: var(--color-link);
}
.d-when-row .form-control,
.d-when-row .form-select {
  min-width: 0;
  width: auto;
}
@media (max-width: 575.98px) {
  .d-when-row {
    flex-wrap: wrap;
  }
  .d-when-row .form-control,
  .d-when-row .form-select {
    flex-basis: 100%;
  }
  .d-when-row .btn-link {
    padding-left: 0;
  }
}
