/* ═══════════════════════════════════════════════════════════
   SEO Maker — standalone styles
   ═══════════════════════════════════════════════════════════ */
:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-2: #7c3aed;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

/* Class selectors below set display:flex/grid, which outranks the UA's [hidden]
   rule. Without this, every element toggled via .hidden stays on screen. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}

code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.muted { color: var(--ink-2); }
.sep { width: 1px; height: 18px; background: var(--line); display: inline-block; }

/* ── buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border-radius: 9px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer; white-space: nowrap;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 4px 14px rgba(37, 99, 235, .28); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(37, 99, 235, .38); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: #eef2f7; color: var(--ink); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }

/* ── storage warning ─────────────────────────────────────── */
.storage-warning {
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px 20px; background: #7f1d1d; color: #fff; font-size: 13px; line-height: 1.5;
}
.storage-warning code { background: rgba(255,255,255,.18); padding: 1px 5px; border-radius: 4px; }

/* ── topbar ──────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 800; letter-spacing: .5px;
  display: grid; place-items: center;
}
.brand-text h1 { margin: 0; font-size: 16px; font-weight: 700; }
.brand-text span { font-size: 12px; color: var(--ink-3); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.storage-pill {
  font-size: 11px; font-weight: 600; color: var(--ink-2);
  background: #f1f5f9; border: 1px solid var(--line);
  padding: 5px 9px; border-radius: 999px;
}
.storage-pill.warn { background: var(--warn-bg); color: #92400e; border-color: #fcd34d; }

/* ── layout ──────────────────────────────────────────────── */
.view { max-width: 1400px; margin: 0 auto; padding: 20px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.filters { padding: 20px; margin-bottom: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.panel-head h2 { margin: 0 0 4px; font-size: 19px; }
.panel-head p { margin: 0; color: var(--ink-2); font-size: 13px; }

.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-wrap { position: relative; flex: 1 1 240px; min-width: 240px; }
.search-wrap svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; fill: none; stroke: var(--ink-3); stroke-width: 2;
  pointer-events: none;
}

input[type=text], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 9px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
/* Must come after the shorthand above, or its `padding` resets our left inset
   and the magnifier icon sits on top of the placeholder text. */
.search-wrap input[type=search] { padding-left: 38px; }
/* Without this the selects inherit width:100% and each one wraps to its own row. */
.filter-row select { width: auto; flex: 0 0 auto; }

input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
select { min-width: 150px; cursor: pointer; }
textarea { resize: vertical; }
textarea.code, input.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.6; background: #0f172a; color: #e2e8f0;
  border-color: #1e293b;
}
textarea.code:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(124, 58, 237, .2); }

/* ── bulk bar ────────────────────────────────────────────── */
.bulkbar {
  display: flex; align-items: center; gap: 8px;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px; padding: 7px 10px;
}
.bulkbar span { font-size: 12px; font-weight: 700; color: #1d4ed8; }

/* ── table ───────────────────────────────────────────────── */
.table-panel { overflow: hidden; }
.pages-table { width: 100%; border-collapse: collapse; }
.pages-table thead th {
  text-align: left; padding: 13px 16px; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3);
  border-bottom: 1px solid var(--line); background: #fbfcfe;
}
.pages-table tbody td { padding: 14px 16px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.pages-table tbody tr:last-child td { border-bottom: none; }
.pages-table tbody tr:hover { background: #fafbfe; }
.col-check { width: 42px; }
.col-cat, .col-status, .col-score, .col-updated { width: 1%; white-space: nowrap; }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }

.page-cell-title { font-weight: 650; color: var(--ink); display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.page-cell-slug { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--ink-3); margin-top: 3px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700; padding: 3px 7px; border-radius: 6px; letter-spacing: .02em;
}
.badge-ld { background: #ede9fe; color: #6d28d9; }
.badge-ld.bad { background: var(--bad-bg); color: var(--bad); }
.badge-social { background: #e0f2fe; color: #0369a1; }
.badge-cat { background: #f1f5f9; color: var(--ink-2); }
.badge-status { padding: 5px 10px; border-radius: 999px; font-size: 11.5px; }
.badge-status.published { background: var(--ok-bg); color: #15803d; }
.badge-status.draft { background: #f1f5f9; color: var(--ink-2); }

.score { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; font-weight: 800; font-size: 12px; }
.score.good { background: var(--ok-bg); color: #15803d; }
.score.mid { background: var(--warn-bg); color: #92400e; }
.score.low { background: var(--bad-bg); color: var(--bad); }

.updated { font-size: 12px; color: var(--ink-2); }

.iconbtn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; cursor: pointer; display: inline-grid; place-items: center;
  transition: background .12s;
}
.iconbtn svg { width: 16px; height: 16px; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn:hover { background: #f1f5f9; }
.i-json  svg { stroke: var(--ok); }
.i-html  svg { stroke: #0891b2; }
.i-zip   svg { stroke: #c026d3; }
.i-edit  svg { stroke: var(--brand); }
.i-copy  svg { stroke: var(--ink-2); }
.i-del   svg { stroke: var(--bad); }

/* ── empty ───────────────────────────────────────────────── */
.empty { padding: 64px 24px; text-align: center; }
.empty-icon { font-size: 44px; margin-bottom: 10px; }
.empty h3 { margin: 0 0 6px; font-size: 17px; }
.empty p { margin: 0 auto 18px; color: var(--ink-2); max-width: 460px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ── editor ──────────────────────────────────────────────── */
.editor-head {
  position: sticky; top: 65px; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; margin-bottom: 16px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.editor-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.editor-title strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-state { font-size: 11.5px; color: var(--ink-3); }
.save-state.dirty { color: var(--warn); font-weight: 600; }
.editor-head-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.editor-body { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 16px; align-items: start; }
.editor-body.no-preview { grid-template-columns: minmax(0, 1fr); }
.editor-body.no-preview .editor-preview { display: none; }

.editor-form { background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.tabs { display: flex; gap: 2px; padding: 6px; background: #fbfcfe; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  padding: 9px 14px; border: none; background: transparent; border-radius: 9px;
  font: inherit; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.tab:hover { background: #eef2f7; }
.tab.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.tab .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand-2); display: inline-block; margin-left: 4px; }
.tab.active .dot { background: #fff; }

.tabpane { display: none; padding: 22px; }
.tabpane.active { display: block; }

.field { margin-bottom: 20px; }
.field > label { display: block; font-weight: 650; font-size: 13px; margin-bottom: 7px; }
.field > label b { color: var(--bad); }
.field small { display: block; margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.label-row label { font-weight: 650; font-size: 13px; }
.counter { font-size: 11.5px; font-weight: 700; color: var(--ink-3); }
.counter.ok { color: var(--ok); }
.counter.warn { color: var(--warn); }
.counter.bad { color: var(--bad); }
.row-inline { display: flex; gap: 8px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; cursor: pointer; margin-bottom: 20px; }
.checkbox input { width: 16px; height: 16px; }

.slug-wrap { display: flex; align-items: center; gap: 6px; }
.slug-wrap > span { color: var(--ink-3); font-family: ui-monospace, Menlo, monospace; }

.status-toggle { display: inline-flex; background: #f1f5f9; padding: 4px; border-radius: 10px; gap: 4px; }
.status-btn {
  padding: 7px 18px; border: none; background: transparent; border-radius: 7px;
  font: inherit; font-weight: 650; font-size: 13px; color: var(--ink-2); cursor: pointer;
}
.status-btn.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
#stPublished.active { background: var(--ok); color: #fff; }

/* ── wysiwyg ─────────────────────────────────────────────── */
.wysiwyg { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.wys-toolbar { display: flex; align-items: center; gap: 3px; padding: 6px; background: #fbfcfe; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.wys-toolbar button {
  min-width: 30px; height: 28px; padding: 0 8px; border: 1px solid transparent; background: transparent;
  border-radius: 6px; font: inherit; font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.wys-toolbar button:hover { background: #e2e8f0; color: var(--ink); }
.wys-editor { min-height: 300px; max-height: 560px; overflow-y: auto; padding: 16px; outline: none; }
.wys-editor:focus { background: #fdfdff; }
.wys-editor h1 { font-size: 24px; } .wys-editor h2 { font-size: 20px; } .wys-editor h3 { font-size: 17px; }
.wys-editor img { max-width: 100%; height: auto; }

/* ── preview cards ───────────────────────────────────────── */
.preview-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: #fbfcfe; margin-bottom: 20px; }
.preview-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 12px;
}
.serp { background: #fff; padding: 14px; border-radius: 9px; border: 1px solid var(--line); }
.serp-url { font-size: 12.5px; color: #3c4043; }
.serp-title { font-size: 19px; color: #1a0dab; line-height: 1.3; margin: 3px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.serp-desc { font-size: 13px; color: #4d5156; line-height: 1.45; }

.social-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.social-img {
  aspect-ratio: 1.91 / 1; background: #f1f5f9; display: grid; place-items: center;
  color: var(--ink-3); font-size: 12px; background-size: cover; background-position: center;
}
.social-img.has-img span { display: none; }
.social-body { padding: 11px 13px; border-top: 1px solid var(--line); }
.social-domain { font-size: 11px; color: var(--ink-3); text-transform: uppercase; }
.social-title { font-weight: 650; font-size: 14px; margin: 2px 0; }
.social-desc { font-size: 12.5px; color: var(--ink-2); }

.score-pill { padding: 3px 9px; border-radius: 999px; background: #f1f5f9; color: var(--ink-2); font-size: 12px; }
.score-pill.good { background: var(--ok-bg); color: #15803d; }
.score-pill.mid { background: var(--warn-bg); color: #92400e; }
.score-pill.low { background: var(--bad-bg); color: var(--bad); }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.checklist li { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.checklist .mark { flex: 0 0 auto; width: 15px; height: 15px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; color: #fff; margin-top: 2px; }
.checklist .pass .mark { background: var(--ok); }
.checklist .warn .mark { background: var(--warn); }
.checklist .fail .mark { background: var(--bad); }
.checklist .pass { color: var(--ink-2); }
.checklist .fail { color: var(--ink); font-weight: 600; }

/* ── json-ld ─────────────────────────────────────────────── */
.ld-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.ld-pill { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: #f1f5f9; color: var(--ink-3); }
.ld-pill.valid { background: var(--ok-bg); color: #15803d; }
.ld-pill.invalid { background: var(--bad-bg); color: var(--bad); }

.faq-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.faq-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; background: #fff; padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.faq-item .fields { display: flex; flex-direction: column; gap: 7px; }
.faq-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── live preview pane ───────────────────────────────────── */
.editor-preview {
  position: sticky; top: 138px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden;
}
.preview-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fbfcfe;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3);
}
.preview-devices { display: flex; gap: 4px; }
.dev { padding: 4px 9px; border: 1px solid var(--line); background: #fff; border-radius: 6px; font: inherit; font-size: 11px; font-weight: 600; color: var(--ink-2); cursor: pointer; text-transform: none; letter-spacing: 0; }
.dev.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.preview-frame-wrap { height: calc(100vh - 230px); min-height: 420px; overflow: auto; display: flex; justify-content: center; background: #eef2f7; }
#previewFrame { width: 100%; height: 100%; border: none; background: #fff; transition: width .18s ease; }

/* ── modals ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .5);
  display: grid; place-items: center; padding: 20px; backdrop-filter: blur(2px);
}
.modal {
  width: 100%; max-width: 640px; max-height: 88vh; display: flex; flex-direction: column;
  background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(15, 23, 42, .3);
}
.modal-sm { max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-x { border: none; background: transparent; font-size: 16px; cursor: pointer; color: var(--ink-3); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-body > p { margin-top: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }

.filedrop {
  display: block; padding: 28px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: 12px; color: var(--ink-2); background: #fbfcfe;
  transition: border-color .12s, background .12s;
}
.filedrop:hover, .filedrop.over { border-color: var(--brand); background: #eff6ff; }
.or { text-align: center; font-size: 12px; color: var(--ink-3); margin: 14px 0 10px; }

.cat-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.cat-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.cat-row input { font-size: 12.5px; padding: 8px 10px; }
.cat-row .uuid { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; }

/* ── toasts ──────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px; border-radius: 10px; background: var(--ink); color: #fff;
  font-size: 13px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  animation: slidein .2s ease;
}
.toast.ok { background: #15803d; }
.toast.err { background: var(--bad); }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } }

/* ── responsive ──────────────────────────────────────────── */
@media (max-width: 1180px) {
  .editor-body { grid-template-columns: minmax(0, 1fr); }
  .editor-preview { position: static; }
  .preview-frame-wrap { height: 520px; }
}
@media (max-width: 780px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .grid-2 { grid-template-columns: 1fr; }
  .col-cat, .col-score, .col-updated { display: none; }
  .editor-head { position: static; flex-wrap: wrap; }
  .cat-row { grid-template-columns: 1fr; }
}
