/* ===== Корзина («Мои уроки», этап 1) ===== */

/* Бейдж в шапке */
.nav-cart {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #9ca3af);
  padding: 6px;
  border-radius: 8px;
  transition: color 0.2s;
}
.nav-cart:hover, .nav-cart.active { color: var(--accent, #f59e0b); }
.nav-cart-count {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent, #f59e0b);
  color: #111;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
#nav-mobile-cart .nav-cart-count {
  position: static;
  display: inline-block;
  margin-left: 6px;
  vertical-align: 1px;
}

/* Цена и кнопка на «Мои уроки» */
.cart-buy {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.cart-price {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text, #e5e7eb);
}
[data-theme="light"] .cart-price { color: #1f2937; }
.cart-add-btn {
  border: 1px solid var(--accent, #f59e0b);
  background: transparent;
  color: var(--accent, #f59e0b);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.cart-add-btn:hover { background: var(--accent, #f59e0b); color: #111; }
.cart-add-btn.in-cart {
  border-color: rgba(34, 197, 94, 0.6);
  color: #22c55e;
  background: rgba(34, 197, 94, 0.08);
}
.cart-add-btn:disabled { opacity: 0.6; cursor: default; }
.dash-group-header { flex-wrap: wrap; row-gap: 8px; }

/* Подсказка об акции «4 модуля — скидка 20%» на дашборде */
.cart-promo-hint {
  margin: -12px 0 20px;
  padding: 10px 14px;
  border: 1px dashed rgba(245, 158, 11, 0.45);
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.06);
  color: var(--text-muted, #9ca3af);
  font-size: 0.82rem;
}
[data-theme="light"] .cart-promo-hint { background: rgba(245, 158, 11, 0.07); color: #6b7280; }

/* Выравнивание правой части строк модулей по колонкам (десктоп):
   уроки | Премиум | кнопка действия | цена | В корзину */
@media (min-width: 769px) {
  .dash-m-lessons { width: 62px; text-align: right; }
  .dash-m-status { width: 96px; justify-content: center; box-sizing: border-box; }
  .dash-row-right .dash-m-btn { width: 104px; text-align: center; box-sizing: border-box; }
  .dash-row-right .cart-price { min-width: 68px; text-align: right; }
  .dash-row-right .cart-add-btn { width: 108px; text-align: center; box-sizing: border-box; padding-left: 4px; padding-right: 4px; }
  /* Одинаковые промежутки между колонками цены и корзины */
  .dash-row-right { gap: 14px; }
  .dash-row-right .cart-buy { gap: 14px; }
}

@media (max-width: 640px) {
  .dash-row-right .cart-buy { width: 100%; justify-content: flex-end; }
}

/* Тост */
.cart-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(17, 24, 39, 0.95);
  color: #f3f4f6;
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 0.9rem;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-width: min(92vw, 480px);
  text-align: center;
}
.cart-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-theme="light"] .cart-toast { background: #fff; color: #1f2937; box-shadow: 0 8px 30px rgba(0,0,0,0.15); }

/* Всплывающее сообщение о скидке у иконки корзины в шапке */
.cart-nav-popover {
  position: fixed;
  background: rgba(17, 24, 39, 0.97);
  color: #f3f4f6;
  border: 1px solid rgba(245, 158, 11, 0.55);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  z-index: 1200;
  max-width: min(88vw, 320px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.cart-nav-popover.show { opacity: 1; transform: translateY(0); }
.cart-nav-popover::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 18px;
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  background: inherit;
  border-left: 1px solid rgba(245, 158, 11, 0.55);
  border-top: 1px solid rgba(245, 158, 11, 0.55);
}
[data-theme="light"] .cart-nav-popover { background: #fff; color: #1f2937; box-shadow: 0 10px 34px rgba(0,0,0,0.18); }

/* Страница корзины */
/* Верхний отступ страницы задаёт .dashboard-page (dashboard-v2.css) — под фиксированную шапку */
.cart-page { max-width: 760px; margin: 0 auto; padding: 0 0 40px; }
.cart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 12px;
  margin-bottom: 12px;
  background: var(--card-bg, rgba(255,255,255,0.02));
}
.cart-row-name { font-weight: 600; }
.cart-row-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.1);
  border-radius: 6px;
  padding: 2px 7px;
}
.cart-price-old {
  color: var(--text-muted, #9ca3af);
  font-weight: 500;
  font-size: 0.85em;
  margin-right: 8px;
}
.cart-price-new { color: #22c55e; }
.cart-row-sub { font-size: 0.82rem; color: var(--text-muted, #9ca3af); margin-top: 4px; }
.cart-row-right { display: inline-flex; align-items: center; gap: 14px; white-space: nowrap; }
.cart-remove-btn {
  border: none;
  background: transparent;
  color: var(--text-muted, #9ca3af);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}
.cart-remove-btn:hover { color: #ef4444; background: rgba(239, 68, 68, 0.08); }
.cart-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border, rgba(255,255,255,0.08));
  flex-wrap: wrap;
}
.cart-summary-total { font-size: 1.15rem; font-weight: 700; }
.cart-summary-lines { display: flex; flex-direction: column; gap: 4px; }
.cart-summary-line { font-size: 0.9rem; color: var(--text-muted, #9ca3af); }
.cart-summary-line span { font-variant-numeric: tabular-nums; }
.cart-summary-discount { color: #22c55e; }
.cart-summary-discount span { font-weight: 600; }
.cart-checkout-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.cart-invoice-btn {
  border: 1px solid var(--border, rgba(255,255,255,0.18)); background: transparent;
  color: var(--text, #e5e7eb); border-radius: 8px; padding: 10px 14px;
  font: 600 0.9rem inherit; cursor: pointer;
}
.cart-invoice-btn:hover { border-color: var(--accent, #f59e0b); color: var(--accent, #f59e0b); }
.cart-invoice-btn:disabled { opacity: .6; cursor: default; }
.cart-checkout-error { width: 100%; margin: 0; color: #ef4444; font-size: .85rem; text-align: right; }
@media (max-width: 520px) {
  .cart-checkout-actions { width: 100%; }
  .cart-checkout-actions > button { flex: 1 1 100%; }
  .cart-checkout-error { text-align: left; }
}

/* Баннер автоскидки на странице корзины */
.cart-discount-banner {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  border: 1px dashed rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.06);
  color: var(--text-muted, #9ca3af);
}
.cart-discount-banner.active {
  border: 1px solid rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.08);
  color: #22c55e;
  font-weight: 600;
}
.cart-empty-promo { font-size: 0.85rem; margin-top: 10px; }
.cart-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted, #9ca3af);
}
.cart-empty a { color: var(--accent, #f59e0b); }

/* Возврат с платёжной страницы */
.billing-return { max-width: 620px; margin: 36px auto 56px; padding: 40px 28px; text-align: center; border: 1px solid var(--border, rgba(255,255,255,.1)); border-radius: 16px; background: var(--card-bg, rgba(255,255,255,.02)); }
.billing-return h1 { margin: 0 0 12px; }
.billing-return-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 18px; border-radius: 50%; font-size: 28px; font-weight: 700; background: rgba(245,158,11,.12); color: var(--accent, #f59e0b); }
.billing-return-icon-paid { background: rgba(34,197,94,.12); color: #22c55e; }
.billing-return-icon-canceled, .billing-return-icon-failed { background: rgba(239,68,68,.12); color: #ef4444; }
.billing-return-status { margin: 0; font-weight: 600; }
.billing-return-detail { min-height: 1.5em; margin: 10px 0 0; color: var(--text-muted, #9ca3af); }
.billing-return-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 26px; }
@media (max-width: 520px) { .billing-return { margin-top: 20px; padding: 30px 18px; } .billing-return-actions .btn { width: 100%; } }

/* Модалка «Сформировать счёт» */
.invoice-modal-box {
  position: relative;
  text-align: left;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.invoice-modal-x {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border, rgba(255,255,255,0.15));
  background: transparent;
  color: var(--text, #e5e7eb);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
[data-theme="light"] .invoice-modal-x { color: #1f2937; }
.invoice-modal-box h3 { margin: 0 0 6px; font-size: 1.3rem; }
.invoice-subtitle { color: var(--text-muted, #9ca3af); font-size: 0.85rem; margin: 0 0 16px; }
.invoice-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  background: var(--card-bg, rgba(255,255,255,0.04));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 10px;
  padding: 4px;
}
.invoice-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted, #9ca3af);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.invoice-tab.active { background: #4f5df0; color: #fff; }
.invoice-field { margin-bottom: 14px; flex: 1; min-width: 0; }
.invoice-field label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted, #9ca3af);
  margin-bottom: 6px;
}
.invoice-field input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  background: var(--card-bg, rgba(255,255,255,0.04));
  color: var(--text, #e5e7eb);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.invoice-field input:focus { border-color: #4f5df0; }
.invoice-field input[readonly] { opacity: 0.8; cursor: default; }
[data-theme="light"] .invoice-field input { background: #faf7f5; color: #1f2937; border-color: #e5e0dc; }
.invoice-field-row { display: flex; gap: 12px; }
.invoice-error {
  color: #ef4444;
  font-size: 0.85rem;
  margin: 4px 0 10px;
}
.invoice-submit {
  width: 100%;
  border: none;
  background: #4f5df0;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}
.invoice-submit:hover { background: #4350e8; }
.invoice-submit:disabled { opacity: 0.6; cursor: default; }
@media (max-width: 520px) {
  .invoice-field-row { flex-direction: column; gap: 0; }
}

/* Модалка-заглушка оплаты */
.cart-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 20px;
}
.cart-modal.show { display: flex; }
.cart-modal-box {
  background: var(--bg, #111827);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 14px;
  padding: 28px;
  max-width: 420px;
  text-align: center;
}
[data-theme="light"] .cart-modal-box { background: #fff; }
.cart-modal-box h3 { margin: 0 0 10px; }
.cart-modal-box p { color: var(--text-muted, #9ca3af); margin: 0 0 18px; }
