/* ==============================================
   EMOBO – Global Stylesheet
   Mobile-first: iPhone + iPad optimiert
   ============================================== */

/* ---- CSS-Variablen ---- */
:root {
  --c-primary:    #0077b6;
  --c-secondary:  #00b4d8;
  --c-accent:     #0096c7;
  --c-bg:         #f0f4f8;
  --c-surface:    #ffffff;
  --c-text:       #1e293b;
  --c-muted:      #64748b;
  --c-border:     #e2e8f0;
  --c-danger:     #dc2626;
  --nav-h:        64px;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow-sm:    0 1px 4px rgba(0,0,0,0.07);
  --shadow:       0 2px 10px rgba(0,0,0,0.09);
  --shadow-lg:    0 6px 24px rgba(0,0,0,0.13);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  touch-action: manipulation;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               Helvetica, Arial, sans-serif;
  background: linear-gradient(160deg, #e8cbc0 0%, #c9d6e8 50%, #9eafd4 100%) fixed;
  color: var(--c-text);
  line-height: 1.6;
  margin: 0;
  /* Navbar-Abstand */
  padding-top: var(--nav-h);
  /* iPhone-Notch / Home-Bar */
  padding-left:   env(safe-area-inset-left,   0px);
  padding-right:  env(safe-area-inset-right,  0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-overflow-scrolling: touch;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-accent); }

img { max-width: 100%; height: auto; }

/* ---- Layout ---- */
#body_inhalt {
  min-height: calc(100vh - var(--nav-h) - 80px);
  padding: 0;
}

/* ---- Karten ---- */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--c-surface);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--c-border);
  font-weight: 600;
}

/* ---- Buttons – mind. 44 px Touch-Target ---- */
.btn {
  min-height: 44px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  padding: 0.55rem 1.25rem;
  font-size: 1rem;
  transition: background 0.18s, box-shadow 0.18s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--c-accent);
  border-color: var(--c-accent);
}

.btn-outline-primary { border-color: var(--c-primary); color: var(--c-primary); }
.btn-outline-primary:hover { background: var(--c-primary); color: #fff; }

/* ---- Formulare ---- */
.form-control,
.form-select {
  min-height: 44px;
  border-radius: var(--radius-sm);
  border-color: var(--c-border);
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--c-secondary);
  box-shadow: 0 0 0 3px rgba(0,180,216,0.18);
  outline: none;
}

.form-label { font-weight: 500; color: var(--c-text); margin-bottom: 0.3rem; }

/* ---- Breadcrumb ---- */
.breadcrumb {
  background: transparent;
  padding: 0;
  font-size: 0.875rem;
  flex-wrap: wrap;
}

.breadcrumb-item + .breadcrumb-item::before { color: var(--c-muted); }

.breadcrumb-item a {
  color: var(--c-primary);
  font-weight: 500;
}

/* ---- Tabellen ---- */
.table {
  font-size: 0.93rem;
  color: var(--c-text);
}

.table > :not(caption) > * > * { padding: 0.65rem 0.75rem; }

/* ---- Alerts ---- */
.alert { border-radius: var(--radius-sm); border: none; font-size: 0.95rem; }

/* ---- Footer ---- */
footer.app-footer {
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  color: var(--c-muted);
  font-size: 0.82rem;
  padding: 1.2rem 1rem;
  text-align: center;
  margin-top: 3rem;
}

/* ---- Container-Abstände ---- */
.container-fluid { padding-left: 16px; padding-right: 16px; }

/* ---- Decodierungs-Banner ---- */
.deco-banner {
  background: linear-gradient(180deg, #e6f4fb 0%, #f7fbff 55%, #fff 100%);
  border-bottom: 2px solid rgba(0,180,216,0.45);
  padding: 0.6rem 0 0.55rem;
  position: fixed;
  top: var(--nav-h);
  left: 0; right: 0;
  z-index: 900;
  box-shadow: 0 4px 14px rgba(0,119,182,0.10);
}

.deco-banner-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 52px;
}

/* Links: Symptom */
.deco-left {
  flex-shrink: 0;
  padding-right: 1rem;
  border-right: 1px solid var(--c-border);
  min-width: 140px;
  max-width: 200px;
}

/* Mitte: Pfad */
.deco-center {
  flex: 1;
  text-align: center;
}

/* Rechts: Sitzungsübersicht */
.deco-right {
  flex-shrink: 0;
  padding-left: 1rem;
  border-left: 1px solid var(--c-border);
  min-width: 120px;
  text-align: right;
}

/* Labels */
.deco-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-muted);
  font-weight: 700;
}

.deco-symptom-text {
  font-size: 0.9rem;
  color: var(--c-text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pfad-Schritte */
.deco-path-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.deco-step-dim {
  font-size: 0.82rem;
  color: #b0bec5;
  font-weight: 500;
}

.deco-step-parent {
  font-size: 0.95rem;
  color: var(--c-muted);
  font-weight: 600;
}

.deco-sep {
  color: var(--c-muted);
  font-size: 0.85rem;
  line-height: 1;
}

.deco-sep-big {
  color: var(--c-secondary);
  font-size: 1.1rem;
  font-weight: 700;
}

.deco-step-current {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--c-primary);
  letter-spacing: -0.2px;
  line-height: 1.1;
}

/* BFC: Satz-Info über dem Breadcrumb */
.bfc-satz-banner {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
  line-height: 1.35;
  max-width: 520px;
  word-break: break-word;
}
.bfc-badge {
  font-size: 0.78rem;
  font-weight: 500;
  color: #64748b;
  white-space: nowrap;
}

/* Kleines Breadcrumb darunter */
.deco-breadcrumb-small {
  font-size: 0.7rem;
  color: #b0bec5;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deco-breadcrumb-small a {
  color: #94a3b8;
  text-decoration: none;
}

.deco-breadcrumb-small a:hover { color: var(--c-primary); }
.deco-breadcrumb-small .bc-sep { margin: 0 3px; color: #cbd5e1; }
.deco-breadcrumb-small .bc-active { color: var(--c-muted); }

/* Sitzungsübersicht-Details */
.deco-right details summary {
  font-size: 0.78rem;
  color: var(--c-primary);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  white-space: nowrap;
}

.deco-right details summary::-webkit-details-marker { display: none; }
.deco-right details summary::before { content: "▸ "; }
.deco-right details[open] summary::before { content: "▾ "; }

.deco-right details[open] {
  position: absolute;
  right: 16px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-lg);
  z-index: 950;
  width: min(440px, calc(100vw - 32px));
  font-size: 0.82rem;
  color: var(--c-text);
  max-height: 70vh;
  overflow-y: auto;
}

/* ---- Protokoll-Übersicht UI (Dropdown im Banner) ---- */
.proto-items {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.proto-nested {
  margin-left: 0.9rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--c-border);
  margin-top: 0.35rem;
  gap: 0.35rem;
}

.proto-item {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.proto-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.proto-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--c-text);
  line-height: 1.3;
}

.proto-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Kategorie-Badges */
.proto-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 20px;
  flex-shrink: 0;
  line-height: 1.5;
}
.kat-symptom      { background: #fee2e2; color: #b91c1c; }
.kat-bodycode     { background: #dbeafe; color: #1d4ed8; }
.kat-emotionscode { background: #ede9fe; color: #6d28d9; }
.kat-beliefcode   { background: #fef3c7; color: #92400e; }
.kat-balance      { background: #dcfce7; color: #166534; }
.kat-default      { background: #f1f5f9; color: #475569; }

/* Info-Tags unter dem Titel */
.proto-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding-left: calc(8px + 0.45rem); /* Breite dot + gap */
}

.proto-d0 .proto-tags {
  padding-left: 0; /* Bei depth=0 mit Badge fängt tags weiter links an */
}

.proto-tag {
  font-size: 0.71rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1px 7px;
  color: #475569;
  line-height: 1.5;
}
.proto-tag-emo  { background: #fdf2f8; border-color: #f0abfc; color: #9d174d; }
.proto-tag-note { background: #fffbeb; border-color: #fde68a; color: #78350f; }

/* Mobile Anpassung */
@media (max-width: 767px) {
  .deco-left { display: none; }
  .deco-right { min-width: auto; border-left: none; padding-left: 0; }
  .deco-step-current { font-size: 1.1rem; }
  .deco-step-parent { font-size: 0.82rem; }
  .deco-breadcrumb-small { display: none; }
  .deco-banner-inner { gap: 0.5rem; }
}

/* ---- Banner-Aktions-Buttons ---- */
.deco-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.45rem;
  flex-wrap: wrap;
}

.btn-deco {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.12s;
  white-space: nowrap;
  min-height: 32px;
}

.btn-deco:hover { opacity: 0.85; transform: translateY(-1px); }
.btn-deco:active { transform: translateY(0); }

/* Abbrechen → Orange-Warnung */
.btn-deco-abort {
  background: #ff8c42;
  color: #fff;
}

/* Fortsetzen → Grün */
.btn-deco-resume {
  background: #22c55e;
  color: #fff;
}

/* Weiter → Blau */
.btn-deco-continue {
  background: var(--c-primary, #0077b6);
  color: #fff;
}

/* Verwerfen → Rot */
.btn-deco-discard {
  background: transparent;
  color: var(--c-danger);
  border: 1.5px solid var(--c-danger);
}

.btn-deco-discard:hover {
  background: var(--c-danger);
  color: #fff;
  opacity: 1;
}

/* ---- Pause-Banner (unterbrochene Sitzung) ---- */
.deco-banner-pause {
  background: linear-gradient(90deg, #fff8ee 0%, #fff 100%);
  border-bottom: 2px solid #ff8c42;
  box-shadow: 0 4px 14px rgba(255,140,66,0.12);
}

.deco-pause-inner {
  justify-content: space-between;
  padding: 0.5rem 0;
}

.deco-pause-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.deco-pause-icon {
  font-size: 1.6rem;
  color: #ff8c42;
  flex-shrink: 0;
}

.deco-pause-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.deco-pause-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #ff8c42;
}

.deco-pause-symptom {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--c-text);
}

.deco-pause-time {
  font-size: 0.72rem;
  color: var(--c-muted);
}

.deco-pause-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .deco-pause-inner { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .deco-pause-actions { width: 100%; }
  .btn-deco { flex: 1; justify-content: center; }
}

/* ---- Produkt-Karten (Decodierung) ---- */
.deco-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.8rem 1rem 1.5rem;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  cursor: pointer;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.deco-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.deco-card:active { transform: scale(0.97); }

.deco-card > img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 50%;
  margin-bottom: 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.deco-card h5 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--c-text);
  margin: 0;
  line-height: 1.3;
}

.deco-card .stretched-link { z-index: 5; }

/* ---- Editor-Modus ---- */
.editor-banner {
  background: #fef9c3; border-bottom: 2px solid #fbbf24;
  padding: .55rem 1.2rem; font-size: .88rem; font-weight: 600; color: #78350f;
  display: flex; align-items: center; gap: .5rem;
}
.deco-card-edit-bar {
  position: relative; z-index: 10;
  display: flex; gap: 6px; justify-content: center;
  margin-top: .5rem;
}
.deco-edit-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: #e5e7eb; color: #374151; font-size: .75rem;
  text-decoration: none; transition: background .15s;
}
.deco-edit-btn:hover { background: #d1d5db; color: #111; }
.deco-delete-btn { background: #fee2e2; color: #b91c1c; }
.deco-delete-btn:hover { background: #fecaca; }
.editor-modus-aktiv { background: #fef3c7 !important; }
.deco-card-ursprung { margin-top: 0.6rem; position: relative; z-index: 10; text-align: center; }
.etsy-button {
  position: relative; z-index: 10;
  display: inline-flex !important; align-items: center; gap: 4px;
  padding: 2px 9px;
  font-size: 0.68rem; font-weight: 500;
  color: #fff !important;
  background: #4b5563 !important;
  border: none;
  border-radius: 999px;
  text-decoration: none !important;
  white-space: nowrap;
  transition: background 0.15s;
}
.etsy-button:hover { background: #374151 !important; }
.etsy-button img { width: 11px !important; height: 11px !important; border-radius: 0 !important; box-shadow: none !important; margin: 0 !important; opacity: 0.85; }

/* ---- Badges ---- */
.badge { font-size: 0.75rem; border-radius: 6px; }

/* ---- Mobile ---- */
@media (max-width: 575px) {
  :root { --nav-h: 60px; }

  body { font-size: 0.95rem; }

  .deco-card { min-height: 120px; padding: 1.4rem 0.75rem 1.2rem; }
  .deco-card img { width: 64px; height: 64px; }
  .deco-card h5 { font-size: 0.9rem; }
}

/* ---- Tablet (iPad) ---- */
@media (min-width: 768px) and (max-width: 1024px) {
  .deco-card { min-height: 150px; }
}

/* ---- Debug-Tabelle (in debug panel) ---- */
.debug-table {
  width: 100%;
  font-size: 0.73rem;
  color: #ffb703;
  border-collapse: collapse;
  margin-bottom: 10px;
}

.debug-table th, .debug-table td {
  border: 1px solid #333;
  padding: 3px 5px;
  vertical-align: top;
  word-break: break-all;
}

.debug-table th { background: #222; font-weight: 700; }
