/* ═══════════════════════════════════════════════════════
   Bousba Deco — Mobile UX Optimization Layer
   Based on UI UX Pro Max Skill guidelines
   ═══════════════════════════════════════════════════════ */

/* ── 1. GLOBAL MOBILE RESET ─── */

/* Remove iOS tap highlight, replace with custom active states */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Prevent iOS auto-zoom on inputs (must be >= 16px) */
input, select, textarea {
  font-size: 16px !important;
}

/* Prevent accidental pull-to-refresh on scrollable elements */
html, body {
  overscroll-behavior-y: contain;
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .whatsapp-float { animation: none; }
  .fade-in { opacity: 1; transform: none; }
}

/* ── 2. HOVER STATES — Only on devices with hover support ─── */
@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover { background: #2d2926; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
  .btn--accent:hover { background: #b45309; transform: translateY(-2px); }
  .btn--whatsapp:hover { background: #1ebe57; transform: translateY(-2px); }
  .btn--outline:hover { background: var(--primary); color: var(--on-primary); }
  .cat-card:hover .cat-card__img { transform: scale(1.08); }
  .portfolio-card:hover img { transform: scale(1.06); }
  .partner-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
  .woocommerce ul.products li.product:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
  .cp-swatch:hover { transform: scale(1.25); z-index: 10; box-shadow: 0 4px 16px rgba(0,0,0,0.2); }
}

/* Disable hover transforms on touch devices to prevent "sticky" hover */
@media (hover: none) {
  .btn--primary:hover,
  .btn--accent:hover,
  .btn--whatsapp:hover,
  .btn--outline:hover { transform: none; }
  .cat-card:hover .cat-card__img { transform: none; }
  .portfolio-card:hover img { transform: none; }
  .partner-card:hover { transform: none; box-shadow: none; }
  .woocommerce ul.products li.product:hover { transform: none; box-shadow: none; }
  .cp-swatch:hover { transform: none; box-shadow: none; }
  
  /* Active state feedback for touch instead */
  .btn:active { transform: scale(0.97); opacity: 0.85; }
  .cat-card:active { opacity: 0.9; }
  .portfolio-card:active { opacity: 0.9; }
  .woocommerce ul.products li.product:active { opacity: 0.92; }
  .cp-swatch:active { transform: scale(1.15); border-color: var(--accent); }
}

/* ── 3. TOUCH TARGET SIZING (Min 44×44px) ─── */

/* All buttons minimum 44px height */
.btn,
.woocommerce a.button,
.woocommerce button.button,
.woocommerce input.button,
.woocommerce #respond input#submit,
.woocommerce div.product .single_add_to_cart_button,
.woocommerce ul.products li.product .button {
  min-height: 44px;
  min-width: 44px;
}

/* Navigation links on mobile */
@media (max-width: 768px) {
  .main-nav.open a,
  .main-nav.open .menu-item a {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    font-size: 1.05rem;
    border-bottom: 1px solid var(--border);
  }
  .main-nav.open a:last-child,
  .main-nav.open .menu-item:last-child a {
    border-bottom: none;
  }
}

/* Menu toggle — larger touch area */
.menu-toggle {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Footer links — larger touch area on mobile */
@media (max-width: 768px) {
  .footer-col a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 10px 0;
  }
  .footer-legal a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 6px;
  }
  .footer-social a {
    width: 48px;
    height: 48px;
  }
}

/* Color picker swatches — larger on mobile for finger taps */
@media (max-width: 768px) {
  .cp-swatch-grid {
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 4px;
  }
  .cp-swatch {
    min-width: 44px;
    min-height: 44px;
  }
  .cp-family-btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 0.9rem;
  }
  .cp-add-btn {
    min-height: 48px;
    font-size: 1.05rem;
  }
  .cp-room-label {
    min-height: 44px;
    padding: 8px 14px;
  }
  .cp-palette-chip__remove {
    width: 32px;
    height: 32px;
    opacity: 1; /* Always visible on mobile */
  }
}

/* WooCommerce quantity input — larger on mobile */
@media (max-width: 768px) {
  .woocommerce div.product .quantity input[type="number"] {
    min-height: 48px;
    min-width: 60px;
    font-size: 16px;
    text-align: center;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
  }
}

/* Touch spacing — minimum 8px between adjacent interactive elements */
@media (max-width: 768px) {
  .hero__actions { gap: 12px; }
  .cp-palette-actions { gap: 10px; }
  .woocommerce ul.products li.product .button { margin-bottom: 16px; }
}

/* ── 4. MOBILE NAVIGATION — Full-screen overlay ─── */
@media (max-width: 768px) {
  .main-nav.open {
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: var(--space-md) var(--space-md) var(--space-xl);
    box-shadow: none;
    border-bottom: none;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 999;
    animation: slideDown 0.25s ease;
  }
  
  /* Prevent body scroll when menu is open */
  body.menu-open { overflow: hidden; }
  
  @keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* ── 5. MOBILE HEADER — Compact & Functional ─── */
@media (max-width: 768px) {
  .header-inner { height: 64px; }
  .site-logo img { height: 38px; }
  .header-cta { padding: 8px 14px; font-size: 0.85rem; min-height: 40px; }
  /* Adjust hero margin for shorter header */
  .hero { margin-top: 64px; }
  .main-nav.open { top: 64px; }
}

/* ── 6. WOOCOMMERCE MOBILE FLOW ─── */
@media (max-width: 768px) {
  /* Product grid — 2 columns with proper spacing */
  .woocommerce ul.products {
    gap: 10px;
  }
  .woocommerce ul.products li.product .woocommerce-loop-product__title {
    font-size: 0.92rem;
    padding: 10px 12px 4px;
  }
  .woocommerce ul.products li.product .price {
    padding: 0 12px;
    font-size: 1rem;
  }
  .woocommerce ul.products li.product .button {
    margin: 8px 12px 12px;
    padding: 10px 16px;
    font-size: 0.9rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Single product page — full width layout */
  .woocommerce div.product {
    padding: var(--space-md) 0;
  }
  .woocommerce div.product .product_title {
    font-size: 1.5rem;
    margin-bottom: 8px;
  }
  .woocommerce div.product p.price {
    font-size: 1.3rem;
    margin-bottom: 12px;
  }
  .woocommerce div.product .single_add_to_cart_button {
    width: 100%;
    min-height: 52px;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Cart table — responsive card layout */
  .woocommerce table.shop_table,
  .woocommerce table.shop_table thead,
  .woocommerce table.shop_table tbody,
  .woocommerce table.shop_table tr,
  .woocommerce table.shop_table td {
    display: block;
    width: 100%;
  }
  .woocommerce table.shop_table thead { display: none; }
  .woocommerce table.shop_table tr {
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: relative;
  }
  .woocommerce table.shop_table td {
    padding: 6px 16px;
    text-align: right;
    border: none;
  }
  .woocommerce table.shop_table td::before {
    content: attr(data-title);
    font-weight: 600;
    float: left;
    color: var(--muted-fg);
  }
  .woocommerce table.shop_table td.product-thumbnail {
    text-align: center;
    padding-bottom: 0;
  }
  .woocommerce table.shop_table td.product-thumbnail img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin: 0 auto;
  }

  /* Checkout — full-width form fields */
  .woocommerce-checkout .col-1,
  .woocommerce-checkout .col-2 {
    float: none;
    width: 100%;
  }
  .woocommerce form .form-row {
    width: 100% !important;
    float: none !important;
    margin-bottom: 12px;
  }
  .woocommerce form .form-row input.input-text,
  .woocommerce form .form-row select,
  .woocommerce form .form-row textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 16px; /* Prevents iOS auto-zoom */
  }
  .woocommerce form .form-row label {
    font-size: 0.95rem;
    margin-bottom: 6px;
    display: block;
  }
}

/* ── 7. STICKY ADD TO CART — Single product pages ─── */
@media (max-width: 768px) {
  .woocommerce div.product form.cart {
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 12px 16px;
    margin: 0 -24px;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .woocommerce div.product form.cart .quantity {
    flex-shrink: 0;
  }
  .woocommerce div.product form.cart .single_add_to_cart_button {
    flex: 1;
    margin: 0;
  }
}

/* ── 8. COLOR PICKER MOBILE POLISH ─── */
@media (max-width: 768px) {
  /* Toolbar stays visible & scrollable */
  .cp-toolbar { padding: 10px 0; top: 64px; }
  .cp-toolbar__inner { padding: 0 4px; }

  /* Selected color — stack vertically */
  .cp-selected { gap: var(--space-md); }
  .cp-selected__name { font-size: 1.3rem; }
  .cp-selected__hex { font-size: 1rem; }

  /* Sliders — bigger thumb for touch */
  .cp-slider::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
    border-width: 3px;
  }
  .cp-slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-width: 3px;
  }
  .cp-slider {
    height: 10px;
  }
  .cp-slider-row label {
    min-width: 60px;
    font-size: 0.85rem;
  }

  /* Palette section — more breathing room */
  .cp-palette-section { padding: var(--space-md); }
  .cp-palette-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  
  /* Room preview — fits screen */
  .cp-room-wrap { padding: var(--space-md); }
  .cp-room-labels { gap: var(--space-xs); }
}

/* ── 9. GLOBAL FORM INPUTS ─── */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="url"],
select,
textarea {
  min-height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 10px 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(217,119,6,0.15);
}

/* ── 10. FOCUS VISIBLE — Keyboard navigation accessibility ─── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
:focus:not(:focus-visible) {
  outline: none;
}

/* ── 11. SMOOTH SCROLLBAR HIDE ON HORIZONTAL SCROLLABLES ─── */
.cp-toolbar__inner,
.cp-palette-strip {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cp-toolbar__inner::-webkit-scrollbar,
.cp-palette-strip::-webkit-scrollbar {
  display: none;
}

/* ── 12. SKELETON LOADING STATE (for lazy-loaded content) ─── */
.skeleton {
  background: linear-gradient(90deg, var(--muted) 25%, #e8e8e8 50%, var(--muted) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease infinite;
  border-radius: var(--radius-md);
}
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── 13. WHATSAPP FLOAT — Mobile positioning ─── */
@media (max-width: 768px) {
  .whatsapp-float {
    bottom: 16px;
    left: 16px;
    width: 52px;
    height: 52px;
  }
  .whatsapp-float svg { width: 28px; height: 28px; }
  
  /* If sticky cart is showing, push WhatsApp up */
  .single-product .whatsapp-float {
    bottom: 80px;
  }
}

/* ── 14. SMART CALCULATOR MOBILE ─── */
@media (max-width: 768px) {
  .smart-calc {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
  }
  .smart-calc__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .smart-calc__input {
    min-height: 48px;
    font-size: 16px;
    padding: 10px;
  }
  .smart-calc__result-row {
    padding: 10px 0;
    font-size: 0.92rem;
  }
  .smart-calc__result-highlight {
    padding: 12px 16px !important;
  }
  .smart-calc__result-total {
    padding: 14px 16px !important;
  }
}

/* ── 15. SCROLL-TO-TOP (optional enhancement) ─── */
.scroll-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 900;
  box-shadow: var(--shadow-md);
  transition: opacity 0.3s, transform 0.3s;
  opacity: 0;
  transform: translateY(10px);
}
.scroll-to-top.visible {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}
@media (max-width: 768px) {
  .scroll-to-top { bottom: 16px; right: 16px; }
  .single-product .scroll-to-top { bottom: 80px; }
}
