/* =============================================================================
   EcomWooh — main.css
   Base reset, layout, header, footer, components, utilities
   ============================================================================= */

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--ew-font-sans);
  font-size: var(--ew-text-base);
  font-weight: var(--ew-font-normal);
  line-height: var(--ew-leading-normal);
  color: var(--ew-text-primary);
  background-color: var(--ew-bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; margin: 0; padding: 0; }

/* ── Skip Link ──────────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: -999;
}
.skip-link:focus {
  position: fixed;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  padding: var(--ew-space-3) var(--ew-space-4);
  background: var(--ew-primary);
  color: var(--ew-white);
  font-size: var(--ew-text-sm);
  font-weight: var(--ew-font-semibold);
  z-index: 9999;
  outline: 2px solid var(--ew-accent);
  outline-offset: 2px;
}

/* ── Screen Reader Text ─────────────────────────────────────────────────────── */
.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}
.screen-reader-text:focus {
  clip: auto !important;
  clip-path: none;
  display: block;
  height: auto;
  left: 5px;
  top: 5px;
  width: auto;
  z-index: 100000;
  background-color: #f1f1f1;
  border-radius: 3px;
  box-shadow: 0 0 2px 2px rgba(0,0,0,.6);
  color: #21759b;
  display: block;
  font-size: 14px;
  font-weight: 700;
  line-height: normal;
  padding: 15px 23px 14px;
  text-decoration: none;
}

/* ── Container ──────────────────────────────────────────────────────────────── */
.ew-container {
  width: 100%;
  max-width: var(--ew-container-2xl);
  margin-inline: auto;
  padding-inline: var(--ew-container-pad);
}
.ew-container--sm  { max-width: var(--ew-container-sm); }
.ew-container--md  { max-width: var(--ew-container-md); }
.ew-container--lg  { max-width: var(--ew-container-lg); }
.ew-container--xl  { max-width: var(--ew-container-xl); }

/* ── Typography ─────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--ew-font-heading);
  font-weight: var(--ew-font-bold);
  line-height: var(--ew-leading-tight);
  letter-spacing: var(--ew-tracking-tight);
  color: var(--ew-text-primary);
  margin-top: 0;
  margin-bottom: var(--ew-space-4);
}
h1 { font-size: clamp(var(--ew-text-3xl), 4vw, var(--ew-text-5xl)); }
h2 { font-size: clamp(var(--ew-text-2xl), 3vw, var(--ew-text-4xl)); }
h3 { font-size: clamp(var(--ew-text-xl),  2.5vw, var(--ew-text-3xl)); }
h4 { font-size: var(--ew-text-xl); }
h5 { font-size: var(--ew-text-lg); }
h6 { font-size: var(--ew-text-base); }

p { margin-top: 0; margin-bottom: var(--ew-space-4); }
p:last-child { margin-bottom: 0; }

a:hover { color: var(--ew-accent); }

strong, b { font-weight: var(--ew-font-semibold); }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.ew-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ew-space-2);
  padding: 0.75em 1.5em;
  font-size: var(--ew-text-sm);
  font-weight: var(--ew-font-semibold);
  font-family: var(--ew-font-sans);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: var(--ew-radius);
  transition: background var(--ew-transition-fast), color var(--ew-transition-fast), border-color var(--ew-transition-fast), transform var(--ew-transition-fast), box-shadow var(--ew-transition-fast);
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
}
.ew-btn:focus-visible {
  outline: 2px solid var(--ew-accent);
  outline-offset: 3px;
}
.ew-btn:active { transform: translateY(1px); }
.ew-btn:disabled, .ew-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.ew-btn--primary {
  background: var(--ew-primary);
  color: var(--ew-white);
  border-color: var(--ew-primary);
}
.ew-btn--primary:hover {
  background: var(--ew-primary-hover);
  border-color: var(--ew-primary-hover);
  color: var(--ew-white);
}

.ew-btn--accent {
  background: var(--ew-accent);
  color: var(--ew-white);
  border-color: var(--ew-accent);
}
.ew-btn--accent:hover {
  background: var(--ew-accent-hover);
  border-color: var(--ew-accent-hover);
  color: var(--ew-white);
}

.ew-btn--outline {
  background: transparent;
  color: var(--ew-primary);
  border-color: var(--ew-primary);
}
.ew-btn--outline:hover {
  background: var(--ew-primary);
  color: var(--ew-white);
}

.ew-btn--ghost {
  background: transparent;
  color: var(--ew-text-primary);
  border-color: transparent;
}
.ew-btn--ghost:hover {
  background: var(--ew-gray-100);
}

.ew-btn--sm { padding: 0.5em 1em; font-size: var(--ew-text-xs); }
.ew-btn--lg { padding: 1em 2em; font-size: var(--ew-text-base); }
.ew-btn--full { width: 100%; }

/* ── Top Bar ────────────────────────────────────────────────────────────────── */
.ew-topbar {
  background: var(--ew-primary);
  color: var(--ew-white);
  font-size: var(--ew-text-xs);
  padding-block: var(--ew-space-2);
}
.ew-topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ew-space-4);
}
.ew-topbar__message { font-weight: var(--ew-font-medium); }
.ew-topbar__nav ul { display: flex; gap: var(--ew-space-4); }
.ew-topbar__nav a { color: var(--ew-gray-300); transition: color var(--ew-transition-fast); }
.ew-topbar__nav a:hover { color: var(--ew-white); }

/* ── Header ─────────────────────────────────────────────────────────────────── */
.ew-header {
  position: relative;
  background: var(--ew-header-bg);
  border-bottom: 1px solid var(--ew-header-border);
  z-index: var(--ew-z-header);
}
.ew-header--sticky {
  position: sticky;
  top: 0;
}
.ew-header__inner {
  display: flex;
  align-items: center;
  gap: var(--ew-space-6);
  height: var(--ew-header-height);
}

/* Logo */
.ew-header__logo { flex-shrink: 0; }
.ew-header__logo img { height: 40px; width: auto; }
.ew-logo-text {
  font-size: var(--ew-text-xl);
  font-weight: var(--ew-font-extrabold);
  color: var(--ew-text-primary);
  letter-spacing: var(--ew-tracking-tight);
}

/* Nav */
.ew-header__nav { flex: 1; }
.ew-nav__list {
  display: flex;
  align-items: center;
  gap: var(--ew-space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}
.ew-nav__list > li > a {
  display: block;
  padding: var(--ew-space-2) var(--ew-space-3);
  font-size: var(--ew-text-sm);
  font-weight: var(--ew-font-medium);
  color: var(--ew-text-primary);
  border-radius: var(--ew-radius-sm);
  transition: color var(--ew-transition-fast), background var(--ew-transition-fast);
}
.ew-nav__list > li > a:hover,
.ew-nav__list > li.current-menu-item > a {
  color: var(--ew-accent);
}

/* Dropdown */
.ew-nav__list > li {
  position: relative;
}
.ew-nav__list > li > ul {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 200px;
  background: var(--ew-bg-card);
  border: 1px solid var(--ew-border);
  border-radius: var(--ew-radius-md);
  box-shadow: var(--ew-shadow-lg);
  padding: var(--ew-space-2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--ew-transition-fast), transform var(--ew-transition-fast), visibility var(--ew-transition-fast);
  z-index: var(--ew-z-dropdown);
}
.ew-nav__list > li:hover > ul,
.ew-nav__list > li:focus-within > ul {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.ew-nav__list ul li a {
  display: block;
  padding: var(--ew-space-2) var(--ew-space-3);
  font-size: var(--ew-text-sm);
  color: var(--ew-text-primary);
  border-radius: var(--ew-radius-sm);
  transition: background var(--ew-transition-fast), color var(--ew-transition-fast);
}
.ew-nav__list ul li a:hover {
  background: var(--ew-gray-100);
  color: var(--ew-accent);
}

/* Header Actions */
.ew-header__actions {
  display: flex;
  align-items: center;
  gap: var(--ew-space-1);
  margin-left: auto;
}
.ew-header__action {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--ew-radius);
  background: none;
  border: none;
  color: var(--ew-text-primary);
  cursor: pointer;
  transition: background var(--ew-transition-fast), color var(--ew-transition-fast);
}
.ew-header__action:hover { background: var(--ew-gray-100); color: var(--ew-accent); }
.ew-header__action:focus-visible { outline: 2px solid var(--ew-accent); outline-offset: 2px; }

/* Cart count bubble */
.ew-cart-count {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--ew-accent);
  color: var(--ew-white);
  font-size: 10px;
  font-weight: var(--ew-font-bold);
  line-height: 16px;
  border-radius: var(--ew-radius-full);
  text-align: center;
}
.ew-cart-count:empty { display: none; }
.ew-cart-count:is(:contains("0")) { display: none; }

/* Hamburger */
.ew-hamburger { display: flex; flex-direction: column; gap: 4px; }
.ew-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform var(--ew-transition-fast), opacity var(--ew-transition-fast);
}

/* Hide menu toggle on desktop */
.ew-header__menu-toggle { display: none; }

/* Search Panel */
.ew-search-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--ew-bg-card);
  border-bottom: 1px solid var(--ew-border);
  padding-block: var(--ew-space-4);
  box-shadow: var(--ew-shadow-md);
  z-index: var(--ew-z-dropdown);
  animation: ew-slideDown var(--ew-transition-fast) ease;
}
.ew-search-panel[hidden] { display: none; }

.ew-search-form {
  display: flex;
  align-items: center;
  gap: var(--ew-space-2);
  border: 2px solid var(--ew-border);
  border-radius: var(--ew-radius-full);
  padding: var(--ew-space-2) var(--ew-space-4);
  transition: border-color var(--ew-transition-fast);
}
.ew-search-form:focus-within { border-color: var(--ew-primary); }
.ew-search-form__input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: var(--ew-text-base);
  color: var(--ew-text-primary);
}
.ew-search-form__input::placeholder { color: var(--ew-text-muted); }
.ew-search-form__submit {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ew-text-secondary);
  display: flex;
  align-items: center;
  padding: 0;
}
.ew-search-form__submit:hover { color: var(--ew-primary); }

/* ── Overlay ─────────────────────────────────────────────────────────────────── */
.ew-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--ew-z-overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--ew-transition), visibility var(--ew-transition);
}
body.ew-overlay-active .ew-overlay {
  opacity: 1;
  visibility: visible;
}

/* ── Drawer (Mobile Menu + Cart) ─────────────────────────────────────────────── */
.ew-mobile-menu,
.ew-cart-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: min(380px, 90vw);
  background: var(--ew-bg-card);
  z-index: var(--ew-z-modal);
  display: flex;
  flex-direction: column;
  transition: transform var(--ew-transition);
  overflow: hidden;
}
.ew-mobile-menu { left: 0; transform: translateX(-100%); }
.ew-cart-drawer { right: 0; transform: translateX(100%); }
.ew-mobile-menu[hidden], .ew-cart-drawer[hidden] { display: flex; }
body.ew-mobile-menu-open .ew-mobile-menu { transform: translateX(0); }
body.ew-cart-open .ew-cart-drawer { transform: translateX(0); }

.ew-mobile-menu__header,
.ew-cart-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ew-space-4) var(--ew-space-6);
  border-bottom: 1px solid var(--ew-border);
  flex-shrink: 0;
}
.ew-mobile-menu__title,
.ew-cart-drawer__title {
  font-size: var(--ew-text-base);
  font-weight: var(--ew-font-semibold);
  margin: 0;
}
.ew-mobile-menu__close,
.ew-cart-drawer__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ew-text-secondary);
  padding: var(--ew-space-1);
  border-radius: var(--ew-radius-sm);
  transition: color var(--ew-transition-fast), background var(--ew-transition-fast);
}
.ew-mobile-menu__close:hover,
.ew-cart-drawer__close:hover {
  color: var(--ew-text-primary);
  background: var(--ew-gray-100);
}

.ew-mobile-menu__body,
.ew-cart-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--ew-space-4);
  -webkit-overflow-scrolling: touch;
}

/* Mobile nav */
.ew-mobile-nav__list { display: flex; flex-direction: column; }
.ew-mobile-nav__list li a {
  display: block;
  padding: var(--ew-space-3) var(--ew-space-2);
  font-size: var(--ew-text-base);
  font-weight: var(--ew-font-medium);
  border-bottom: 1px solid var(--ew-border);
  transition: color var(--ew-transition-fast);
}
.ew-mobile-nav__list li a:hover { color: var(--ew-accent); }

/* ── Newsletter Bar ─────────────────────────────────────────────────────────── */
.ew-footer__newsletter {
  background: var(--ew-gray-900);
  color: var(--ew-white);
  padding-block: var(--ew-space-10);
}
.ew-newsletter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ew-space-8);
  flex-wrap: wrap;
}
.ew-newsletter__title {
  font-size: var(--ew-text-2xl);
  font-weight: var(--ew-font-bold);
  color: var(--ew-white);
  margin-bottom: var(--ew-space-1);
}
.ew-newsletter__subtitle { color: var(--ew-gray-400); margin: 0; }
.ew-newsletter__form {
  display: flex;
  gap: var(--ew-space-2);
  flex-wrap: wrap;
}
.ew-newsletter__input {
  padding: 0.75em 1.25em;
  border: 1px solid var(--ew-gray-700);
  border-radius: var(--ew-radius);
  background: var(--ew-gray-800);
  color: var(--ew-white);
  font-size: var(--ew-text-sm);
  min-width: 260px;
  outline: none;
  transition: border-color var(--ew-transition-fast);
}
.ew-newsletter__input::placeholder { color: var(--ew-gray-500); }
.ew-newsletter__input:focus { border-color: var(--ew-accent); }

/* ── Footer Widgets ─────────────────────────────────────────────────────────── */
.ew-footer__widgets {
  padding-block: var(--ew-space-16);
  border-bottom: 1px solid var(--ew-border);
}
.ew-footer__widget-grid {
  display: grid;
  gap: var(--ew-space-8);
}
.ew-footer__widget-grid--1 { grid-template-columns: 1fr; }
.ew-footer__widget-grid--2 { grid-template-columns: repeat(2, 1fr); }
.ew-footer__widget-grid--3 { grid-template-columns: repeat(3, 1fr); }
.ew-footer__widget-grid--4 { grid-template-columns: repeat(4, 1fr); }

/* Widget styles */
.widget-title {
  font-size: var(--ew-text-sm);
  font-weight: var(--ew-font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--ew-tracking-widest);
  margin-bottom: var(--ew-space-4);
  color: var(--ew-text-primary);
}
.widget ul { display: flex; flex-direction: column; gap: var(--ew-space-2); }
.widget ul li a {
  font-size: var(--ew-text-sm);
  color: var(--ew-text-secondary);
  transition: color var(--ew-transition-fast);
}
.widget ul li a:hover { color: var(--ew-text-primary); }

/* ── Footer Bottom ─────────────────────────────────────────────────────────── */
.ew-footer__bottom { padding-block: var(--ew-space-6); }
.ew-footer__bottom-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ew-space-4);
  flex-wrap: wrap;
}
.ew-footer__copyright { font-size: var(--ew-text-sm); color: var(--ew-text-secondary); margin: 0; }
.ew-footer__legal-list {
  display: flex;
  gap: var(--ew-space-4);
}
.ew-footer__legal-list a {
  font-size: var(--ew-text-sm);
  color: var(--ew-text-secondary);
  transition: color var(--ew-transition-fast);
}
.ew-footer__legal-list a:hover { color: var(--ew-text-primary); }

/* Payment icons placeholder */
.ew-footer__payment-icons { display: flex; gap: var(--ew-space-2); align-items: center; }
.ew-payment-icon {
  width: 38px;
  height: 24px;
  border-radius: 4px;
  background: var(--ew-gray-200);
  display: block;
}

/* ── 404 Page ────────────────────────────────────────────────────────────────── */
.ew-404 { min-height: 60vh; display: flex; align-items: center; }
.ew-404__inner { text-align: center; padding-block: var(--ew-space-24); }
.ew-404__number {
  font-size: clamp(80px, 15vw, 180px);
  font-weight: var(--ew-font-extrabold);
  line-height: 1;
  color: var(--ew-gray-200);
  letter-spacing: -0.05em;
  margin-bottom: var(--ew-space-4);
}
.ew-404__title { margin-bottom: var(--ew-space-4); }
.ew-404__subtitle { color: var(--ew-text-secondary); max-width: 400px; margin-inline: auto; margin-bottom: var(--ew-space-8); }
.ew-404__actions { display: flex; gap: var(--ew-space-3); justify-content: center; flex-wrap: wrap; margin-bottom: var(--ew-space-8); }
.ew-404__search { max-width: 500px; margin-inline: auto; }

/* ── Toast ───────────────────────────────────────────────────────────────────── */
.ew-toast {
  position: fixed;
  bottom: var(--ew-space-6);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  z-index: var(--ew-z-toast);
  transition: transform var(--ew-transition);
}
.ew-toast.ew-toast--visible { transform: translateX(-50%) translateY(0); }
.ew-toast[hidden] { display: block; } /* keep it in DOM */
.ew-toast__inner {
  display: flex;
  align-items: center;
  gap: var(--ew-space-3);
  padding: var(--ew-space-3) var(--ew-space-5);
  background: var(--ew-gray-900);
  color: var(--ew-white);
  border-radius: var(--ew-radius-full);
  font-size: var(--ew-text-sm);
  font-weight: var(--ew-font-medium);
  box-shadow: var(--ew-shadow-xl);
  white-space: nowrap;
}
.ew-toast__icon { color: var(--ew-success); font-weight: var(--ew-font-bold); }

/* ── Spinner ─────────────────────────────────────────────────────────────────── */
.ew-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--ew-gray-200);
  border-top-color: var(--ew-primary);
  border-radius: 50%;
  animation: ew-spin 0.6s linear infinite;
}

/* ── Animations ──────────────────────────────────────────────────────────────── */
@keyframes ew-spin {
  to { transform: rotate(360deg); }
}
@keyframes ew-slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ew-fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .ew-header__nav { display: none; }
  .ew-header__menu-toggle { display: inline-flex; }
}

@media (max-width: 768px) {
  :root { --ew-container-pad: var(--ew-space-4); }

  .ew-topbar__right { display: none; }

  .ew-newsletter { flex-direction: column; text-align: center; }
  .ew-newsletter__form { width: 100%; justify-content: center; }
  .ew-newsletter__input { min-width: 0; flex: 1; }

  .ew-footer__widget-grid--2,
  .ew-footer__widget-grid--3,
  .ew-footer__widget-grid--4 { grid-template-columns: repeat(2, 1fr); }

  .ew-footer__bottom-inner { flex-direction: column; text-align: center; }
}

@media (max-width: 480px) {
  .ew-footer__widget-grid--2,
  .ew-footer__widget-grid--3,
  .ew-footer__widget-grid--4 { grid-template-columns: 1fr; }
}

/* ── Focus Styles (Accessibility) ────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--ew-accent);
  outline-offset: 2px;
}
