/* Delade, generiska byggstenar för de nya sidorna (Restaurang, Hemsida,
   Kommunikation, Gäster, Ditt konto). Bygger vidare på tokens/knappar/fält
   som redan finns i theme.css — duplicerar inte dem. */

/* ---- Generisk rad (specialdagar, personal, fakturor m.m.) ---- */
.list-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 4px;
  border-bottom: 1px solid rgba(22, 22, 22, .06);
}

.list-row:last-child { border-bottom: 0; }
.list-row .row-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.list-row .row-title { font-size: 13px; font-weight: 650; letter-spacing: -.01em; }
.list-row .row-subtitle { color: var(--text-secondary); font-size: 11px; }
.list-row .row-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

/* ---- Avatar/monogram (samma stil som restaurant-monogram i headern) ---- */
.avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: #343432;
  font-size: 12px;
  font-weight: 650;
}

.avatar.avatar-lg { width: 52px; height: 52px; border-radius: 14px; font-size: 16px; }

/* ---- Badge/tag ---- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 9px;
  border-radius: 8px;
  color: var(--text-secondary);
  background: var(--surface-hover);
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

.tag.tag-green { color: var(--green); background: var(--green-soft); }
.tag.tag-brand { color: var(--brand-end); background: var(--brand-soft); }
.tag.tag-danger { color: var(--danger); background: var(--danger-soft); }
.tag.tag-quiet { height: 18px; padding: 0 7px; color: var(--text-tertiary); background: var(--surface-subtle); font-size: 9px; vertical-align: 1px; }

/* ---- Sektionsrubrik med värde/status till höger ---- */
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.section-head > div { min-width: 0; }

/* ---- Inline-formulär i en inställningssektion (t.ex. ny personal) ---- */
.inline-form {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}
/* Fälten ligger på samma ton som formulärets egen bakgrund — ge dem
   sidans yta så de syns som fält. */
.inline-form .field input,
.inline-form .field select,
.inline-form .field textarea { background: var(--surface); }
.inline-form .settings-actions { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 0; }
.inline-form .form-error:empty { display: none; }
.form-hint { margin: var(--space-3) 0 0; color: var(--text-tertiary); font-size: 10px; line-height: 1.5; }

.staff-list { margin-top: var(--space-4); }

/* ---- Sökfält ---- */
.search-field { position: relative; display: flex; align-items: center; }
.search-field .lucide-icon { position: absolute; left: 12px; color: var(--text-tertiary); pointer-events: none; }
.search-field input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 36px;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-subtle);
  font-size: 13px;
}
.search-field input::placeholder { color: var(--text-tertiary); }

/* ---- Öppettider: en rad per veckodag ---- */
.day-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 12px 4px;
  border-bottom: 1px solid rgba(22, 22, 22, .06);
}

.day-row:last-child { border-bottom: 0; }
.day-row .day-name { flex: 0 0 96px; padding-top: 4px; font-size: 13px; font-weight: 650; }
.day-row.day-off .day-name { color: var(--text-tertiary); }
.day-row .day-intervals { flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; }
.time-interval { display: flex; align-items: center; gap: 6px; }
.time-interval input[type="time"] { height: 36px; padding: 0 9px; border: 0; border-radius: var(--radius-sm); background: var(--surface-subtle); color: var(--text); font-size: 12px; }
.time-interval span { color: var(--text-tertiary); font-size: 11px; }
.time-interval .icon-button { width: 28px; height: 28px; }
.time-interval .icon-button .lucide-icon { width: 15px; height: 15px; }
.day-off-label { padding-top: 8px; color: var(--text-tertiary); font-size: 11px; font-style: italic; }
.add-interval-btn { align-self: flex-start; margin-top: 2px; }

/* ---- Bildkakel (omslagsbild, logotyp, galleri) ---- */
.image-tile-grid { display: flex; flex-wrap: wrap; gap: var(--space-3); }

.image-tile {
  position: relative;
  width: 132px;
  height: 92px;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}

.image-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-tile .image-tile-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(20, 20, 20, .55);
  cursor: pointer;
}

.image-tile .image-tile-remove .lucide-icon { width: 13px; height: 13px; }
.image-tile.image-tile-add {
  display: grid;
  place-items: center;
  gap: 3px;
  border: 1.5px dashed rgba(22, 22, 22, .16);
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 650;
  cursor: pointer;
  background: transparent;
}
.image-tile.image-tile-add:hover { background: var(--surface-subtle); border-color: rgba(22, 22, 22, .28); }
.image-tile.image-tile-add .lucide-icon { width: 20px; height: 20px; }

/* ---- Enkla val-kort (t.ex. bokningswidget-alternativ, abonnemangsplaner) ---- */
.choice-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-3); }

.choice-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-4);
  border: 1.5px solid rgba(22, 22, 22, .08);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  cursor: pointer;
  text-align: left;
}

.choice-card.selected { border-color: var(--brand-end); background: var(--brand-soft); }
.choice-card .choice-card-title { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 650; }
.choice-card .choice-card-desc { margin: 0; color: var(--text-secondary); font-size: 11px; line-height: 1.5; }
.choice-card .lucide-icon.check { color: var(--brand-end); }

/* ---- Kodruta (för widget-embed-exempel) ---- */
.code-box {
  overflow-x: auto;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #1c1c1b;
  color: #eae8e3;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.6;
  white-space: pre;
}

/* ---- Drawer (sidopanel) — bygger på .booking-dialog för form/backdrop-stil ---- */
.drawer-dialog {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  width: min(430px, 100vw);
  height: 100%;
  max-height: 100%;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.drawer-dialog[open] { animation: drawer-in .22s cubic-bezier(.16, 1, .3, 1); }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-dialog form { display: flex; flex-direction: column; height: 100%; padding: var(--space-5); }
.drawer-body { flex: 1 1 auto; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }

/* ---- Sammanfattning överst i gästkortet ---- */
.drawer-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.drawer-stat {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}
.drawer-stat strong { font-size: 18px; font-weight: 650; letter-spacing: -.03em; }
.drawer-stat span { color: var(--text-secondary); font-size: 10px; }

.drawer-textarea {
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}

/* Namnet är ingången till gästprofilen — visa att det går att klicka. */
.data-table tbody tr:hover .guest-name-cell { text-decoration: underline; text-underline-offset: 3px; }

/* ---- Enkel tabell (gästlistan) ---- */
.data-table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; border-radius: var(--radius-md); }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { position: sticky; top: 0; padding: 10px 12px; color: var(--text-tertiary); background: var(--surface); font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; text-align: left; border-bottom: 1px solid rgba(22, 22, 22, .08); }

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  transition: color .15s ease;
}
.th-sort:hover { color: var(--text); }
.th-sort .sort-icon { font-size: 14px; color: var(--text-tertiary); opacity: .45; transition: opacity .15s ease, color .15s ease, transform .15s ease; }
.th-sort:hover .sort-icon { opacity: .75; }
.th-sort.active { color: var(--text); }
.th-sort.active .sort-icon { color: var(--text); opacity: 1; }
.data-table td { padding: 12px; border-bottom: 1px solid rgba(22, 22, 22, .06); vertical-align: middle; }
.data-table tbody tr { cursor: pointer; transition: background .15s ease; }
.data-table tbody tr:hover { background: var(--surface-subtle); }
.data-table .guest-name-cell { display: flex; align-items: center; gap: 10px; font-weight: 650; }

@media (max-width: 700px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { padding: 10px 4px; border-bottom: 1px solid rgba(22, 22, 22, .08); }
  .data-table td { border-bottom: 0; padding: 2px 8px; }
  .data-table td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 96px; color: var(--text-tertiary); font-size: 9px; font-weight: 700; text-transform: uppercase; }
}


/* ---- Laddningsskelett ------------------------------------------------
   Ligger direkt i sidans HTML så att något syns innan JavaScript hunnit
   hämta data. Renderingen skriver över det. Samma shimmer som kalendern. */
.page-loading { display: grid; gap: var(--space-3); padding: var(--space-5); }
.page-loading .bar {
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(100deg, #f7f7f5 20%, #fbfbfa 42%, #f7f7f5 65%);
  background-size: 220% 100%;
  animation: shimmer 1.4s infinite;
}
.page-loading .bar.title { width: 180px; height: 22px; }
.page-loading .bar.wide { width: 100%; }
.page-loading .bar.half { width: 52%; }
.page-loading .bar.block { height: 64px; }
@media (prefers-reduced-motion: reduce) {
  .page-loading .bar { animation: none; }
}

/* ---- Fel som går att försöka igen från ---- */
.error-state { display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-6); text-align: center; }
.error-state .material-symbols-rounded { color: var(--text-tertiary); font-size: 32px; }
.error-state strong { font-size: 14px; }
.error-state p { max-width: 320px; margin: 0; color: var(--text-secondary); font-size: 11px; line-height: 1.6; }

@media (max-width: 560px) {
  .inline-form { padding: var(--space-3); }
  .inline-form .settings-actions { flex-direction: column-reverse; align-items: stretch; }
  .drawer-summary { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .drawer-stat { padding: 8px 10px; }
  .drawer-stat strong { font-size: 15px; }
  .section-head { flex-direction: column; gap: var(--space-2); }
}

/* ---- Telefonnummer med flagga i stället för landskod ---- */
.phone-flag { margin-right: 7px; font-size: 13px; line-height: 1; }
.phone-number { font-variant-numeric: tabular-nums; white-space: nowrap; }
