/* ==========================================
   MOBILE ENHANCEMENTS & INTERACTIONS
   Advanced mobile-specific improvements
   ========================================== */

/* ==========================================
   BETTER SCROLL BEHAVIOR
   ========================================== */

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
  /* Smooth momentum scrolling on iOS */
  body {
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent pull-to-refresh on Chrome mobile */
  body {
    overscroll-behavior-y: contain;
  }
}

/* ==========================================
   IMPROVED TOUCH INTERACTIONS
   ========================================== */

@media (hover: none) and (pointer: coarse) {
  /* Better button press feedback */
  button,
  .btn,
  a.btn {
    position: relative;
    transition: transform 0.1s ease;
  }

  button:active,
  .btn:active,
  a.btn:active {
    transform: scale(0.97);
  }

  /* Product cards tap feedback */
  .product-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }

  .product-card:active {
    transform: scale(0.98);
    box-shadow: 0 8px 20px rgba(11, 132, 132, 0.12);
  }

  /* Link tap areas */
  a {
    position: relative;
  }

  a::after {
    content: '';
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    z-index: -1;
  }
}

/* ==========================================
   STICKY ELEMENTS ON MOBILE
   ========================================== */

@media (max-width: 768px) {
  /* Sticky add to cart on product page */
  .product-actions-sticky {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 1rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 50;
    transform: translateY(100%);
    transition: transform 0.3s ease;
  }

  .product-actions-sticky.is-visible {
    transform: translateY(0);
  }

  /* Sticky cart total */
  .cart-summary-sticky {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 1.25rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    margin: 0 -1rem -1rem;
    border-radius: 16px 16px 0 0;
    z-index: 10;
  }

  /* Sticky checkout button */
  .checkout-submit-sticky {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 1rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    margin: 1rem -1rem -1rem;
    z-index: 10;
  }
}

/* ==========================================
   BOTTOM NAVIGATION BAR (OPTIONAL)
   ========================================== */

@media (max-width: 768px) {
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0.75rem 0;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    z-index: 100;
    border-top: 1px solid #e5e7eb;
  }

  .mobile-bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: #6b7280;
    font-size: 0.75rem;
    font-weight: 500;
    transition: color 0.2s ease;
    position: relative;
  }

  .mobile-bottom-nav__item.is-active {
    color: var(--color-primary);
  }

  .mobile-bottom-nav__icon {
    font-size: 1.25rem;
    position: relative;
  }

  .mobile-bottom-nav__badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background: var(--color-error);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
  }
}

/* ==========================================
   SWIPEABLE GALLERY
   ========================================== */

@media (max-width: 768px) {
  .product-gallery-mobile {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    touch-action: pan-y;
  }

  .product-gallery-mobile__track {
    display: flex;
    transition: transform 0.3s ease;
  }

  .product-gallery-mobile__slide {
    flex: 0 0 100%;
    width: 100%;
  }

  .product-gallery-mobile__dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
  }

  .product-gallery-mobile__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
    transition: all 0.3s ease;
    cursor: pointer;
  }

  .product-gallery-mobile__dot.is-active {
    width: 24px;
    border-radius: 4px;
    background: var(--color-primary);
  }
}

/* ==========================================
   PULL TO REFRESH INDICATOR
   ========================================== */

@media (max-width: 768px) {
  .pull-to-refresh {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    padding: 1rem;
    background: white;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    z-index: 1000;
  }

  .pull-to-refresh.is-visible {
    transform: translateX(-50%) translateY(0);
  }

  .pull-to-refresh__icon {
    animation: spin 1s linear infinite;
  }

  @keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }
}

/* ==========================================
   LOADING STATES
   ========================================== */

@media (max-width: 768px) {
  .skeleton-mobile {
    background: linear-gradient(
      90deg,
      #f0f0f0 25%,
      #e0e0e0 50%,
      #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
  }

  @keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }

  .skeleton-text {
    height: 16px;
    margin-bottom: 8px;
  }

  .skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 12px;
  }

  .skeleton-card {
    height: 200px;
    border-radius: 12px;
  }
}

/* ==========================================
   IMPROVED SEARCH ON MOBILE
   ========================================== */

@media (max-width: 768px) {
  .search-mobile-overlay {
    position: fixed;
    inset: 0;
    background: white;
    z-index: 1000;
    display: none;
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto;
  }

  .search-mobile-overlay.is-active {
    display: flex;
  }

  .search-mobile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
  }

  .search-mobile-close {
    font-size: 1.5rem;
    padding: 0.5rem;
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
  }

  .search-mobile-input {
    flex: 1;
    padding: 0.875rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 16px;
  }

  .search-mobile-results {
    flex: 1;
    overflow-y: auto;
  }
}

/* ==========================================
   FILTER DRAWER FOR MOBILE
   ========================================== */

@media (max-width: 768px) {
  .filter-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    max-height: 80vh;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .filter-drawer.is-open {
    transform: translateY(0);
  }

  .filter-drawer__handle {
    width: 40px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 12px auto 8px;
  }

  .filter-drawer__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
  }

  .filter-drawer__title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
  }

  .filter-drawer__close {
    font-size: 1.5rem;
    padding: 0.5rem;
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
  }

  .filter-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
  }

  .filter-drawer__footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 12px;
  }

  .filter-drawer__footer .btn {
    flex: 1;
  }
}

/* ==========================================
   TOAST NOTIFICATIONS (MOBILE)
   ========================================== */

@media (max-width: 768px) {
  .toast-mobile {
    position: fixed;
    bottom: 20px;
    left: 16px;
    right: 16px;
    background: white;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(calc(100% + 20px));
    transition: transform 0.3s ease;
    z-index: 1000;
  }

  .toast-mobile.is-visible {
    transform: translateY(0);
  }

  .toast-mobile__icon {
    font-size: 1.5rem;
    flex-shrink: 0;
  }

  .toast-mobile__content {
    flex: 1;
  }

  .toast-mobile__title {
    font-weight: 600;
    margin: 0 0 4px;
  }

  .toast-mobile__message {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
  }

  .toast-mobile__close {
    font-size: 1.25rem;
    padding: 0.5rem;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
  }

  /* Success toast */
  .toast-mobile--success .toast-mobile__icon {
    color: var(--color-success);
  }

  /* Error toast */
  .toast-mobile--error .toast-mobile__icon {
    color: var(--color-error);
  }

  /* Warning toast */
  .toast-mobile--warning .toast-mobile__icon {
    color: var(--color-warning);
  }
}

/* ==========================================
   QUANTITY SELECTOR IMPROVEMENTS
   ========================================== */

@media (max-width: 768px) {
  .quantity-selector {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
  }

  .quantity-selector__btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: none;
    color: #4b5563;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.2s ease;
  }

  .quantity-selector__btn:active {
    background: #f3f4f6;
  }

  .quantity-selector__input {
    width: 60px;
    height: 44px;
    border: none;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
  }
}

/* ==========================================
   ACCORDION/COLLAPSIBLE (MOBILE)
   ========================================== */

@media (max-width: 768px) {
  .accordion-mobile {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
  }

  .accordion-mobile__item {
    border-bottom: 1px solid #e5e7eb;
  }

  .accordion-mobile__item:last-child {
    border-bottom: none;
  }

  .accordion-mobile__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: white;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-weight: 600;
    color: #1f2937;
    transition: background 0.2s ease;
  }

  .accordion-mobile__header:active {
    background: #f9fafb;
  }

  .accordion-mobile__icon {
    transition: transform 0.3s ease;
  }

  .accordion-mobile__item.is-open .accordion-mobile__icon {
    transform: rotate(180deg);
  }

  .accordion-mobile__content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
  }

  .accordion-mobile__item.is-open .accordion-mobile__content {
    max-height: 1000px;
    padding: 0 1.25rem 1rem;
  }
}

/* ==========================================
   FLOATING ACTION BUTTON
   ========================================== */

@media (max-width: 768px) {
  .fab {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 8px 24px rgba(11, 132, 132, 0.3);
    border: none;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 90;
  }

  .fab:active {
    transform: scale(0.95);
  }

  .fab--whatsapp {
    background: #25d366;
  }

  .fab--scroll-top {
    opacity: 0;
    pointer-events: none;
  }

  .fab--scroll-top.is-visible {
    opacity: 1;
    pointer-events: auto;
  }
}
