/* KMM — Sklep (publiczny e-commerce)
   Apple-like design, sticky header, categories, cart drawer z kodem rabatowym, footer */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --border: #e5e5ea;
  --border-strong: #d2d2d7;
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-light: #e8f2ff;
  --danger: #ff3b30;
  --success: #34c759;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.18);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --max-w: 1320px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background: var(--bg);
}

.muted { color: var(--text-muted); }
img { display: block; max-width: 100%; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ========== Header ========== */
.shop-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(29, 29, 31, 0.92);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.shop-header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
}

.shop-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.shop-brand img {
  max-height: 36px;
  max-width: 140px;
  width: auto;
  height: auto;
}

.shop-search {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
}

.shop-search [data-lucide],
.shop-search svg.lucide {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: rgba(255, 255, 255, 0.45);
  pointer-events: none;
}

.shop-search input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

.shop-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2);
  background: rgba(255, 255, 255, 0.15);
}

.shop-search input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.shop-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cart-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  transition: background 0.15s ease;
}

.cart-btn:hover { background: rgba(255, 255, 255, 0.1); }

.cart-btn [data-lucide], .cart-btn svg.lucide {
  width: 22px;
  height: 22px;
  color: #fff;
}

.cart-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ========== Hero ========== */
.shop-hero {
  background: linear-gradient(135deg, #1d1d1f 0%, #2c2c2e 100%);
  color: #fff;
}

.shop-hero-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 48px 24px;
}

.shop-hero h1 {
  font-size: 38px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.8px;
}

.shop-hero p {
  margin: 0;
  font-size: 17px;
  opacity: 0.7;
}

/* ========== Category bar ========== */
.shop-categories {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 61px; /* header height */
  z-index: 40;
}

.shop-categories-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.shop-categories-inner::-webkit-scrollbar { display: none; }

.cat-pill {
  flex-shrink: 0;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.cat-pill:hover {
  background: var(--bg);
  color: var(--text);
}

.cat-pill.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

/* ========== Main ========== */
.shop-main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px 24px 80px;
}

.shop-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.shop-results {
  font-size: 14px;
  color: var(--text-muted);
}

.shop-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.shop-sort label {
  color: var(--text-muted);
  white-space: nowrap;
}

.shop-sort select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.shop-sort select:focus {
  border-color: var(--accent);
}

/* ========== Product grid ========== */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.catalog-loading,
.catalog-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 15px;
}

/* ========== Product card ========== */
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  cursor: pointer;
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.product-card-image {
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.product-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.product-card:hover .product-card-image img {
  transform: scale(1.03);
}

.product-card-image .placeholder {
  color: var(--text-muted);
}

.product-card-image .placeholder [data-lucide],
.product-card-image .placeholder svg.lucide {
  width: 48px;
  height: 48px;
}

.product-card-labels {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: calc(100% - 16px);
}

.product-label {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
  line-height: 1.3;
}

.product-detail-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.product-detail-labels .product-label {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.product-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.product-card-name {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  margin: 0;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card-price {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-top: auto;
}

.product-card-add {
  background: var(--text);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease;
}

.product-card-add:hover { background: #000; }

.product-card-add [data-lucide], .product-card-add svg.lucide {
  width: 16px;
  height: 16px;
}

/* ========== Footer ========== */
.shop-footer {
  background: #1d1d1f;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 40px;
}

.shop-footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 48px 24px 32px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 40px;
}

.footer-logo {
  max-height: 36px;
  width: auto;
  margin-bottom: 14px;
  filter: brightness(10);
}

.shop-footer-col h4 {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 14px;
}

.shop-footer-col p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

.shop-footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.shop-footer-col li {
  font-size: 14px;
  line-height: 1.6;
  padding: 2px 0;
}

.shop-footer-bottom {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 20px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.4);
}

/* ========== Product detail modal ========== */
.cat-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cat-modal[hidden] { display: none; }

.cat-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.cat-modal-card {
  position: relative;
  background: var(--surface);
  border-radius: 18px;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.cat-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease;
}

.cat-modal-close:hover { background: #fff; }

.cat-modal-close [data-lucide], .cat-modal-close svg.lucide {
  width: 18px;
  height: 18px;
}

.cat-modal-body {
  overflow-y: auto;
  padding: 0;
}

.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.product-detail-image {
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-detail-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-detail-info {
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.product-detail-info h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
}


.product-detail-code {
  font-size: 12px;
  color: var(--text-muted);
  font-family: ui-monospace, "SF Mono", monospace;
}

.product-detail-price {
  font-size: 26px;
  font-weight: 600;
  margin-top: auto;
}

.product-detail-add {
  background: var(--text);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  transition: background 0.15s ease;
}

.product-detail-add:hover { background: #000; }

.product-detail-add [data-lucide], .product-detail-add svg.lucide {
  width: 18px;
  height: 18px;
}

/* ========== Cart drawer ========== */
.cart-drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
}

.cart-drawer[hidden] { display: none; }

.cart-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.cart-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.25s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.cart-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.cart-drawer-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.cart-drawer-header .cat-modal-close {
  position: static;
  box-shadow: none;
  background: transparent;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

.cart-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.cart-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.cart-item:last-child { border-bottom: none; }

.cart-item-img {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-item-info { min-width: 0; }

.cart-item-name {
  font-size: 14px;
  font-weight: 500;
  margin: 0 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cart-item-price {
  font-size: 13px;
  color: var(--text-muted);
}

.cart-item-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.qty-stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.qty-stepper button {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--surface);
  transition: background 0.12s ease;
}

.qty-stepper button:hover { background: var(--surface-2); }

.qty-stepper .qty {
  min-width: 30px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
}

.cart-item-remove {
  font-size: 11px;
  color: var(--danger);
  text-decoration: underline;
}

/* ========== Cart footer / discount / summary ========== */
.cart-drawer-footer {
  padding: 20px 24px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.discount-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.discount-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 14px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  text-transform: uppercase;
}

.discount-row input::placeholder {
  text-transform: none;
}

.discount-row input:focus {
  border-color: var(--accent);
}

.discount-row button {
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.discount-row button:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.discount-applied {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #e8fbe8 0%, #f0faf0 100%);
  border: 1px solid #c6ecc6;
  border-radius: var(--radius-xs);
  margin-bottom: 14px;
  font-size: 13px;
  color: #1a7a1a;
}

.discount-applied [data-lucide],
.discount-applied svg.lucide {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--success);
}

.discount-applied span { flex: 1; }

.discount-remove-btn {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: underline;
  flex-shrink: 0;
  transition: color 0.15s;
}

.discount-remove-btn:hover { color: var(--danger); }

.cart-summary {
  margin-bottom: 16px;
}

.cart-summary-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  font-size: 14px;
  color: var(--text-muted);
}

.cart-summary-line.discount-line {
  color: var(--success);
}

.cart-summary-line.cart-total-line {
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 15px;
  color: var(--text);
}

.cart-total-line strong {
  font-size: 22px;
  font-weight: 600;
}

.btn-checkout {
  width: 100%;
  padding: 14px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-checkout:hover:not(:disabled) { background: #000; }

.btn-checkout:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-checkout [data-lucide], .btn-checkout svg.lucide {
  width: 16px;
  height: 16px;
}

.cart-note {
  margin: 10px 0 0;
  text-align: center;
  font-size: 12px;
}

/* ========== Toast ========== */
.catalog-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: toastIn 0.2s ease;
}

.catalog-toast[hidden] { display: none; }

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ========== Mobile ========== */
@media (max-width: 768px) {
  .shop-header-inner { padding: 10px 16px; gap: 12px; }

  .shop-search { max-width: none; }
  .shop-search input { padding: 8px 12px 8px 36px; font-size: 13px; }

  .shop-hero-inner { padding: 32px 16px; }
  .shop-hero h1 { font-size: 28px; }
  .shop-hero p { font-size: 15px; }

  .shop-categories-inner { padding: 10px 16px; }

  .shop-main { padding: 16px 16px 60px; }

  .shop-toolbar { flex-wrap: wrap; }

  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }

  .product-card-body { padding: 12px; }
  .product-card-name { font-size: 14px; }
  .product-card-price { font-size: 16px; }
  .product-card-category { font-size: 10px; padding: 3px 8px; }

  .product-detail { grid-template-columns: 1fr; }
  .product-detail-image { aspect-ratio: 4 / 3; }

  .cart-drawer-panel { max-width: 100%; }

  .shop-footer-inner { padding: 32px 16px 24px; gap: 28px; }
  .shop-footer-bottom { padding: 16px; }
}

@media (max-width: 480px) {
  .shop-brand img { max-height: 28px; }
  .catalog-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .product-card-add { padding: 8px 10px; font-size: 13px; }
}
