/* Парсер фидов — светлый SaaS-интерфейс. Собственная айдентика. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --sidebar: #14213d;
  --sidebar-hover: #1f2f52;
  --text: #1c2333;
  --muted: #667085;
  --border: #e3e8ef;
  --accent: #0f9d8f;          /* teal — отличается от золотого референса */
  --accent-dark: #0b7d72;
  --critical: #d92d20;
  --warning: #dc8a00;
  --recommendation: #2e7cc4;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
/* Атрибут hidden должен прятать элемент даже если у него задан display
   (иначе .loader с display:flex продолжает показывать спиннер в покое). */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.5; }

.layout { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 260px; background: var(--sidebar); color: #fff;
  display: flex; flex-direction: column; padding: 22px 16px;
  position: sticky; top: 0; height: 100vh; flex-shrink: 0;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; margin-bottom: 28px; }
.sidebar__logo { color: var(--accent); font-size: 24px; }
.sidebar__nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  color: #c7d0e0; text-decoration: none; padding: 11px 14px; border-radius: 9px;
  font-size: 15px; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-link.is-active { background: var(--accent); color: #fff; font-weight: 600; }
.sidebar__footer { margin-top: auto; color: #8a97b3; font-size: 12px; padding-top: 20px; }

/* ---------- Topbar (mobile) ---------- */
.topbar { display: none; align-items: center; gap: 12px; background: var(--sidebar); color: #fff; padding: 12px 16px; position: sticky; top: 0; z-index: 30; }
.topbar__brand { font-weight: 700; }
.burger { background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; }

/* ---------- Content ---------- */
.content { flex: 1; padding: 40px 48px; max-width: 1100px; }
.view { display: none; }
.view.is-active { display: block; }
h1 { font-size: 34px; margin: 0 0 8px; letter-spacing: -.5px; }
h2 { font-size: 20px; margin: 28px 0 12px; }
.lead { color: var(--muted); font-size: 16px; margin: 0 0 24px; max-width: 640px; }

/* ---------- Cards & forms ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 24px; }
.card--form { max-width: 560px; }
.tabs { display: inline-flex; background: #eef1f6; border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.tab { border: none; background: none; padding: 8px 18px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted); font-weight: 500; }
.tab.is-active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.tab-pane { display: none; }
.tab-pane.is-active { display: block; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.field span { color: var(--text); }
.field input[type=url], .field input[type=text], .field input[type=tel], .field input[type=email],
.field select, .field textarea, .field input[type=file] {
  border: 1px solid var(--border); border-radius: 9px; padding: 11px 13px; font-size: 15px; font-family: inherit;
  background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,157,143,.15); }
.field-row { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-end; }
.field--inline { min-width: 240px; }
.field--narrow { min-width: 160px; max-width: 200px; }
.field input:disabled { background: #f2f4f7; color: var(--muted); cursor: not-allowed; }
.field--checkbox { flex-direction: row; align-items: center; gap: 8px; }

/* Валидация формы */
.form-note { font-size: 13px; color: var(--muted); margin: 0 0 18px; }
.req { color: var(--critical); font-weight: 700; }
.field-error { color: var(--critical); font-size: 12px; margin-top: 4px; display: none; font-weight: 400; }
.field-error.is-visible { display: block; }
.field input.is-invalid, .field textarea.is-invalid { border-color: var(--critical); }
.field input.is-invalid:focus, .field textarea.is-invalid:focus { box-shadow: 0 0 0 3px rgba(217,45,32,.15); }

.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.btn { border: none; border-radius: 9px; padding: 11px 20px; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; font-family: inherit; transition: background .15s, opacity .15s; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); }
.btn--secondary { background: #1d2b4d; color: #fff; }
.btn--secondary:hover { opacity: .9; }
.btn--ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn--ghost:hover { background: rgba(15,157,143,.08); }
.btn:disabled { opacity: .55; cursor: default; pointer-events: none; }

/* ---------- Loader / alerts ---------- */
.loader { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 16px 0; }
.spinner { width: 18px; height: 18px; border: 3px solid #d7deea; border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { background: #fef3f2; border: 1px solid #fecdc9; color: var(--critical); padding: 12px 16px; border-radius: 9px; margin: 16px 0; }
.alert--success { background: #ecfdf3; border-color: #b7ead0; color: #0a7c4a; }

/* ---------- Summary ---------- */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat__value { font-size: 28px; font-weight: 700; }
.stat__label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat--critical .stat__value { color: var(--critical); }
.stat--warning .stat__value { color: var(--warning); }
.stat--recommendation .stat__value { color: var(--recommendation); }
.stat__label { display: flex; align-items: center; gap: 6px; }

/* Всплывающая подсказка (tooltip) */
.tip { position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; background: var(--warning); color: #fff;
  font-size: 11px; font-weight: 700; cursor: help; flex-shrink: 0; }
.tip:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.tip__bubble {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: 240px; background: #14213d; color: #fff; padding: 10px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 400; line-height: 1.4; text-align: left;
  box-shadow: 0 8px 24px rgba(16,24,40,.25); opacity: 0; visibility: hidden;
  transition: opacity .15s, visibility .15s; z-index: 50; pointer-events: none;
}
.tip__bubble::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #14213d;
}
.tip:hover .tip__bubble, .tip:focus .tip__bubble { opacity: 1; visibility: visible; }
@media (max-width: 860px) {
  .tip__bubble { left: 0; transform: none; }
  .tip__bubble::after { left: 8px; transform: none; }
}

/* ---------- FAQ ---------- */
.faq { max-width: 760px; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; margin-bottom: 12px; }
.faq summary { cursor: pointer; font-weight: 600; font-size: 16px; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "＋"; color: var(--accent); font-weight: 700; margin-right: 10px; }
.faq details[open] summary::before { content: "－"; }
.faq details p { color: var(--muted); margin: 10px 0 0; padding-left: 24px; }

/* ---------- Compare ---------- */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 8px; }
.compare-col-title { font-weight: 600; margin-bottom: 12px; }
@media (max-width: 860px) { .compare-grid { grid-template-columns: 1fr; } }

/* ---------- Ad-readiness ---------- */
.readiness { display: flex; align-items: center; gap: 18px; background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--accent); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.readiness--good { border-left-color: #12b76a; }
.readiness--mid { border-left-color: var(--warning); }
.readiness--low { border-left-color: var(--critical); }
.readiness__gauge { flex-shrink: 0; width: 76px; height: 76px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #f2f4f7; }
.readiness--good .readiness__gauge { background: #e7f7ef; }
.readiness--mid .readiness__gauge { background: #fff5e6; }
.readiness--low .readiness__gauge { background: #fef0ef; }
.readiness__num { font-size: 24px; font-weight: 700; }
.readiness--good .readiness__num { color: #12b76a; }
.readiness--mid .readiness__num { color: var(--warning); }
.readiness--low .readiness__num { color: var(--critical); }
.readiness__title { font-weight: 600; font-size: 16px; margin-bottom: 2px; }
.readiness__desc { color: var(--muted); font-size: 13px; }
.readiness__missing { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.readiness__mlabel { font-size: 12px; color: var(--muted); }
.miss-chip { background: #f2f4f7; border-radius: 20px; padding: 3px 10px; font-size: 12px; color: var(--text); }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter { border: 1px solid var(--border); background: #fff; border-radius: 20px; padding: 6px 14px; font-size: 13px; cursor: pointer; color: var(--muted); }
.filter.is-active { background: var(--sidebar); color: #fff; border-color: var(--sidebar); }

/* ---------- Issues table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.issues { width: 100%; border-collapse: collapse; font-size: 14px; }
.issues th { background: #f8fafc; text-align: left; padding: 12px 14px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.issues td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.issues tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge--critical { background: #fef3f2; color: var(--critical); }
.badge--warning { background: #fff7e6; color: var(--warning); }
.badge--recommendation { background: #eef6fd; color: var(--recommendation); }
.ids { color: var(--muted); font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-word; max-width: 220px; display: inline-block; }
.example { margin-top: 6px; }
.example summary { cursor: pointer; color: var(--accent); font-size: 12px; }
.example pre { background: #0f172a; color: #e2e8f0; padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 12px; margin: 6px 0 0; }

/* ---------- CTA ---------- */
.cta { background: linear-gradient(135deg, #14213d, #1d3a5f); color: #fff; border-radius: var(--radius); padding: 32px; margin: 32px 0; }
.cta h2 { color: #fff; margin-top: 0; }
.cta p { color: #c7d2e6; max-width: 560px; }

/* ---------- SEO ---------- */
.seo { margin-top: 40px; color: #3a4560; }
.seo p { max-width: 720px; color: var(--muted); }
.seo details { margin: 8px 0; }
.seo summary { cursor: pointer; font-weight: 500; }

/* ---------- Lang switch ---------- */
.lang-switch { display: inline-flex; gap: 2px; background: rgba(255,255,255,.12); border-radius: 8px; padding: 3px; }
.lang-switch button { background: none; border: none; color: inherit; padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; }
.lang-switch--desktop { position: absolute; top: 40px; right: 48px; background: #eef1f6; }
.lang-switch--desktop button { color: var(--muted); }
.lang-switch button.is-active { background: var(--accent); color: #fff; }

.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 25; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  /* Раскладка становится вертикальной: шапка сверху, контент под ней,
     сайдбар — выезжающая панель поверх (иначе он остаётся flex-колонкой). */
  .layout { display: block; }
  /* Никакой горизонтальной прокрутки: длинные строки не должны распирать экран. */
  html, body { overflow-x: hidden; }
  .layout, .content { max-width: 100%; }
  .sidebar { position: fixed; left: 0; top: 0; width: 82%; max-width: 320px; height: 100vh;
             transform: translateX(-100%); transition: transform .2s; z-index: 40; }
  .sidebar.is-open { transform: translateX(0); }
  .topbar { display: flex; }
  .content { padding: 24px 18px; }
  h1 { font-size: 26px; }
  .lang-switch--desktop { display: none; }
  .field-row { gap: 14px; }
  /* Переносим длинные строки (URL, идентификаторы, описания). */
  .ids, .issues td, .readiness__desc, .stat__label, .seo p, .faq details p {
    overflow-wrap: anywhere; word-break: break-word;
  }
  .card, .cta, .stat, .readiness, .table-wrap, .faq details { max-width: 100%; }
  /* Таблица → карточки */
  .issues thead { display: none; }
  .issues, .issues tbody, .issues tr, .issues td { display: block; width: 100%; }
  .issues tr { border-bottom: 8px solid var(--bg); padding: 6px 0; }
  .issues td { border: none; padding: 6px 14px; }
  .issues td::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
  .ids { max-width: 100%; }
}
