/* =========================================================
   ZahnarztFlüsterer — Professional Medical UI
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:       #1a56db;
  --blue-light: #e8f0fe;
  --blue-dark:  #1241b1;
  --green:      #057a55;
  --green-bg:   #def7ec;
  --amber:      #c27803;
  --amber-bg:   #fdf6b2;
  --red:        #c81e1e;
  --red-bg:     #fde8e8;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-400:   #9ca3af;
  --gray-600:   #4b5563;
  --gray-800:   #1f2937;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --radius:     10px;
  --radius-sm:  6px;
  --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Header ── */
.app-header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 50;
}
.header-inner {
  max-width: 900px; margin: 0 auto;
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { font-size: 28px; line-height: 1; }
.brand h1 { font-size: 1.2rem; font-weight: 700; color: var(--gray-800); line-height: 1.2; }
.brand p  { font-size: .8rem; color: var(--gray-400); }

/* ── Main layout ── */
.main-content {
  max-width: 900px; margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex; flex-direction: column; gap: 20px;
}

/* ── Card ── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 28px 28px 24px;
  border: 1px solid var(--gray-200);
}

/* ── Section title ── */
.section-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.1rem; font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 20px;
}
.step-badge {
  background: var(--blue);
  color: #fff;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: .8rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ml-auto { margin-left: auto; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all .15s;
  line-height: 1;
  text-decoration: none;
}
.btn-primary {
  background: var(--blue); color: #fff;
  border-color: var(--blue);
}
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-outline {
  background: #fff; color: var(--blue);
  border-color: var(--blue);
}
.btn-outline:hover { background: var(--blue-light); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  font-size: 1.4rem; color: var(--gray-400); line-height: 1;
  padding: 2px;
}
.btn-icon:hover { color: var(--gray-800); }

/* ── Dropzone ── */
.dropzone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  background: var(--gray-50);
  padding: 40px 20px;
  transition: all .2s;
  cursor: pointer;
  text-align: center;
}
.dropzone.drag-over {
  border-color: var(--blue);
  background: var(--blue-light);
}
.dropzone-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.upload-icon { font-size: 3rem; line-height: 1; margin-bottom: 4px; }
.dropzone-label { font-size: 1rem; font-weight: 600; color: var(--gray-800); }
.dropzone-hint { font-size: .85rem; color: var(--gray-400); }
.dropzone-formats { font-size: .78rem; color: var(--gray-400); margin-top: 4px; }

/* ── Progress ── */
.progress-area {
  margin-top: 20px;
  padding: 20px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
}
.progress-info {
  display: flex; justify-content: space-between;
  font-size: .87rem;
  margin-bottom: 10px;
}
.filename { font-weight: 600; color: var(--gray-800); }
.status-text { color: var(--gray-400); }
.progress-bar-track {
  height: 6px; background: var(--gray-200);
  border-radius: 99px; overflow: hidden;
  margin-bottom: 16px;
}
.progress-bar-fill {
  height: 100%; background: var(--blue);
  border-radius: 99px;
  transition: width .4s ease;
}
.progress-steps {
  display: flex; gap: 0; justify-content: space-between;
}
.step-dot {
  font-size: .75rem; color: var(--gray-400);
  position: relative; padding-bottom: 0;
  display: flex; align-items: center;
}
.step-dot::before {
  content: '';
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--gray-200);
  margin-right: 5px;
  flex-shrink: 0;
}
.step-dot.active { color: var(--blue); font-weight: 600; }
.step-dot.active::before { background: var(--blue); }
.step-dot.done::before { background: var(--green); }
.step-dot.done { color: var(--green); }

/* ── Alert ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  margin-top: 12px;
}
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid #fca5a5; }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid #6ee7b7; }

/* ── Transcript ── */
.transcript-box {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  max-height: 360px;
  overflow-y: auto;
  font-size: .875rem;
  line-height: 1.8;
}
.utterance { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 4px 0; }
.utt-meta { display: flex; flex-direction: column; gap: 1px; }
.utt-speaker {
  font-weight: 700; font-size: .78rem;
  padding: 2px 7px; border-radius: 99px;
  white-space: nowrap; display: inline-block;
}
.speaker-A { background: #dbeafe; color: #1d4ed8; }
.speaker-B { background: #dcfce7; color: #15803d; }
.speaker-C { background: #fce7f3; color: #9d174d; }
.speaker-D { background: #fef3c7; color: #92400e; }
.utt-time  { font-size: .72rem; color: var(--gray-400); }
.utt-text  { color: var(--gray-800); }

/* ── Analysis ── */
.analysis-block {
  margin-bottom: 28px;
}
.analysis-block:last-child { margin-bottom: 0; }
.analysis-block h3 {
  font-size: 1rem; font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-200);
}

/* Doc grid */
.doc-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: .88rem;
}
.doc-row { display: contents; }
.doc-row:not(:last-child) .doc-label,
.doc-row:not(:last-child) .doc-value {
  border-bottom: 1px solid var(--gray-200);
}
.doc-label {
  background: var(--gray-50);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-600);
  padding: 11px 14px;
  display: flex; align-items: flex-start;
}
.doc-value {
  padding: 11px 14px;
  color: var(--gray-800);
  line-height: 1.55;
}

/* Billing table */
.table-wrapper { overflow-x: auto; }
.billing-table {
  width: 100%; border-collapse: collapse;
  font-size: .85rem;
}
.billing-table th {
  background: var(--gray-50);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
.billing-table td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: top;
  line-height: 1.45;
}
.billing-table tr:last-child td { border-bottom: none; }
.billing-table tr:hover td { background: var(--gray-50); }
.billing-table tr.row-forgotten td { background: #fffbeb; }
.billing-table tr.row-forgotten td:first-child { border-left: 3px solid var(--amber); }
.code-badge {
  font-family: monospace;
  font-weight: 700; font-size: .9rem;
  color: var(--gray-800);
  white-space: nowrap;
}
.forgotten-badge {
  display: inline-block;
  margin-left: 4px;
  font-size: .85rem;
  vertical-align: middle;
}
.go-tag {
  font-size: .72rem; font-weight: 700;
  padding: 2px 6px; border-radius: 4px;
  white-space: nowrap;
}
.go-GOÄ  { background: #dbeafe; color: #1e40af; }
.go-GOZ  { background: #d1fae5; color: #065f46; }
.go-BEMA { background: #f3e8ff; color: #6b21a8; }
.go-EBM  { background: #fce7f3; color: #9d174d; }

.col-begruendung { color: var(--gray-600); font-size: .82rem; max-width: 240px; }
.col-betrag { font-weight: 700; white-space: nowrap; }
.billing-total-row {
  display: flex; justify-content: flex-end; align-items: center;
  gap: 16px;
  margin-top: 14px;
  font-size: .9rem; font-weight: 600; color: var(--gray-600);
}
.billing-total {
  font-size: 1.2rem; font-weight: 800; color: var(--green);
}

/* Billing feedback buttons */
.row-fb-btns { display: flex; gap: 6px; white-space: nowrap; }
.fb-btn {
  border: 1px solid var(--gray-200);
  background: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 4px 8px;
  font-size: .85rem;
  transition: all .15s;
}
.fb-btn:hover { border-color: var(--gray-400); }
.fb-btn.active-ok    { background: var(--green-bg); border-color: var(--green); }
.fb-btn.active-wrong { background: var(--red-bg);   border-color: var(--red);   }

/* ── Feedback section ── */
.feedback-block {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--gray-200);
}
.feedback-block:last-child { border-bottom: none; margin-bottom: 0; }
.feedback-block h3 {
  font-size: .95rem; font-weight: 700;
  margin-bottom: 14px; color: var(--gray-800);
}
.star-rating { display: flex; gap: 4px; margin-bottom: 12px; }
.star {
  font-size: 1.8rem; cursor: pointer;
  color: var(--gray-200);
  background: none; border: none;
  line-height: 1;
  transition: color .12s, transform .1s;
  padding: 0;
}
.star.lit { color: #f59e0b; }
.star:hover { transform: scale(1.15); }
.textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: .88rem;
  resize: vertical;
  color: var(--gray-800);
  background: var(--gray-50);
}
.textarea:focus { outline: 2px solid var(--blue); border-color: transparent; }

/* Added codes */
.added-codes-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.added-code-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .87rem;
}
.added-code-item .code-badge { font-size: .87rem; }
.added-code-remove { margin-left: auto; cursor: pointer; color: var(--gray-400); font-size: 1rem; background: none; border: none; }
.added-code-remove:hover { color: var(--red); }

.feedback-actions { margin-top: 8px; display: flex; justify-content: flex-end; }

/* ── History panel ── */
.history-panel {
  position: fixed; top: 0; right: 0;
  width: 340px; height: 100vh;
  background: #fff;
  box-shadow: -4px 0 20px rgba(0,0,0,.1);
  z-index: 100;
  display: flex; flex-direction: column;
  border-left: 1px solid var(--gray-200);
}
.history-header {
  padding: 18px 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.history-header h2 { font-size: 1rem; font-weight: 700; }
.history-list { overflow-y: auto; flex: 1; }
.history-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
  transition: background .12s;
}
.history-item:hover { background: var(--gray-50); }
.history-item-name { font-weight: 600; font-size: .9rem; margin-bottom: 3px; }
.history-item-meta { font-size: .78rem; color: var(--gray-400); display: flex; gap: 8px; }
.status-pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px;
  font-size: .72rem; font-weight: 700;
}
.pill-done       { background: var(--green-bg);   color: var(--green); }
.pill-analyzing  { background: var(--blue-light);  color: var(--blue); }
.pill-transcribing { background: var(--amber-bg);  color: var(--amber); }
.pill-error      { background: var(--red-bg);      color: var(--red); }
.pill-uploaded   { background: var(--gray-100);    color: var(--gray-600); }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 440px; max-width: 95vw;
  overflow: hidden;
}
.modal-header {
  padding: 18px 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  padding: 16px 20px;
  display: flex; gap: 10px; justify-content: flex-end;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: .8rem; font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: .05em; }
.input {
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: var(--font);
  background: #fff;
  color: var(--gray-800);
}
.input:focus { outline: 2px solid var(--blue); border-color: transparent; }

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .card { padding: 18px 16px; }
  .doc-grid { grid-template-columns: 100px 1fr; }
  .billing-table th, .billing-table td { padding: 8px; }
  .col-begruendung { max-width: 140px; }
  .history-panel { width: 100%; }
}
