/* Покупка рекламы: окно покупки, выбор поста, корзина (см. _ad_buy.html, js/ad-buy.js). */

/* ── Окно покупки ── */
.abm-overlay {
  position: fixed; inset: 0; z-index: 1500;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(0, 0, 0, 0.45);
}
.abm-overlay[hidden], .abm-wh-overlay[hidden] { display: none; }
.abm {
  background: #fff; border-radius: 14px;
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  padding: 26px 28px 22px; box-sizing: border-box;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  animation: abmIn .2s cubic-bezier(.4, 0, .2, 1);
}
@keyframes abmIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.abm-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.abm-head h2 { font-size: 18px; font-weight: 700; color: #0e0e12; margin: 0 0 4px; }
.abm-channel { font-size: 13px; color: #6b7280; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.abm-close {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #f1f5f9; border: none; color: #64748b; font-size: 20px; line-height: 1; cursor: pointer;
  transition: background .15s, color .15s;
}
.abm-close:hover { background: #e2e8f0; color: #0e0e12; }

.abm-field { margin: 4px 0 12px; }
.abm-field label { display: block; font-size: 13px; color: #374151; margin-bottom: 6px; }
.abm-field select {
  width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 14px; background: #fff; color: #0e0e12; font-family: inherit;
}
.abm-price { font-size: 14px; color: #374151; margin-bottom: 10px; }
.abm-price strong { color: #2563eb; font-size: 16px; }
.abm-balance {
  font-size: 13px; line-height: 1.5; color: #64748b;
  margin-bottom: 16px; padding: 10px 12px; border-radius: 10px;
  background: #f8fafc; border: 1px solid #e2e8f0;
}
.abm-balance.is-short { color: #92400e; background: #fffbeb; border-color: #fde68a; }
.abm-balance b { font-weight: 700; }

.abm-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.abm-actions [hidden] { display: none; }
.abm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
  font-family: inherit;
}
.abm-btn:disabled { opacity: .6; cursor: default; }
.abm-btn-primary { background: #2563eb; color: #fff; border: 1.5px solid #2563eb; }
.abm-btn-primary:hover:not(:disabled) { background: #1d4ed8; border-color: #1d4ed8; }
.abm-btn-ghost { background: transparent; color: #374151; border: 1.5px solid #d1d5db; }
.abm-btn-ghost:hover:not(:disabled) { border-color: #2563eb; color: #2563eb; }
.abm-what {
  display: block; margin: 14px auto 0; padding: 4px 8px;
  background: none; border: none; color: #64748b; font-size: 12.5px;
  text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer;
}
.abm-what:hover { color: #2563eb; }

/* «Что за цифры?» */
.abm-wh-overlay {
  position: fixed; inset: 0; z-index: 1600;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(0, 0, 0, 0.5);
}
.abm-wh {
  position: relative; background: #fff; border-radius: 14px; width: 100%; max-width: 440px;
  padding: 24px 24px 18px; box-sizing: border-box; font-size: 14px; line-height: 1.55; color: #374151;
}
.abm-wh .abm-close { position: absolute; top: 14px; right: 14px; }
.abm-wh h3 { font-size: 17px; font-weight: 700; color: #0e0e12; margin: 0 40px 10px 0; }
.abm-wh p { margin: 0 0 10px; }
.abm-wh ul { margin: 0 0 12px; padding-left: 20px; }

/* ── Выбор поста ── */
.pp-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 16px; max-height: 260px; overflow-y: auto;
}
.pp-list[hidden], .pp-empty[hidden], .pp-tg-warning[hidden], .pp-waiting[hidden] { display: none; }
.pp-card {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border: 1px solid #e5e7eb; border-radius: 10px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.pp-card:hover { border-color: #93c5fd; background: #eff6ff; }
.pp-card:has(input:checked) { border-color: #2563eb; background: #eff6ff; }
.pp-card input { flex-shrink: 0; width: 16px; height: 16px; accent-color: #2563eb; margin: 0; }
.pp-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pp-name { font-size: 14px; font-weight: 600; color: #111827; overflow-wrap: anywhere; }
.pp-preview { font-size: 12px; color: #6b7280; overflow-wrap: anywhere; }

.pp-empty { margin-bottom: 16px; }
.pp-step { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.pp-num {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  background: #2563eb; color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.pp-step-title { font-size: 14px; font-weight: 600; color: #0e0e12; margin-bottom: 2px; }
.pp-step-desc { font-size: 12.5px; color: #64748b; line-height: 1.45; }
.pp-tg-warning {
  display: flex; gap: 9px; align-items: flex-start;
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px; font-size: 13px; color: #92400e;
}
.pp-tg-warning a { color: #92400e; font-weight: 700; }
.pp-bot-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; box-sizing: border-box; padding: 12px;
  background: #229ED9; color: #fff !important; border-radius: 10px;
  font-size: 14px; font-weight: 600; text-decoration: none !important;
  transition: background .15s;
}
.pp-bot-btn:hover { background: #1c8bc0; }
.pp-waiting {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 10px; font-size: 12.5px; color: #94a3b8;
}
.pp-spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #cbd5e1; border-top-color: #2563eb;
  animation: ppSpin .8s linear infinite;
}
@keyframes ppSpin { to { transform: rotate(360deg); } }

/* ── Кнопка «В корзину» на карточке каталога (рядом с сердечком) ── */
.cart-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; flex-shrink: 0;
  border: 1.5px solid #e2e8f0; border-radius: 9px; background: #fff;
  color: #64748b; font-size: 14px; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s, transform .1s;
}
.cart-btn:hover { color: #2563eb; border-color: #93c5fd; }
.cart-btn:active { transform: scale(0.92); }
.cart-btn.in-cart { color: #2563eb; border-color: #93c5fd; background: #eff6ff; }
.cart-btn .fa-check { display: none; }
.cart-btn.in-cart .fa-cart-plus { display: none; }
.cart-btn.in-cart .fa-check { display: inline-block; }
.cart-btn:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

/* ── Плашка корзины внизу страницы ── */
.cart-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 1200;
  display: flex; align-items: center; gap: 14px;
  width: calc(100% - 32px); max-width: 520px; box-sizing: border-box;
  padding: 10px 10px 10px 14px; border-radius: 16px;
  background: #0f172a; color: #fff; text-decoration: none;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
}
.cart-bar[hidden] { display: none; }
.cart-bar.bump { animation: cartBump .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes cartBump {
  0% { transform: translateX(-50%) scale(1); }
  40% { transform: translateX(-50%) scale(1.04); }
  100% { transform: translateX(-50%) scale(1); }
}
.cart-bar-ic {
  position: relative; flex-shrink: 0; width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.1); font-size: 17px;
}
.cart-bar-count {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; box-sizing: border-box;
}
.cart-bar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.cart-bar-title { font-size: 12.5px; color: #94a3b8; }
.cart-bar-sum { font-size: 17px; font-weight: 800; white-space: nowrap; }
.cart-bar-btn {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 16px; border-radius: 11px; background: #2563eb; color: #fff;
  font-size: 14px; font-weight: 600; transition: background .15s;
}
.cart-bar:hover .cart-bar-btn { background: #1d4ed8; }
/* Плашка не должна закрывать низ страницы: место под неё — внутри подвала,
   иначе под тёмным подвалом остаётся светлая полоса. */
body.has-cart-bar .footer { padding-bottom: 108px; }

/* ── Тёмная тема ── */
html.dark .abm, html.dark .abm-wh { background: #1a1a20; color: #e2e8f0; }
html.dark .abm-head h2, html.dark .abm-wh h3, html.dark .pp-step-title { color: #e2e8f0; }
html.dark .abm-wh { color: #cbd5e1; }
html.dark .abm-close { background: #25252e; color: #94a3b8; }
html.dark .abm-close:hover { background: #2f2f3a; color: #e2e8f0; }
html.dark .abm-field label, html.dark .abm-price { color: #94a3b8; }
html.dark .abm-field select { background: #25252e; border-color: rgba(255, 255, 255, 0.1); color: #e2e8f0; }
html.dark .abm-balance { background: #1e1e28; border-color: rgba(255, 255, 255, 0.08); color: #94a3b8; }
html.dark .abm-balance.is-short { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.3); color: #fcd34d; }
html.dark .abm-btn-ghost { color: #cbd5e1; border-color: rgba(255, 255, 255, 0.15); }
html.dark .abm-btn-ghost:hover:not(:disabled) { border-color: #60a5fa; color: #60a5fa; }
html.dark .abm-overlay, html.dark .abm-wh-overlay { background: rgba(0, 0, 0, 0.7); }
html.dark .pp-card { border-color: rgba(255, 255, 255, 0.1); }
html.dark .pp-card:hover, html.dark .pp-card:has(input:checked) { background: #1e2a3a; border-color: #60a5fa; }
html.dark .pp-name { color: #e2e8f0; }
html.dark .pp-preview { color: #94a3b8; }
html.dark .pp-tg-warning { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.3); color: #fcd34d; }
html.dark .pp-tg-warning a { color: #fcd34d; }
html.dark .pp-spinner { border-color: rgba(255, 255, 255, 0.15); border-top-color: #60a5fa; }
html.dark .cart-btn { background: #25252e; border-color: rgba(255, 255, 255, 0.1); color: #94a3b8; }
html.dark .cart-btn:hover { color: #60a5fa; border-color: rgba(96, 165, 250, 0.5); }
html.dark .cart-btn.in-cart { color: #60a5fa; background: rgba(37, 99, 235, 0.15); border-color: rgba(96, 165, 250, 0.5); }
html.dark .cart-bar { background: #2563eb; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5); }
html.dark .cart-bar-ic { background: rgba(255, 255, 255, 0.16); }
html.dark .cart-bar-title { color: #dbeafe; }
html.dark .cart-bar-btn { background: #fff; color: #1d4ed8; }
html.dark .cart-bar:hover .cart-bar-btn { background: #eff6ff; }

/* ── Телефоны: окно — снизу во всю ширину ── */
@media (max-width: 600px) {
  .abm-overlay { padding: 0; align-items: flex-end; }
  .abm { max-width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; padding: 20px 16px 18px; }
  .abm-actions { flex-direction: column-reverse; }
  .abm-actions .abm-btn { width: 100%; padding: 12px; }
  .abm-field select { font-size: 16px; } /* iOS не приближает поле при фокусе */
  .cart-bar { bottom: 10px; width: calc(100% - 20px); gap: 10px; padding: 8px 8px 8px 12px; }
  .cart-bar-btn { padding: 10px 13px; }
  body.has-cart-bar .footer { padding-bottom: 92px; }
}
/* Кнопка панели персонала на странице канала — над плашкой. */
@media (max-width: 640px) {
  body.has-cart-bar .sp-trigger { bottom: 84px; }
}
