/* Plyndi Explore admin — plain CSS, no library. Teal #20C1C4 is Plyndi's brand accent. */

:root {
  --teal: #20C1C4;
  --teal-deep: #138A8D;
  --teal-soft: #E3F7F7;
  --ink: #111827;
  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --text: #0F172A;
  --text-2: #374151;
  --muted: #6B7280;
  --border: #E2E6EA;
  --danger: #DC2626;
  --danger-soft: #FDECEC;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --info-soft: #E0F2FE;

  /* Explore category accents, matched to the app (AppShell.swift plyndiViolet/Amber/Coral). */
  --cat-travel: #9366ED;
  --cat-hotels: #F5A633;
  --cat-lifestyle: #F26B6B;

  --radius: 12px;
  --gutter: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --teal-soft: #0F3536;
    --bg: #0B1015;
    --surface: #12181F;
    --text: #F3F4F6;
    --text-2: #B0BDCB;
    --muted: #8A96A3;
    --border: #243040;
    --danger-soft: #3A1414;
    --warn-soft: #3A2A0C;
    --info-soft: #0C2A3A;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}
main { max-width: 1120px; margin: 0 auto; padding: var(--gutter); outline: none; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 16px; margin: 0 0 12px; }
a { color: var(--teal-deep); }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px var(--gutter);
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--teal); color: #06282A; font-weight: 800; }
.topnav { display: flex; gap: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: 600 14px var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--teal); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #06282A; } /* white on #20C1C4 is ~2.3:1 */
.btn.primary:hover { background: #1BAFB2; border-color: #1BAFB2; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .switch input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--teal) 55%, transparent); outline-offset: 1px;
}

/* ---------- banners, toast ---------- */
.banner { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 10px var(--gutter); font-size: 14px; border-bottom: 1px solid var(--border); }
.banner.info { background: var(--info-soft); }
.banner.error { background: var(--danger-soft); color: var(--text); }
.banner.warn { background: var(--warn-soft); }
.banner ul { margin: 4px 0 0; padding-left: 18px; }
.inline-banner { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
.spinner { flex: none; width: 16px; height: 16px; margin-top: 2px; border-radius: 50%; border: 2px solid var(--teal); border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 50; max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

/* ---------- card list ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.list-head h1 { margin: 0; }
.list-tools { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.list-tools select { min-height: 36px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  border-left: 4px solid var(--border);
}
.row.status-live { border-left-color: #16A34A; }
.row.status-scheduled { border-left-color: #2563EB; }
.row.status-draft { border-left-color: var(--muted); }
.row.status-expired { border-left-color: var(--warn); opacity: 0.8; }
.row-main { min-width: 0; }
.row-title { font-weight: 650; color: var(--text); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title:hover { color: var(--teal-deep); }
.row-id { color: var(--muted); font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.clicks { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.clicks strong { font-size: 16px; color: var(--text); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; background: var(--bg); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.live { background: #DCFCE7; color: #166534; border-color: #BBF7D0; }
.badge.scheduled { background: #DBEAFE; color: #1E40AF; border-color: #BFDBFE; }
.badge.draft { background: var(--bg); color: var(--muted); }
.badge.expired { background: var(--warn-soft); color: var(--warn); border-color: #FDE68A; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #FDE68A; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.cat-travel { color: var(--cat-travel); }
.badge.cat-hotels { color: #B7791F; }
.badge.cat-lifestyle { color: var(--cat-lifestyle); }
@media (prefers-color-scheme: dark) {
  .badge.live { background: #0F2E1A; color: #86EFAC; border-color: #14532D; }
  .badge.scheduled { background: #10223F; color: #93C5FD; border-color: #1E3A8A; }
  .badge.expired, .badge.warn { border-color: #78350F; color: #FCD34D; }
  .badge.cat-hotels { color: var(--cat-hotels); }
}

/* ---------- switch ---------- */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span.track { position: relative; width: 44px; height: 26px; border-radius: 999px; background: #CBD2D9; transition: background 0.15s; flex: none; }
.switch span.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.15s; }
.switch input:checked + span.track { background: var(--teal); }
.switch input:checked + span.track::after { transform: translateX(18px); }
.switch input:disabled + span.track { opacity: 0.5; }
@media (prefers-color-scheme: dark) { .switch span.track { background: #3A4654; } }

/* ---------- editor layout ---------- */
.editor {
  display: grid; gap: 16px;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-areas: "top preview" "rest preview";
  align-items: start;
}
.editor-top { grid-area: top; }
.editor-rest { grid-area: rest; }
.preview-panel { grid-area: preview; position: sticky; top: 72px; }
@media (max-width: 860px) {
  .editor { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "preview" "rest"; }
  .preview-panel { position: static; }
}

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }
.panel:last-child { margin-bottom: 0; }
.editor-top .panel:last-child, .editor-rest .panel:last-child { margin-bottom: 0; }
/* minmax(0,1fr): an auto track would grow to the <select>'s longest option and overflow a phone. */
.editor-top, .editor-rest { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }
.panel, .preview-panel { min-width: 0; }
.editor-top .panel, .editor-rest .panel { margin-bottom: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

.field { display: grid; gap: 4px; margin-bottom: 12px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field > label, .field > .label { font-size: 13px; font-weight: 650; color: var(--text-2); }
.field .req { color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); }
.err { font-size: 12.5px; color: var(--danger); font-weight: 550; }
.err:empty { display: none; }
input[type=text], input[type=url], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text);
  font: 16px var(--font); /* 16px stops iOS Safari zooming on focus */
}
textarea { min-height: 72px; resize: vertical; line-height: 1.4; }
input[readonly] { background: var(--bg); color: var(--muted); }
.invalid input, .invalid select, .invalid textarea { border-color: var(--danger); }
.counter { font-size: 11.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented label { flex: 1 1 auto; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span { display: block; text-align: center; padding: 9px 10px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer; background: var(--surface); }
.segmented input:checked + span { background: var(--teal-soft); border-color: var(--teal); color: var(--teal-deep); }
.segmented input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--teal) 55%, transparent); }
@media (prefers-color-scheme: dark) { .segmented input:checked + span { color: var(--teal); } }

/* locale tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 0 -14px 12px; padding: 0 14px 2px; scrollbar-width: thin; }
.tab { flex: none; position: relative; padding: 7px 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font: 600 13px var(--font); cursor: pointer; }
.tab[aria-selected=true] { background: var(--teal); border-color: var(--teal); color: #06282A; }
.tab.filled:not([aria-selected=true]) { border-color: var(--teal); color: var(--teal-deep); }
.tab.has-error { border-color: var(--danger); }
.tab.has-error::after { content: ""; position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.tab .req { color: inherit; }

/* sticky save bar */
.savebar {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: 16px calc(var(--gutter) * -1) calc(var(--gutter) * -1);
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}
.savebar .spacer { flex: 1; }
.savebar .btn.primary { min-width: 120px; }

/* ---------- phone preview ---------- */
.preview-panel h2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.preview-panel select { width: auto; min-height: 32px; padding: 2px 8px; font-size: 13px; }
.phone-strip { display: flex; justify-content: center; gap: 12px; padding: 16px 12px; border-radius: var(--radius); background: #F2F2F7; overflow-x: auto; }
@media (prefers-color-scheme: dark) { .phone-strip { background: #000; } }
.preview-col { display: grid; gap: 6px; justify-items: center; flex: none; }
.preview-caption { font-size: 11px; color: var(--muted); text-align: center; }
.preview-notes { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 12.5px; }
.preview-notes li { padding: 6px 8px; border-radius: 8px; background: var(--bg); color: var(--text-2); }
.preview-notes li.warn { background: var(--warn-soft); color: var(--text); }

/* The card itself: ExploreView.swift feedCard(). Sizes are iOS points rendered as CSS px. */
.xcard {
  width: var(--card-w, 173px);
  background: #fff; color: #0F172A;
  border: 1px solid rgba(15, 23, 42, 0.08); border-radius: 16px; overflow: hidden;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-align: start;
}
@media (prefers-color-scheme: dark) {
  .xcard { background: #12181F; color: #fff; border-color: rgba(255,255,255,0.08); }
  .xcard .x-desc { color: #B0BDCB; }
}
.x-hero { position: relative; display: grid; place-items: center; overflow: hidden; }
.x-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.x-hero.placeholder { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 85%, transparent), color-mix(in srgb, var(--accent) 50%, transparent)); }
.x-hero .x-glyph { font-size: 32px; line-height: 1; color: rgba(255,255,255,0.9); }
.x-body { padding: 12px; display: grid; gap: 6px; }
.x-tagrow { display: flex; align-items: center; gap: 6px; color: var(--accent); min-width: 0; }
.x-tagrow .x-icon { font-size: 11px; flex: none; }
.x-tag { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.x-title { font-size: 15px; font-weight: 700; line-height: 20px; overflow-wrap: anywhere; }
.x-desc { font-size: 12px; line-height: 16px; color: #374151; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.x-cta { margin-top: 4px; display: flex; justify-content: center; align-items: center; gap: 4px; padding: 7px 8px; border-radius: 999px; background: #111827; color: #fff; font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (prefers-color-scheme: dark) { .x-cta { background: #F3F4F6; color: #111827; } }
.x-empty { color: #9CA3AF; font-style: italic; font-weight: 500; }

/* ---------- confirm dialog ---------- */
.confirm { border: none; border-radius: 16px; padding: 20px; width: min(420px, calc(100% - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.confirm::backdrop { background: rgba(15, 23, 42, 0.45); }
.confirm h2 { font-size: 17px; }
.confirm p { margin: 0 0 16px; color: var(--text-2); overflow-wrap: anywhere; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 420px) {
  :root { --gutter: 12px; }
  .topnav .btn { padding: 0 10px; }
  h1 { font-size: 20px; }
}
.savebar-errors { flex: 1 0 100%; max-height: 40vh; overflow-y: auto; }
.savebar-errors:empty { display: none; }
.savebar-errors .inline-banner { margin: 0; }
