/* Shared patient-portal component styles — card / btn / meta / err /
   pill / info / row / table / lbl.

   Loads AFTER portal_base.css (structural) so component rules can
   reference the same --border, --muted, --ink, --err tokens. The
   project-specific stylesheet (linked from each app's `head_extra`)
   loads AFTER this file and can still override.

   Single source of truth for what zahlung.* (rz_praxis_portal_legacy
   Flask app) AND mein.*/d/ + mein.*/p/ (consolidated unified app)
   render with. Was previously inlined into
   rz_praxis/templates/portal/_base.html; extracted 2026-05-25 so
   both apps render identically. */

:root {
  --card: #ffffff;
  --accent: #1d4ed8;
  --accent-soft: #eef2ff;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 16px 0 8px; }
h3 { font-size: 16px; margin: 0 0 4px; }

.meta { color: var(--muted); font-size: 14px; }
.strong { font-weight: 600; }

.row {
  display: flex; justify-content: space-between;
  padding: 6px 0; border-bottom: 1px dashed var(--border);
}
.row:last-child { border-bottom: 0; }
.row .lbl { color: var(--muted); }

table {
  width: 100%; border-collapse: collapse;
  margin-top: 12px; font-size: 14px;
}
th, td {
  text-align: start; padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}
th { background: var(--accent-soft); font-weight: 600; }
td.r, th.r { text-align: end; }

.btn {
  display: inline-block;
  padding: 12px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  font-size: 16px;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn.primary:hover { filter: brightness(0.95); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.pill.ok   { background: #dcfce7; color: var(--ok); }
.pill.warn { background: #fef3c7; color: var(--warn); }

.info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  color: #1e3a8a;
  margin: 12px 0;
}
.err {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 16px;
  color: var(--err);
}

code { font-family: "SF Mono", "Cascadia Code", monospace; font-size: 13px; }

/* ───────────────────────────────────────────────────────────────────
   Gallery + thumbnails — used by mein.*/d/<token>/gallery (consolidated
   xray portal) and the future consolidated invoice attachment view.
   Extracted 2026-05-25 from Xray_server/app/static/style.css lines
   128-260 + 386-414. Single source so both portals look the same.
   ─────────────────────────────────────────────────────────────────── */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.thumb {
  margin: 0;
  background: #0b0f14;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.thumb img {
  width: 100%;
  height: 220px;
  object-fit: contain;
  display: block;
  background: #000;
}

.thumb figcaption {
  background: var(--card);
  padding: 0.75rem 0.9rem;
  font-size: 0.9rem;
}

.thumb .meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  margin-bottom: 0.4rem;
}

.btn-download {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  background: var(--ink);
  color: #fff;
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.85rem;
}
.btn-download:hover { filter: brightness(1.1); }

/* Selectable variant — adds the checkbox + selection outline. */
.thumb.selectable { position: relative; transition: transform .12s ease, box-shadow .12s ease; }
.thumb.selectable:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.thumb.selected { outline: 3px solid var(--accent); outline-offset: -3px; }

.thumb-select {
  position: absolute;
  top: 0.55rem; inset-inline-start: 0.55rem;
  z-index: 2;
  cursor: pointer;
  user-select: none;
}
.thumb-select input { position: absolute; opacity: 0; pointer-events: none; }

.check-box {
  display: block;
  width: 26px; height: 26px;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--border);
  border-radius: 5px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.check-box::after {
  content: "";
  position: absolute;
  top: 4px; inset-inline-start: 8px;
  width: 6px; height: 12px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform .12s ease;
}
.thumb-select input:checked + .check-box {
  background: var(--accent);
  border-color: var(--accent);
}
.thumb-select input:checked + .check-box::after { transform: rotate(45deg) scale(1); }

.thumb-image { display: block; }

/* Sticky toolbar at the bottom of the gallery for bulk actions. */
.select-bar {
  position: sticky;
  bottom: 0;
  margin-top: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  box-shadow: 0 6px 18px rgba(0,0,0,.06);
  z-index: 5;
}
.select-bar-count { font-weight: 500; color: var(--ink); }
.select-bar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.select-bar .btn-primary,
.select-bar .btn-secondary {
  padding: 0.5rem 0.95rem;
  font-size: 0.92rem;
  margin: 0;
  border-radius: 5px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.select-bar .btn-primary {
  background: var(--accent);
  color: white;
}
.select-bar .btn-primary:hover:not(:disabled) { filter: brightness(1.05); }
.select-bar .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.select-bar .btn-secondary {
  background: #e5e7eb;
  color: var(--ink);
}
.select-bar .btn-secondary:hover { background: #d1d5db; }

/* CT volume tiles — slightly distinct from regular 2D image tiles. */
.thumb.ct-tile { position: relative; }
.ct-badge {
  position: absolute;
  top: 6px;
  inset-inline-start: 6px;
  background: rgba(13, 110, 253, 0.92);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
  pointer-events: none;
}
.ct-download {
  background: var(--accent);
  color: white;
  font-weight: 600;
}
.ct-download:hover { filter: brightness(1.05); }
.ct-size {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.85;
}

/* ── Directional back-navigation affordance ─────────────────────────────
   The arrow glyph lives HERE, not baked into translation strings or link
   text, so it auto-mirrors in RTL: ← in LTR, → in Arabic (where the line
   starts at the right edge). Add class="back-link" to any "back / up to
   overview" link; the visible text stays direction-agnostic. Loaded on
   every patient surface via _shared/portal_base.html. */
.back-link::before {
  content: "\2190";          /* ← LEFTWARDS ARROW */
  margin-inline-end: 0.35em;
}
[dir="rtl"] .back-link::before,
body.rtl .back-link::before {
  content: "\2192";          /* → RIGHTWARDS ARROW — points to the RTL line start */
}
