/* ==========================================================
 * Magiczny Koszyk — modal centralny
 * Wszystko scoped pod .mk-wrap żeby nie kolidować z motywem.
 * Paleta i typografia spójna z czasduszy-home (--lunaria-*).
 * ========================================================== */

.mk-wrap {
  /* --- KOLORY GŁÓWNE (z homepage) --- */
  --lunaria-primary: #5e2a84;
  --lunaria-primary-dark: #4b2c68;
  --lunaria-secondary: #8e44ad;
  --lunaria-accent: #9b59b6;
  --lunaria-highlight: #b05fa7;
  --lunaria-fire: #c0392b;

  --lunaria-bg-white: #ffffff;
  --lunaria-bg-off-white: #f9f7fc;
  --lunaria-bg-hover: #fcfaff;

  --lunaria-text-main: #333333;
  --lunaria-text-secondary: #4a4a4a;
  --lunaria-text-muted: #555555;
  --lunaria-text-light: #aaaaaa;

  --lunaria-border-light: #e1e1e1;
  --lunaria-border-menu: #f0f0f5;

  --lunaria-gradient-magic: linear-gradient(135deg, #4b2c68 0%, #8e44ad 50%, #c0392b 100%);
  --lunaria-gradient-btn: linear-gradient(135deg, #5e2a84 0%, #b05fa7 100%);
  --lunaria-gradient-btn-hover: linear-gradient(135deg, #6d3099 0%, #c96cc0 100%);

  --lunaria-shadow-subtle: 0 5px 15px rgba(0, 0, 0, 0.08);
  --lunaria-shadow-glow: 0 8px 15px rgba(94, 42, 132, 0.1);
  --lunaria-shadow-magic: 0 10px 25px rgba(142, 68, 173, 0.4);

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--lunaria-text-main);
  box-sizing: border-box;
}
.mk-wrap *,
.mk-wrap *::before,
.mk-wrap *::after { box-sizing: border-box; }

/* ---------- MODAL CONTAINER ---------- */
.mk-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.mk-modal[hidden] { display: none !important; }
.mk-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* Body lock helper — JS dodaje klasę .mk-no-scroll do <html> */
html.mk-no-scroll,
html.mk-no-scroll body {
  overflow: hidden !important;
}

/* ---------- BACKDROP ---------- */
.mk-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 14, 50, 0.55);
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
  cursor: pointer;
}

/* ---------- DIALOG ---------- */
.mk-dialog {
  position: relative;
  width: calc(100% - 32px);
  max-width: 520px;
  max-height: calc(100vh - 48px);
  background: var(--lunaria-bg-white);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(30, 14, 50, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.3, 1.2);
}
.mk-modal.is-open .mk-dialog {
  transform: translateY(0) scale(1);
}

/* ---------- HEADER ---------- */
.mk-modal-header {
  background: var(--lunaria-gradient-magic);
  color: #fff;
  padding: 20px 22px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  position: relative;
  flex-shrink: 0;
}
.mk-modal-header::before {
  /* lekka „mgiełka" jak w hero */
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.35) 0.8px, transparent 1.2px);
  background-size: 22px 22px;
  opacity: 0.18;
  pointer-events: none;
}
.mk-modal-titles {
  position: relative;
  z-index: 1;
}
.mk-kicker {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.82;
  margin-bottom: 4px;
}
.mk-modal-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 500;
  color: #fff;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.mk-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.mk-close {
  position: relative;
  z-index: 1;
  appearance: none;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}
.mk-close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: rotate(90deg);
}
.mk-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ---------- BODY ---------- */
.mk-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 0;
  background: var(--lunaria-bg-white);
}
.mk-modal-body.is-loading {
  pointer-events: none;
  opacity: 0.55;
}

/* ---------- ITEMS LIST ---------- */
.mk-items {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mk-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--lunaria-border-menu);
  align-items: flex-start;
  position: relative;
}
.mk-item:last-child { border-bottom: none; }
.mk-item-thumb {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--lunaria-bg-off-white);
  border: 1px solid var(--lunaria-border-light);
  flex-shrink: 0;
}
.mk-item-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.mk-item-thumb a {
  display: block;
  width: 100%;
  height: 100%;
}

.mk-item-body {
  min-width: 0;
}
.mk-item-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 500;
  color: var(--lunaria-primary-dark);
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mk-item-title a {
  color: inherit;
  text-decoration: none;
}
.mk-item-title a:hover { color: var(--lunaria-secondary); }

.mk-item-meta {
  font-size: 12px;
  color: var(--lunaria-text-muted);
  margin: 0 0 8px;
  line-height: 1.4;
}
.mk-item-meta p { margin: 0; }

.mk-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* Quantity picker */
.mk-qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--lunaria-border-light);
  border-radius: 999px;
  overflow: hidden;
  background: var(--lunaria-bg-white);
}
.mk-qty-btn {
  appearance: none;
  background: transparent;
  border: none;
  width: 28px;
  height: 28px;
  font-size: 16px;
  line-height: 1;
  color: var(--lunaria-primary);
  cursor: pointer;
  transition: background 0.15s ease;
  font-weight: 500;
  padding: 0;
}
.mk-qty-btn:hover {
  background: var(--lunaria-bg-off-white);
}
.mk-qty-btn:disabled {
  color: var(--lunaria-text-light);
  cursor: not-allowed;
}
.mk-qty-input {
  width: 36px;
  height: 28px;
  border: none;
  border-left: 1px solid var(--lunaria-border-light);
  border-right: 1px solid var(--lunaria-border-light);
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--lunaria-text-main);
  background: transparent;
  -moz-appearance: textfield;
  appearance: textfield;
  padding: 0;
}
.mk-qty-input::-webkit-outer-spin-button,
.mk-qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.mk-qty-input:focus {
  outline: none;
  background: var(--lunaria-bg-off-white);
}

.mk-item-price {
  font-size: 14px;
  font-weight: 600;
  color: var(--lunaria-fire);
  white-space: nowrap;
}
.mk-item-price del {
  color: var(--lunaria-text-light);
  font-weight: 400;
  margin-right: 4px;
}
.mk-item-price ins {
  text-decoration: none;
  background: transparent;
}

/* Remove button (×) */
.mk-item-remove {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--lunaria-text-light);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  padding: 0;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: -4px;
}
.mk-item-remove:hover {
  background: rgba(192, 57, 43, 0.08);
  color: var(--lunaria-fire);
}
.mk-item-remove:focus-visible {
  outline: 2px solid var(--lunaria-secondary);
  outline-offset: 2px;
}

/* ---------- SUMMARY (footer) ---------- */
.mk-summary {
  border-top: 1px solid var(--lunaria-border-light);
  background: var(--lunaria-bg-off-white);
  padding: 18px 22px 20px;
  flex-shrink: 0;
}
.mk-summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.mk-summary-label {
  font-size: 13px;
  color: var(--lunaria-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.mk-summary-total .mk-summary-label {
  color: var(--lunaria-primary-dark);
}
.mk-summary-value {
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--lunaria-primary-dark);
}

.mk-summary-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons (pill shape, jak na home) */
.mk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 44px;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  text-align: center;
  white-space: nowrap;
}
.mk-btn-ghost {
  background: transparent;
  color: var(--lunaria-primary-dark);
  border: 1px solid var(--lunaria-border-light);
}
.mk-btn-ghost:hover {
  background: var(--lunaria-bg-white);
  border-color: var(--lunaria-highlight);
  color: var(--lunaria-primary);
}
.mk-btn-gradient {
  background: var(--lunaria-gradient-btn);
  color: #fff;
}
.mk-btn-gradient:hover {
  background: var(--lunaria-gradient-btn-hover);
  transform: translateY(-2px);
  box-shadow: var(--lunaria-shadow-magic);
  color: #fff;
}
.mk-btn:focus-visible {
  outline: 2px solid var(--lunaria-secondary);
  outline-offset: 2px;
}

/* ---------- EMPTY ---------- */
.mk-empty {
  text-align: center;
  padding: 48px 24px 40px;
}
.mk-empty-icon {
  font-size: 38px;
  color: var(--lunaria-highlight);
  margin-bottom: 10px;
  line-height: 1;
}
.mk-empty-text {
  font-family: Georgia, serif;
  font-size: 17px;
  color: var(--lunaria-text-secondary);
  margin: 0 0 22px;
}
.mk-empty .mk-btn {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 12px 28px;
}

/* ---------- LOADING ---------- */
.mk-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 24px;
  font-size: 14px;
  color: var(--lunaria-text-muted);
}
.mk-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--lunaria-border-light);
  border-top-color: var(--lunaria-secondary);
  border-radius: 50%;
  animation: mk-spin 0.8s linear infinite;
}
@keyframes mk-spin {
  to { transform: rotate(360deg); }
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 560px) {
  .mk-dialog {
    width: calc(100% - 16px);
    max-height: calc(100vh - 24px);
    border-radius: 14px;
  }
  .mk-modal-header {
    padding: 18px 18px 16px;
  }
  .mk-modal-title { font-size: 20px; }
  .mk-item {
    grid-template-columns: 56px 1fr auto;
    gap: 12px;
    padding: 14px 18px;
  }
  .mk-item-thumb { width: 56px; height: 56px; }
  .mk-summary { padding: 16px 18px 18px; }
  .mk-summary-actions {
    flex-direction: column;
  }
  .mk-summary-actions .mk-btn {
    flex: 1 1 auto;
    width: 100%;
  }
}

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  .mk-modal,
  .mk-dialog,
  .mk-close,
  .mk-btn-gradient,
  .mk-spinner {
    transition: none !important;
    animation: none !important;
  }
}
