/*
 * «Кабинет ресторана → Промокоды / Посты» (marketing.js). Только токены YOI (--yoi-*): светлая и тёмная темы
 * меняют токены, а не эти правила. Промокод нарисован купоном с отрывной линией — так же, как гость видит его
 * в разделе «Акции» на странице ресторана: сотрудник сразу понимает, что получит гость.
 */

.mk { display: block; }
.mk-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── вкладки ── */
.mk-tabs { display: flex; gap: 4px; padding: 4px; margin: 0 0 20px; border-radius: 14px; background: var(--yoi-surface-2); width: max-content; max-width: 100%; overflow-x: auto; }
.mk-tabs button { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 10px; background: transparent;
  color: var(--yoi-muted); font: inherit; font-weight: 650; font-size: 15px; cursor: pointer; white-space: nowrap; touch-action: manipulation; }
.mk-tabs button:hover { color: var(--yoi-text); }
.mk-tabs button[aria-selected="true"] { background: var(--yoi-surface); color: var(--yoi-text); box-shadow: 0 1px 2px rgba(41, 37, 31, .08), 0 0 0 1px var(--yoi-border); }
.mk-tabs button:focus-visible { outline: none; box-shadow: var(--yoi-focus); }
.mk-count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--yoi-green-light); color: var(--yoi-green-dark);
  font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }

/* ── полоса над списком ── */
.mk-note { margin: 0 0 14px; color: var(--yoi-muted); font-size: 14px; line-height: 1.5; max-width: 70ch; }
.mk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-bottom: 16px; }
.mk-bar .mk-note { margin: 0; }
.mk-grow { flex: 1 1 320px; }
.mk-new { margin-left: auto; }
.mk-search { position: relative; flex: 1 1 220px; max-width: 320px; }
.mk-search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--yoi-muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.mk-search input { width: 100%; min-height: 44px; padding: 0 12px 0 38px; border: 1px solid var(--yoi-border); border-radius: 12px; background: var(--yoi-surface);
  color: var(--yoi-text); font: inherit; }
.mk-search input:focus { outline: none; border-color: var(--yoi-green); box-shadow: var(--yoi-focus); }
.mk-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.mk-filters button { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--yoi-border); background: var(--yoi-surface); color: var(--yoi-text);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.mk-filters button[aria-pressed="true"] { background: var(--yoi-green-light); border-color: var(--yoi-green); color: var(--yoi-green-dark); }
.mk-filters button:focus-visible { outline: none; box-shadow: var(--yoi-focus); }

/* ── состояния ── */
.mk-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.mk-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.mk-pill-green { background: var(--yoi-green-light); color: var(--yoi-green-dark); }
.mk-pill-gray { background: var(--yoi-surface-2); color: var(--yoi-muted); }
.mk-pill-amber { background: var(--yoi-amber-soft, #F6EBDD); color: var(--yoi-amber); }
.mk-pill-blue { background: var(--yoi-blue-soft, #E4EEF4); color: var(--yoi-blue); }
.mk-meta { margin: 0; color: var(--yoi-muted); font-size: 13.5px; }
.mk-danger { color: var(--yoi-red) !important; }

/* ── купон промокода ── */
.mk-coupons { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 14px; }
.mk-coupon { --mk-stub: var(--yoi-green-light); position: relative; display: grid; grid-template-columns: 120px 14px 1fr; min-height: 168px;
  border: 1px solid var(--yoi-border); border-radius: 16px; background: var(--yoi-surface); overflow: hidden; }
.mk-coupon.mk-is-off, .mk-coupon.mk-is-ended { --mk-stub: var(--yoi-surface-2); }
.mk-coupon-stub { display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 16px 12px 16px 16px; background: var(--mk-stub); }
.mk-coupon-stub b { font-size: 26px; line-height: 1.05; font-weight: 800; letter-spacing: -.01em; color: var(--yoi-green-dark); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mk-coupon-stub b.mk-l2 { font-size: 20px; }
.mk-coupon-stub b.mk-l3 { font-size: 16px; }
.mk-is-off .mk-coupon-stub b, .mk-is-ended .mk-coupon-stub b { color: var(--yoi-muted); }
.mk-coupon-stub small { font-size: 12.5px; line-height: 1.3; color: var(--yoi-muted); }
/* Отрывная линия: пунктир и две выемки, как у бумажного купона. */
.mk-coupon { --mk-hole: var(--yoi-bg); }
.mk-coupon-tear { position: relative;
  background: radial-gradient(circle at 50% 0, var(--mk-hole) 7px, transparent 7.5px), radial-gradient(circle at 50% 100%, var(--mk-hole) 7px, transparent 7.5px),
    linear-gradient(90deg, var(--mk-stub) 50%, var(--yoi-surface) 50%); }
.mk-coupon-tear::before { content: ''; position: absolute; top: 14px; bottom: 14px; left: 50%; border-left: 2px dashed var(--yoi-border-strong); transform: translateX(-1px); opacity: .7; }
.mk-coupon-main { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 12px 6px; min-width: 0; }
.mk-coupon-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.mk-code { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 10px; border: 1px dashed var(--yoi-border-strong); border-radius: 10px;
  background: var(--yoi-field, var(--yoi-green-soft)); color: var(--yoi-text); font: inherit; font-weight: 800; font-size: 16px; letter-spacing: .06em; cursor: pointer; max-width: 100%; }
.mk-code svg { width: 16px; height: 16px; fill: none; stroke: var(--yoi-muted); stroke-width: 2; flex: none; }
.mk-code:hover { border-color: var(--yoi-green); }
.mk-code:hover svg { stroke: var(--yoi-green); }
.mk-code:focus-visible { outline: none; box-shadow: var(--yoi-focus); }
.mk-code-static { cursor: default; }
.mk-coupon-title { margin: 2px 0 0; font-size: 15px; font-weight: 650; line-height: 1.35; color: var(--yoi-text); overflow-wrap: anywhere; }
.mk-usage { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--yoi-muted); }
.mk-bar-track { flex: 1; max-width: 140px; height: 6px; border-radius: 999px; background: var(--yoi-surface-2); overflow: hidden; }
.mk-bar-track span { display: block; height: 100%; border-radius: inherit; background: var(--yoi-green); }
.mk-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.mk-actions .mk-switch { margin-right: 4px; }

@media (max-width: 480px) {
  .mk-coupon { grid-template-columns: 96px 12px 1fr; }
  .mk-coupon-stub { padding: 14px 8px 14px 12px; }
  .mk-coupon-stub b { font-size: 21px; }
}

/* ── переключатель ── */
.mk-switch { position: relative; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.mk-switch input { position: absolute; opacity: 0; width: 44px; height: 26px; margin: 0; cursor: pointer; }
.mk-switch-track { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--yoi-border-strong); transition: background .18s ease; flex: none; }
.mk-switch-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, .25); transition: transform .18s ease; }
.mk-switch input:checked + .mk-switch-track { background: var(--yoi-green); }
.mk-switch input:checked + .mk-switch-track::after { transform: translateX(18px); }
.mk-switch input:focus-visible + .mk-switch-track { box-shadow: var(--yoi-focus); }
.mk-switch input:disabled + .mk-switch-track { opacity: .5; }
.mk-switch-row { font-size: 15px; }

/* ── посты ── */
.mk-posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.mk-post { display: flex; flex-direction: column; border: 1px solid var(--yoi-border); border-radius: 16px; background: var(--yoi-surface); overflow: hidden; }
.mk-post.mk-is-off .mk-post-media, .mk-post.mk-is-ended .mk-post-media { filter: grayscale(.85); opacity: .7; }
.mk-post-media { position: relative; aspect-ratio: 16 / 9; background: var(--yoi-surface-2); }
.mk-post-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mk-post-ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.mk-post-ph svg { width: 44px; height: 44px; fill: none; stroke: var(--yoi-border-strong); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mk-post-badge { position: absolute; left: 12px; top: 12px; padding: 4px 10px; border-radius: 999px; background: var(--yoi-green); color: var(--yoi-on-accent, #fff);
  font-style: normal; font-weight: 800; font-size: 13px; }
.mk-post-body { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 12px; flex: 1; }
.mk-post-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mk-post h3 { margin: 0; font-size: 17px; line-height: 1.3; color: var(--yoi-text); overflow-wrap: anywhere; }
.mk-post-sub { margin: 0; color: var(--yoi-muted); font-size: 14px; line-height: 1.4; }
.mk-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mk-chip { display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; border-radius: 8px; border: 1px dashed var(--yoi-green); color: var(--yoi-green-dark);
  font-weight: 750; font-size: 12.5px; letter-spacing: .05em; background: var(--yoi-green-light); }
.mk-chip-off { border-color: var(--yoi-border-strong); color: var(--yoi-muted); background: var(--yoi-surface-2); text-decoration: line-through; }

/* ── пусто и загрузка ── */
.mk-empty { grid-column: 1 / -1; padding: 40px 24px; border: 1px dashed var(--yoi-border-strong); border-radius: 16px; text-align: center; background: var(--yoi-surface); }
.mk-empty b { display: block; font-size: 18px; margin-bottom: 6px; color: var(--yoi-text); }
.mk-empty p { margin: 0 auto 16px; max-width: 52ch; color: var(--yoi-muted); line-height: 1.5; }
.mk-empty-sm { padding: 20px; }
.mk-empty-sm p { margin: 0 auto; }
.mk-skel { height: 168px; border-radius: 16px; background: linear-gradient(90deg, var(--yoi-surface-2), var(--yoi-surface), var(--yoi-surface-2)); background-size: 200% 100%; animation: mk-shine 1.2s linear infinite; }
.mk-skel-tall { height: 320px; }
@keyframes mk-shine { to { background-position: -200% 0; } }

/* ── окно редактора ── */
.mk-dialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 20px; background: var(--yoi-surface); color: var(--yoi-text);
  box-shadow: var(--yoi-shadow); overflow: hidden; display: flex; flex-direction: column; }
.mk-dialog:not([open]) { display: none; }
.mk-dialog-wide { width: min(1040px, calc(100vw - 32px)); }
.mk-dialog::backdrop { background: var(--yoi-scrim, rgba(41, 37, 31, .5)); }
.mk-dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 18px 20px 14px 24px; border-bottom: 1px solid var(--yoi-border); }
.mk-dlg-head h2 { margin: 0; font-size: 19px; line-height: 1.25; overflow-wrap: anywhere; }
.mk-x { width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--yoi-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.mk-x svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.mk-x:hover { background: var(--yoi-surface-2); color: var(--yoi-text); }
.mk-x:focus-visible { outline: none; box-shadow: var(--yoi-focus); }
.mk-dlg-body { overflow-y: auto; padding: 20px 24px 0; }
.mk-dlg-foot { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; margin: 8px -24px 0; padding: 14px 24px calc(14px + env(safe-area-inset-bottom));
  background: var(--yoi-surface); border-top: 1px solid var(--yoi-border); }
.mk-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; align-content: start; }
.mk-span2 { grid-column: 1 / -1; }
.mk-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.mk-field .yoi-label { margin: 0; }
.mk-field .yoi-input { width: 100%; min-height: 44px; }
.mk-field textarea.yoi-input { min-height: 120px; resize: vertical; line-height: 1.5; }
.mk-help { color: var(--yoi-muted); font-size: 13px; line-height: 1.4; }
.mk-code-input { font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.mk-unit { display: flex; align-items: stretch; }
.mk-unit .yoi-input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.mk-unit span { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--yoi-border); border-left: 0; border-radius: 0 12px 12px 0; background: var(--yoi-surface-2);
  color: var(--yoi-muted); font-weight: 650; }
.mk-seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--yoi-surface-2); }
.mk-seg label { position: relative; cursor: pointer; }
.mk-seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.mk-seg span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 9px; font-weight: 650; color: var(--yoi-muted); }
.mk-seg input:checked + span { background: var(--yoi-surface); color: var(--yoi-text); box-shadow: 0 0 0 1px var(--yoi-border); }
.mk-seg input:focus-visible + span { box-shadow: var(--yoi-focus); }
.mk-link { padding: 0; border: 0; background: none; color: var(--yoi-green-dark); font: inherit; font-weight: 650; text-decoration: underline; cursor: pointer; }

/* предпросмотр купона в редакторе */
.mk-preview { padding: 14px; border-radius: 16px; background: var(--yoi-surface-2); }
.mk-preview-label { display: block; margin-bottom: 10px; font-size: 13px; font-weight: 650; color: var(--yoi-muted); }
.mk-preview .mk-coupon { min-height: 104px; }
.mk-preview .mk-coupon { --mk-hole: var(--yoi-surface-2); }
.mk-preview .mk-coupon-main { justify-content: center; }

/* редактор поста: форма слева, карточка гостя справа */
.mk-post-editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.mk-post-preview { position: sticky; top: 0; padding: 14px; border-radius: 16px; background: var(--yoi-surface-2); }
.mk-upload { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.mk-upload-thumb { width: 128px; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--yoi-surface-2); border: 1px solid var(--yoi-border);
  display: flex; align-items: center; justify-content: center; color: var(--yoi-muted); font-size: 12px; text-align: center; }
.mk-upload-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mk-upload-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mk-upload-ctl .mk-help { flex-basis: 100%; }
.mk-file { position: relative; overflow: hidden; }
.mk-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.mk-pick { gap: 8px; }
.mk-pick-q { margin-bottom: 4px; }
.mk-pick-list { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; padding: 2px; }
.mk-pick-item { display: grid; grid-template-columns: 22px auto 1fr auto; align-items: center; gap: 10px; min-height: 48px; padding: 6px 12px; border: 1px solid var(--yoi-border);
  border-radius: 12px; background: var(--yoi-surface); cursor: pointer; }
.mk-pick-item[hidden] { display: none; }
.mk-pick-item:has(input:checked) { border-color: var(--yoi-green); background: var(--yoi-green-light); }
.mk-pick-item input { width: 18px; height: 18px; accent-color: var(--yoi-green); margin: 0; }
.mk-pick-code { font-weight: 800; letter-spacing: .05em; }
.mk-pick-desc { min-width: 0; color: var(--yoi-muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* карточка, как у гостя (светлая рама сайта — независимо от темы панели) */
.mk-guest { color: #29251F; }
.mk-guest-card { display: grid; gap: 0; border-radius: 16px; overflow: hidden; background: #fff; border: 1px solid #E5DFD4; }
.mk-guest-img { position: relative; aspect-ratio: 16 / 9; background: #F0EAE0; }
.mk-guest-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mk-guest-img i, .mk-guest-badge { position: absolute; left: 10px; top: 10px; padding: 3px 9px; border-radius: 999px; background: #2D803A; color: #fff; font-style: normal; font-weight: 800; font-size: 12px; }
.mk-guest-badge { position: static; justify-self: start; margin: 12px 12px 0; }
.mk-guest-text { display: grid; gap: 3px; padding: 12px 14px; }
.mk-guest-text b { font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.mk-guest-text small { color: #6D655A; font-size: 13.5px; }
.mk-guest-text em { color: #6D655A; font-style: normal; font-size: 12.5px; }
.mk-guest-body { margin: 0; padding: 0 14px 14px; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; max-height: 220px; overflow: auto; }
.mk-guest-codes { display: grid; gap: 8px; margin-top: 8px; padding: 10px 12px; border: 1px solid #E5DFD4; border-radius: 14px; background: #fff; }
.mk-guest-codes > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mk-guest-codes span { display: grid; min-width: 0; }
.mk-guest-codes code { font-family: inherit; font-weight: 900; font-size: 15px; line-height: 1.2; letter-spacing: .08em; }
.mk-guest-codes small { color: #6D655A; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-guest-codes b { padding: 8px 12px; border-radius: 10px; background: #2D803A; color: #fff; font-size: 13px; white-space: nowrap; }

@media (max-width: 860px) {
  .mk-post-editor { grid-template-columns: 1fr; }
  .mk-post-preview { position: static; }
}
@media (max-width: 640px) {
  .mk-dialog, .mk-dialog-wide { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .mk-dlg-body { padding: 16px 16px 0; }
  .mk-dlg-foot { margin: 8px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .mk-dlg-foot .yoi-btn { flex: 1; }
  .mk-form { grid-template-columns: 1fr; }
  .mk-new { width: 100%; margin-left: 0; }
  .mk-search { max-width: none; }
  .mk-tabs { width: 100%; }
  .mk-tabs button { flex: 1; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .mk-skel { animation: none; }
  .mk-switch-track, .mk-switch-track::after { transition: none; }
}

/* Вкладки-ссылки над страницами продвижения панели YOI (fragments/yoi-marketing :: tabs). */
.mk-tabs-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 10px; color: var(--yoi-muted);
  font-weight: 650; font-size: 15px; text-decoration: none; white-space: nowrap; }
.mk-tabs-links a:hover { color: var(--yoi-text); }
.mk-tabs-links a[aria-current="page"] { background: var(--yoi-surface); color: var(--yoi-text); box-shadow: 0 1px 2px rgba(41, 37, 31, .08), 0 0 0 1px var(--yoi-border); }
.mk-tabs-links a:focus-visible { outline: none; box-shadow: var(--yoi-focus); }
@media (max-width: 640px) { .mk-tabs-links a { flex: 1; justify-content: center; padding: 0 10px; } }
