/* ==========================================================================
   sklep.filipkowarski.pl — Dual Theme CSS
   Wlasna kopia tokenow panelu (te same nazwy custom properties, gold #c8a258),
   plus style storefrontu / checkoutu / admina. Mobile-first.
   Theme swap = atrybut data-theme na <html>, przelaczany przez shop.js.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens — light (default) + dark. Te same nazwy co panel.css.
   -------------------------------------------------------------------------- */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f7fa;
  --bg-card: #ffffff;
  --bg-hover: #eef2f7;
  --bg-input: #f0f3f7;
  --text-primary: #0b1426;
  --text-secondary: #3d5a80;
  --text-muted: #8899aa;
  --accent: #c8a258;
  --accent-hover: #b8923e;
  --accent-light: #c8a25815;
  --accent-text: #ffffff;
  --border: #d4dce6;
  --border-light: #e2e8f0;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --info: #2563eb;
  --info-bg: #eff6ff;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --header-height: 64px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
}

[data-theme="dark"] {
  --bg-primary: #0b1426;
  --bg-secondary: #101d33;
  --bg-card: #152240;
  --bg-hover: #1a2a4d;
  --bg-input: #0d1830;
  --text-primary: #f0f4f8;
  --text-secondary: #94a3b8;
  --text-muted: #5a7090;
  --accent: #c8a258;
  --accent-hover: #b08d42;
  --accent-light: #c8a25820;
  --accent-text: #0b1426;
  --border: #1e3050;
  --border-light: #243a5c;
  --danger: #ef4444;
  --danger-bg: #ef444420;
  --success: #22c55e;
  --success-bg: #22c55e20;
  --info: #3b82f6;
  --info-bg: #3b82f620;
  --warning: #f59e0b;
  --warning-bg: #f59e0b20;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* --------------------------------------------------------------------------
   2. Base / reset
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  transition: background-color 0.3s ease, color 0.3s ease;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; display: block; }

/* --------------------------------------------------------------------------
   3. Header (sticky, mobile-first)
   -------------------------------------------------------------------------- */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 50;
}

.logo { display: inline-flex; align-items: center; gap: 10px; color: inherit; }
.logo__text {
  font-family: 'Montserrat', var(--font-sans);
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 1px;
  color: var(--text-primary);
  text-transform: uppercase;
}

.app-header__right { display: flex; align-items: center; gap: 10px; }

.app-header__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.app-header__icon-btn:hover { color: var(--accent); border-color: var(--accent); }

.app-header__cart {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.app-header__cart:hover { color: var(--accent); }
.app-header__cart-count {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: var(--accent-text);
  background: var(--accent);
  border-radius: 9px;
}

/* --------------------------------------------------------------------------
   4. Admin nav strip
   -------------------------------------------------------------------------- */
.admin-nav {
  position: fixed;
  top: var(--header-height); left: 0; right: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 40;
}
.admin-nav__inner {
  display: flex; align-items: center; gap: 6px;
  max-width: 1400px; margin: 0 auto;
  padding: 8px 16px;
  overflow-x: auto;
}
.admin-nav__link {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all var(--transition);
}
.admin-nav__link:hover { color: var(--accent); border-color: var(--border); }
.admin-nav__link--active {
  color: var(--accent);
  background: var(--accent-light);
  border-color: var(--accent);
}
.admin-nav__sep { flex: 1; }
.admin-nav__external { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

/* --------------------------------------------------------------------------
   5. Main / container
   -------------------------------------------------------------------------- */
.app-main {
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  padding: 20px 16px 48px;
}
/* admin pages add the nav strip; push content down a row */
.admin-nav ~ .app-main { margin-top: calc(var(--header-height) + 45px); }

.app-container { max-width: 1100px; margin: 0 auto; }
.app-container--wide { max-width: 1400px; }

/* --------------------------------------------------------------------------
   6. Alerts / flash
   -------------------------------------------------------------------------- */
.alert {
  border: 1px solid var(--info);
  background: var(--info-bg);
  color: var(--info);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 20px;
}
.alert--error   { border-color: var(--danger);  background: var(--danger-bg);  color: var(--danger); }
.alert--success { border-color: var(--success); background: var(--success-bg); color: var(--success); }
.alert--warning { border-color: var(--warning); background: var(--warning-bg); color: var(--warning); }

/* --------------------------------------------------------------------------
   7. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn--accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn--block { width: 100%; }
.btn--lg { font-size: 17px; padding: 16px 24px; }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn--danger:hover { border-color: var(--danger); color: var(--danger); }

/* --------------------------------------------------------------------------
   8. Cards / generic surfaces
   -------------------------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.section-title {
  font-family: 'Montserrat', var(--font-sans);
  font-weight: 800;
  font-size: 22px;
  margin-bottom: 16px;
  color: var(--text-primary);
}
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }
.back-link:hover { color: var(--accent); }

/* --------------------------------------------------------------------------
   9. Grid (categories / products) — mobile-first 1 col -> auto-fill
   -------------------------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* --------------------------------------------------------------------------
   10. Product / category card
   -------------------------------------------------------------------------- */
.product-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  color: inherit;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
  color: inherit;
}
.product-card__media {
  aspect-ratio: 4 / 3;
  background: var(--bg-secondary);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.product-card__media img { width: 100%; height: 100%; object-fit: cover; }
.product-card__media-placeholder { font-size: 40px; color: var(--accent); opacity: 0.4; }
.product-card__body { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-card__name { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.product-card__desc { font-size: 13px; color: var(--text-muted); }
.product-card__price { margin-top: auto; font-size: 18px; font-weight: 800; color: var(--accent); }

/* --------------------------------------------------------------------------
   11. Product page
   -------------------------------------------------------------------------- */
.product-detail { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 760px) { .product-detail { grid-template-columns: 1fr 1fr; align-items: start; } }
.product-detail__media {
  aspect-ratio: 4 / 3;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.product-detail__media img { width: 100%; height: 100%; object-fit: cover; }
.product-detail__title { font-family: 'Montserrat', var(--font-sans); font-weight: 800; font-size: 26px; margin-bottom: 10px; }
.product-detail__price { font-size: 26px; font-weight: 800; color: var(--accent); margin-bottom: 16px; }
.product-detail__desc { color: var(--text-secondary); margin-bottom: 24px; }

/* --------------------------------------------------------------------------
   12. Cart
   -------------------------------------------------------------------------- */
.cart-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}
.cart-item__media { width: 64px; height: 64px; border-radius: var(--radius-sm); background: var(--bg-secondary); overflow: hidden; flex-shrink: 0; }
.cart-item__media img { width: 100%; height: 100%; object-fit: cover; }
.cart-item__info { flex: 1; min-width: 0; }
.cart-item__name { font-weight: 600; font-size: 15px; }
.cart-item__price { color: var(--accent); font-weight: 700; }

.qty-stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.qty-stepper button {
  width: 34px; height: 34px;
  background: var(--bg-card); color: var(--text-primary);
  border: none; cursor: pointer; font-size: 18px; line-height: 1;
}
.qty-stepper button:hover { background: var(--bg-hover); color: var(--accent); }
.qty-stepper input {
  width: 44px; height: 34px; text-align: center;
  border: none; border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  background: var(--bg-input); color: var(--text-primary);
  font-size: 15px;
}

.summary {
  margin-top: 20px; padding-top: 16px;
  border-top: 2px solid var(--border);
}
.summary__row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 15px; color: var(--text-secondary); }
.summary__total { font-size: 20px; font-weight: 800; color: var(--text-primary); }
.summary__total .summary__amount { color: var(--accent); }

/* --------------------------------------------------------------------------
   13. Cross-sell slot
   -------------------------------------------------------------------------- */
.crosssell {
  margin-top: 20px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-light);
  padding: 16px;
}
.crosssell__label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent); margin-bottom: 12px; }
.crosssell__row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.crosssell__media { width: 48px; height: 48px; border-radius: var(--radius-sm); background: var(--bg-secondary); display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; }
.crosssell__media img { width: 100%; height: 100%; object-fit: cover; }
.crosssell__info { flex: 1; min-width: 120px; }
.crosssell__name { font-weight: 600; font-size: 15px; }
.crosssell__price { color: var(--accent); font-weight: 700; }
.crosssell__btn { white-space: nowrap; }

/* --------------------------------------------------------------------------
   14. Checkout / forms
   -------------------------------------------------------------------------- */
.checkout-grid { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 860px) { .checkout-grid { grid-template-columns: 1.2fr 0.8fr; align-items: start; } }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit; font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
}
.field--error input { border-color: var(--danger); }
.field__error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.buyer-toggle { display: flex; gap: 10px; margin-bottom: 16px; }
.buyer-toggle label {
  flex: 1; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; text-align: center; font-weight: 600;
  background: var(--bg-card); color: var(--text-secondary);
  transition: all var(--transition);
}
.buyer-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.buyer-toggle input:checked + label,
.buyer-toggle label:has(input:checked) {
  border-color: var(--accent); color: var(--accent); background: var(--accent-light);
}
/* company fields hidden via the [hidden] attribute (server renders it,
   JS toggles el.hidden — single source of truth). !important so the native
   hidden default wins even if .company-fields ever gets display: flex/grid.
   no-JS fallback: server omits [hidden] when buyer_type=company. */
.company-fields[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   15. Admin tables
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
table.data th, table.data td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
table.data th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
table.data tr:hover td { background: var(--bg-hover); }

.badge {
  display: inline-block; padding: 2px 8px; font-size: 12px; font-weight: 600;
  border-radius: 999px; border: 1px solid var(--border);
}
.badge--paid      { color: var(--success); background: var(--success-bg); border-color: var(--success); }
.badge--failed    { color: var(--danger);  background: var(--danger-bg);  border-color: var(--danger); }
.badge--awaiting_payment,
.badge--new       { color: var(--warning); background: var(--warning-bg); border-color: var(--warning); }
.badge--cancelled { color: var(--text-muted); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: end; }
.filters .field { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   16. Sticky checkout CTA on mobile
   -------------------------------------------------------------------------- */
@media (max-width: 859px) {
  .checkout-cta--sticky {
    position: sticky; bottom: 0;
    padding: 12px 0;
    background: linear-gradient(to top, var(--bg-primary) 70%, transparent);
  }
}

.empty-state { text-align: center; padding: 48px 16px; color: var(--text-muted); }
.muted { color: var(--text-muted); }
