/* ShopWithDerek primary stylesheet
   Organized: tokens, base, layout, header, components, pages, admin, responsive */

/* ---------- Design tokens ---------- */
:root {
  --brand: #0071dc;
  --brand-dark: #004f9a;
  --accent: #ffc220;
  --accent-dark: #f0b400;
  --bg: #ffffff;
  --bg-section: #f5f6f8;
  --border: #e3e5e8;
  --text: #1a1a1a;
  --text-soft: #5a5f66;
  --success: #1a8754;
  --error: #d93025;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 14px rgba(0,0,0,.10);
  --maxw: 1280px;
  --font: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
/* Global guard against accidental horizontal scrolling. Placed on html (the root
   scroll container) so it does not break the sticky header. */
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
img, svg, video, table { max-width: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  font-size: 15px;
}
img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.section { padding: 28px 0; }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 8px; top: 8px; background: #fff; padding: 8px; z-index: 100; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; vertical-align: middle; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: var(--radius);
  font-weight: 600; font-size: 15px; cursor: pointer; border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .05s; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #1a1a1a; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--brand); color: #fff; }
.btn-secondary:hover { background: var(--brand-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: #fff; border-color: var(--error); color: var(--error); }
.btn-danger:hover { background: var(--error); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; background: none; border: none; color: inherit; cursor: pointer; border-radius: var(--radius-sm); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.field { margin-bottom: 16px; }
.field-hint { color: var(--text-soft); font-size: 13px; margin-top: 4px; }
.form-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; max-width: 460px; margin: 24px auto; box-shadow: var(--shadow-sm); }
.form-card h1 { font-size: 24px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Flash and alerts ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin: 16px 0; font-weight: 500; }
.flash-success { background: #e6f4ec; color: var(--success); border: 1px solid #b7e0c8; }
.flash-error { background: #fdecea; color: var(--error); border: 1px solid #f5c2bd; }
.flash-info { background: #e8f1fc; color: var(--brand-dark); border: 1px solid #bcd9f7; }
.inline-error { color: var(--error); font-size: 13px; margin-top: 4px; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.header-inner { display: flex; align-items: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 800; font-size: 20px; }
.brand:hover { text-decoration: none; }
.brand-mark { background: var(--accent); color: var(--brand-dark); border-radius: 50%; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; }
.brand-mark .icon { width: 20px; height: 20px; }
.search { flex: 1; display: flex; background: #fff; border-radius: 24px; overflow: hidden; max-width: 640px; }
.search input { flex: 1; min-width: 0; border: none; border-radius: 0; padding: 12px 18px; }
.search input:focus { outline: none; }
.search-btn { background: var(--accent); border: none; color: var(--brand-dark); width: 52px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.header-actions { display: flex; align-items: center; gap: 4px; }
.action { display: flex; flex-direction: column; align-items: center; color: #fff; padding: 6px 10px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; }
.action:hover { background: var(--brand-dark); text-decoration: none; }
.action-label { margin-top: 2px; }
.cart-icon-wrap { position: relative; }
.cart-badge { position: absolute; top: -6px; right: -8px; background: var(--accent); color: #1a1a1a; border-radius: 10px; min-width: 18px; height: 18px; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.nav-toggle { display: none; color: #fff; }

/* ---------- Category bar ---------- */
.category-bar { background: var(--brand-dark); }
.category-bar-inner { display: flex; align-items: center; gap: 4px; overflow-x: auto; }
.cat-item { position: relative; }
.cat-link { display: inline-flex; align-items: center; gap: 4px; color: #fff; padding: 10px 14px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.cat-link:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.cat-link .icon { width: 16px; height: 16px; }
.cat-dropdown { position: absolute; top: 100%; left: 0; background: #fff; min-width: 200px; box-shadow: var(--shadow-md); border-radius: 0 0 var(--radius) var(--radius); padding: 8px 0; display: none; z-index: 60; }
.cat-item:hover .cat-dropdown { display: block; }
.cat-dropdown a { display: block; padding: 8px 16px; color: var(--text); font-size: 14px; }
.cat-dropdown a:hover { background: var(--bg-section); text-decoration: none; }

/* ---------- Hero ---------- */
.hero { background: linear-gradient(100deg, var(--brand) 0%, var(--brand-dark) 100%); color: #fff; border-radius: var(--radius); padding: 36px 28px; margin: 20px 0; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.hero h1 { font-size: 30px; margin-bottom: 8px; }
.hero p { font-size: 16px; opacity: .95; margin-bottom: 18px; }
.hero-badge { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #1a1a1a; padding: 4px 12px; border-radius: 20px; font-weight: 700; font-size: 13px; margin-bottom: 12px; }

/* ---------- Section headings ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { font-size: 20px; }
.section-head a { font-weight: 600; font-size: 14px; }

/* ---------- Category tiles ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.tile { background: var(--bg-section); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 10px; text-align: center; color: var(--text); font-weight: 600; font-size: 14px; transition: box-shadow .15s, transform .1s; }
.tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
.tile-img { width: 56px; height: 56px; margin: 0 auto 8px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; color: var(--brand); }
.tile-img .icon { width: 28px; height: 28px; }

/* ---------- Product grid and cards ---------- */
.product-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.product-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; position: relative; transition: box-shadow .15s; }
.product-card:hover { box-shadow: var(--shadow-md); }
.product-card .card-media { position: relative; aspect-ratio: 1 / 1; background: var(--bg-section); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 10px; }
.product-card .card-media img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.badge { position: absolute; top: 8px; left: 8px; background: var(--accent); color: #1a1a1a; font-weight: 700; font-size: 12px; padding: 3px 8px; border-radius: 4px; z-index: 2; }
.badge-out { background: var(--text-soft); color: #fff; }
.wish-btn { position: absolute; top: 8px; right: 8px; background: #fff; border: 1px solid var(--border); border-radius: 50%; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; color: var(--text-soft); cursor: pointer; z-index: 2; }
.wish-btn.active, .wish-btn:hover { color: var(--error); }
.card-title { font-size: 14px; font-weight: 500; margin: 0 0 6px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 40px; }
.card-title:hover { color: var(--brand); }
.price-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.price { font-size: 18px; font-weight: 800; color: var(--text); }
.price-old { font-size: 13px; color: var(--text-soft); text-decoration: line-through; }
.unit-note { font-size: 12px; color: var(--text-soft); }
.stars { display: inline-flex; gap: 1px; }
.star-icon { width: 15px; height: 15px; fill: var(--border); stroke: none; }
.star-icon.star-full { fill: var(--accent); }
.star-icon.star-half { fill: var(--accent); opacity: .6; }
.rating-line { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-soft); margin-bottom: 10px; }
.card-foot { margin-top: auto; }

/* ---------- Breadcrumb ---------- */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-soft); padding: 14px 0; flex-wrap: wrap; }
.breadcrumb a { color: var(--text-soft); }
.breadcrumb .icon { width: 14px; height: 14px; }

/* ---------- Category / listing layout ---------- */
.listing { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; }
.filters { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; position: sticky; top: 120px; }
.filters h3 { font-size: 15px; }
.filter-group { border-top: 1px solid var(--border); padding: 14px 0; }
.filter-group:first-of-type { border-top: none; }
.filter-group h4 { font-size: 14px; margin-bottom: 10px; }
.filter-group label { font-weight: 400; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.filter-group label input { width: auto; }
.price-inputs { display: flex; align-items: center; gap: 8px; }
.listing-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.listing-head h1 { font-size: 22px; margin: 0; }
.sort-select { max-width: 220px; }
.filter-toggle { display: none; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-weight: 600; }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Product detail ---------- */
.pdp { display: grid; grid-template-columns: minmax(0, 1.1fr) 1fr; gap: 32px; margin-top: 12px; }
.gallery-main { background: var(--bg-section); border: 1px solid var(--border); border-radius: var(--radius); aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; padding: 20px; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.gallery-thumbs button { width: 64px; height: 64px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; padding: 4px; cursor: pointer; }
.gallery-thumbs button.active { border-color: var(--brand); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: contain; }
.pdp-info h1 { font-size: 26px; }
.pdp-brand { color: var(--text-soft); font-size: 14px; margin-bottom: 8px; }
.pdp-price { font-size: 30px; font-weight: 800; }
.pdp-price-old { font-size: 18px; color: var(--text-soft); text-decoration: line-through; margin-left: 10px; }
.pdp-save { color: var(--success); font-weight: 700; margin-left: 8px; font-size: 15px; }
.variant-group { margin: 16px 0; }
.variant-options { display: flex; flex-wrap: wrap; gap: 8px; }
.variant-opt { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 14px; cursor: pointer; background: #fff; font-weight: 600; font-size: 14px; }
.variant-opt.selected { border-color: var(--brand); background: #e8f1fc; color: var(--brand-dark); }
.variant-opt[disabled] { opacity: .4; cursor: not-allowed; text-decoration: line-through; }
.qty-row { display: flex; align-items: center; gap: 12px; margin: 18px 0; }
.qty-stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.qty-stepper button { width: 40px; height: 44px; background: #fff; border: none; cursor: pointer; color: var(--text); }
.qty-stepper input { width: 52px; height: 44px; text-align: center; border: none; border-left: 1px solid var(--border); border-right: 1px solid var(--border); border-radius: 0; }
.stock-pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }
.stock-in { color: var(--success); }
.stock-out { color: var(--error); }
.pdp-actions { display: flex; gap: 12px; margin: 18px 0; }
.pdp-meta { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 16px; font-size: 14px; color: var(--text-soft); }
.pdp-meta div { margin-bottom: 6px; }

/* ---------- Tabs / reviews ---------- */
.prose { font-size: 15px; color: var(--text); }
.reviews { margin-top: 36px; }
.review { border-top: 1px solid var(--border); padding: 16px 0; }
.review-head { display: flex; align-items: center; gap: 10px; }
.review-author { font-weight: 600; }
.review-date { color: var(--text-soft); font-size: 13px; }

/* ---------- Cart ---------- */
.cart-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.cart-list { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.cart-item { display: grid; grid-template-columns: 84px 1fr auto; gap: 14px; padding: 16px; border-bottom: 1px solid var(--border); align-items: center; }
.cart-item:last-child { border-bottom: none; }
.cart-item-img { width: 84px; height: 84px; background: var(--bg-section); border-radius: var(--radius-sm); object-fit: contain; padding: 6px; }
.cart-item-title { font-weight: 600; font-size: 15px; }
.cart-item-variant { color: var(--text-soft); font-size: 13px; }
.cart-item-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.summary { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; position: sticky; top: 120px; }
.summary h3 { font-size: 17px; }
.summary-row { display: flex; justify-content: space-between; margin: 8px 0; font-size: 14px; }
.summary-row.total { font-size: 18px; font-weight: 800; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.coupon-form { display: flex; gap: 8px; margin: 12px 0; }
.coupon-form input { flex: 1; }
.coupon-tag { display: inline-flex; align-items: center; gap: 6px; background: #e6f4ec; color: var(--success); padding: 4px 10px; border-radius: 4px; font-weight: 600; font-size: 13px; }

/* ---------- Checkout ---------- */
.checkout-layout { display: grid; grid-template-columns: 1fr 360px; gap: 24px; align-items: start; }
.checkout-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.checkout-card h2 { font-size: 18px; }
#payment-element { margin: 12px 0; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-soft); }
.empty-state .icon { width: 56px; height: 56px; color: var(--border); margin-bottom: 12px; }

/* ---------- Account ---------- */
.account-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.account-nav { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.account-nav a { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--text); font-weight: 600; border-bottom: 1px solid var(--border); }
.account-nav a:hover, .account-nav a.active { background: var(--bg-section); text-decoration: none; }
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { background: var(--bg-section); font-weight: 700; }
.status { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.status-pending { background: #fff3d6; color: #8a6100; }
.status-paid, .status-processing { background: #e8f1fc; color: var(--brand-dark); }
.status-shipped { background: #ede7fb; color: #5b34c4; }
.status-delivered { background: #e6f4ec; color: var(--success); }
.status-cancelled, .status-refunded, .status-failed { background: #fdecea; color: var(--error); }
.status-unpaid { background: #f0f1f3; color: var(--text-soft); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; border-left: 2px solid var(--border); }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--border); }
.timeline li.done::before { background: var(--success); }

/* ---------- Footer ---------- */
.site-footer { background: var(--bg-section); border-top: 1px solid var(--border); margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 24px; padding: 36px 16px; }
.footer-col h4 { font-size: 15px; }
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin-bottom: 8px; }
.footer-col a { color: var(--text-soft); font-size: 14px; }
.footer-about { color: var(--text-soft); font-size: 14px; max-width: 340px; }
.brand-footer { color: var(--text); font-size: 18px; margin-bottom: 12px; }
.footer-contact { display: flex; align-items: center; gap: 6px; color: var(--text-soft); font-size: 14px; margin-top: 10px; }
.footer-bottom { border-top: 1px solid var(--border); padding: 16px 0; font-size: 13px; color: var(--text-soft); text-align: center; }

/* ---------- Utilities ---------- */
.bg-section { background: var(--bg-section); }
.text-soft { color: var(--text-soft); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
[hidden] { display: none !important; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tag-deal { color: var(--error); font-weight: 700; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); }
  .tile-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 860px) {
  .listing { grid-template-columns: 1fr; }
  .filters { position: static; display: none; }
  .filters.open { display: block; }
  .filter-toggle { display: inline-flex; }
  .pdp { grid-template-columns: 1fr; }
  .cart-layout, .checkout-layout, .account-layout { grid-template-columns: 1fr; }
  .summary, .filters { position: static; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; flex: 0 0 auto; }
  .action-label { display: none; }
  /* Header reflows to two rows: controls on top, full width search below.
     This keeps the cart and account buttons visible and stops sideways scroll. */
  .header-inner { flex-wrap: wrap; gap: 8px; }
  .brand { font-size: 18px; flex: 0 1 auto; min-width: 0; }
  .brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .header-actions { margin-left: auto; gap: 0; flex: 0 0 auto; }
  .action { padding: 6px 8px; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
  .category-bar { display: none; }
  .category-bar.open { display: block; }
  .category-bar-inner { flex-direction: column; align-items: stretch; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .tile-grid { grid-template-columns: repeat(3, 1fr); }
  .hero { flex-direction: column; text-align: center; }
  .hero-art { display: none; }
  .form-row { grid-template-columns: 1fr; }
  /* Wide data tables scroll inside their own box instead of widening the page. */
  .table, .admin-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
}
/* Cart and product rows: keep controls inside the screen on phones. */
@media (max-width: 600px) {
  .cart-item { grid-template-columns: 60px 1fr auto; gap: 10px; padding: 12px; align-items: start; }
  .cart-item > div { min-width: 0; }
  .cart-item-img { width: 60px; height: 60px; }
  .cart-item-title { font-size: 14px; overflow-wrap: anywhere; }
  .cart-item-actions { gap: 8px; }
  .qty-stepper button { width: 34px; }
  .qty-stepper input { width: 40px; }
  .pdp-actions { flex-wrap: wrap; }
  .pdp-actions .btn { flex: 1 1 auto; }
}
@media (max-width: 480px) {
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 24px; }
  .brand-name { display: none; } /* logo mark is enough on the smallest screens */
  .search input { padding: 10px 14px; }
}
