/* ============================================================================
   MOBILE RESPONSIVE ENHANCEMENTS
   Add this to the END of styles.css for better mobile experience
   ============================================================================ */

/* Touch-friendly buttons and inputs */
@media (max-width: 767px) {
  input, textarea, select, button, .btn {
    min-height: 44px; /* Apple's recommended touch target size */
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
  
  /* Smaller profile avatar button on mobile (don't force 44px height) */
  #account-toggle {
    min-height: 30px;
  }

  #account-toggle.has-profile-photo {
    width: 30px;
    height: 30px;
  }
  
  /* Better form spacing on mobile */
  .form-group {
    margin-bottom: var(--space-4);
  }
  
  .form-label {
    font-size: 0.9rem;
    margin-bottom: var(--space-2);
  }
  
  /* Mobile-friendly tables */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  table thead {
    display: none;
  }
  
  table tr {
    display: block;
    margin-bottom: var(--space-4);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: var(--space-3);
  }
  
  table td {
    display: block;
    text-align: right;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-primary);
  }
  
  table td:last-child {
    border-bottom: none;
  }
  
  table td:before {
    content: attr(data-label);
    float: left;
    font-weight: 600;
    color: var(--text-secondary);
  }
  
  /* Cart improvements */
  .cart-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: var(--space-3);
  }
  
  .cart-item-image {
    width: 100% !important;
    max-width: 200px;
    margin: 0 auto;
  }
  
  .cart-item-details {
    width: 100%;
  }
  
  .cart-item-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  /* Product details improvements */
  .product-gallery {
    flex-direction: column !important;
  }
  
  .product-images {
    width: 100% !important;
  }
  
  .product-info {
    width: 100% !important;
  }
  
  /* Admin dashboard improvements */
  .admin-grid {
    grid-template-columns: 1fr !important;
  }
  
  .dashboard-card {
    min-height: auto !important;
  }
  
  /* Search bar improvements */
  .search-container {
    width: 100%;
    padding: 0 var(--space-2);
  }
  
  .search-input {
    font-size: 16px; /* Prevent iOS zoom */
    padding: var(--space-3) var(--space-4);
  }
  
  /* Modal improvements for mobile */
  .modal {
    margin: 0;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  
  .modal-content {
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }
  
  /* Checkout page improvements */
  .checkout-container {
    flex-direction: column !important;
  }
  
  .checkout-form, .order-summary {
    width: 100% !important;
  }
  
  /* Orders page improvements */
  .order-card {
    padding: var(--space-3);
  }
  
  .order-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: var(--space-2);
  }
  
  .order-items {
    overflow-x: auto;
  }
}

/* Extra mobile optimizations */
@media (max-width: 575px) {
  /* Prevent horizontal scroll */
  body {
    overflow-x: hidden;
  }
  
  /* Better spacing for small screens */
  * {
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Optimize images */
  img {
    max-width: 100%;
    height: auto;
  }
  
  /* Better spacing for cards in grids */
  .product-card, .category-card {
    margin: 0 auto;
    max-width: 100%;
  }
  
  /* Sticky header improvements — use background-color only so botanical SVG texture is preserved */
  .navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: #0d3d18;
    box-shadow: 0 2px 8px rgba(0,0,0,0.24);
  }
  
  /* Footer stacking */
  .footer-links {
    flex-direction: column;
    gap: var(--space-4);
  }
  
  .footer-column {
    width: 100%;
  }
  
  /* Authentication forms */
  .auth-container {
    padding: var(--space-4) var(--space-3);
    max-width: 100%;
  }
  
  .auth-card {
    padding: var(--space-5) var(--space-3);
  }
  
  /* Address cards */
  .address-card {
    padding: var(--space-3);
  }
  
  .address-actions {
    flex-direction: column;
    gap: var(--space-2);
  }
  
  .address-actions .btn {
    width: 100%;
  }
}

/* Landscape mode optimizations for phones */
@media (max-height: 600px) and (orientation: landscape) {
  .hero {
    padding: var(--space-6) var(--space-3);
  }
  
  .hero h1 {
    font-size: 1.5rem;
  }
  
  .hero p {
    font-size: 0.85rem;
    margin-bottom: var(--space-3);
  }
  
  .modal {
    max-height: 100vh;
  }
  
  .navbar {
    height: 50px;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Note: automatic OS dark-mode styles removed so that
   the site only goes dark when the in-site theme toggle
   adds the .dark-mode class on <body>. This keeps colors
   consistent across different browsers. */

/* ============================================================================
   AMAZON-STYLE MOBILE ECOMMERCE UX ENHANCEMENTS
   ============================================================================ */

@media (max-width: 768px) {

  /* ── Larger touch targets for all interactive elements ── */
  .btn, button:not(.icon-button), [role="button"]:not(.icon-button),
  .carousel-nav, .hero-dot,
  .add-cart-cta, .product-action-row .btn {
    min-height: 48px;
    min-width: 48px;
  }

  /* Keep navbar icon buttons compact */
  .icon-button {
    min-height: unset !important;
    min-width: unset !important;
    width: 40px !important;
    height: 40px !important;
  }

  .hero-dot {
    width: 10px;
    height: 10px;
    min-width: 10px;
    min-height: 10px;
    padding: 6px;
    box-sizing: content-box;
  }

  /* ── Product card – elevated shadow + rounded corners ── */
  .product-card {
    border-radius: 14px !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.07) !important;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
  }

  .product-card:active {
    transform: scale(0.985);
    box-shadow: 0 1px 6px rgba(0,0,0,0.10) !important;
  }

  /* ── Product grids – restore normal responsive grid, vertical scroll ── */
  .grid.grid-4,
  .grid.grid-3,
  .grid.grid-2 {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    flex-direction: unset !important;
    flex-wrap: unset !important;
    overflow-x: unset !important;
    scroll-snap-type: unset !important;
    gap: 0.75rem !important;
    padding: 0.5rem 1rem 1rem !important;
    scrollbar-width: auto;
  }

  .grid.grid-4 > .product-card,
  .grid.grid-3 > .product-card,
  .grid.grid-2 > .product-card {
    flex: unset !important;
    max-width: 100% !important;
    width: 100% !important;
    scroll-snap-align: unset;
  }

  /* ── Section headings – Amazon-style compact spacing ── */
  .section-title {
    padding: 1rem 1rem 0.5rem !important;
    margin-bottom: 0 !important;
  }

  .section-title h2 {
    font-size: 1.15rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.01em;
    margin: 0 !important;
  }

  #homepage-sections-container > section.container {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-bottom: 1.5rem !important;
  }

  /* ── Carousel items – snap + proper sizing ── */
  .carousel-track {
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
  }

  .carousel-item {
    scroll-snap-align: start;
    border-radius: 12px !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.10) !important;
  }

  /* ── Sticky bottom "Add to Cart" bar – shown on product detail ── */
  .sticky-cart-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 900;
    background: var(--bg-primary, #fff);
    border-top: 1px solid var(--border-primary, #e5e7eb);
    padding: 0.65rem 1rem env(safe-area-inset-bottom, 0.65rem);
    display: flex;
    gap: 0.65rem;
    align-items: center;
    box-shadow: 0 -4px 18px rgba(0,0,0,0.11);
    transition: transform 0.25s ease;
  }

  .sticky-cart-bar.hidden {
    transform: translateY(110%);
  }

  .sticky-cart-bar .btn {
    flex: 1;
    font-size: 1rem !important;
    font-weight: 700 !important;
    padding: 0.85rem 1rem !important;
    border-radius: 10px !important;
    min-height: 52px;
  }

  /* Reserve space at bottom so content isn't hidden behind sticky bar */
  body.has-sticky-cart-bar {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  /* ── Flip cards – tighter spacing on mobile ── */
  .flip-cards-section {
    padding: 1.25rem 0 1.5rem !important;
  }

  .flip-cards-container {
    padding: 0 0.75rem !important;
  }

  /* ── Category track – more breathing room ── */
  .category-carousel .carousel-track-container {
    padding: 0.25rem 0 0.5rem;
  }

  /* ── Better badge / price contrast on cards ── */
  .product-price {
    font-size: 1.15rem !important;
    font-weight: 800 !important;
  }

  /* ── Smoother page-level scroll ── */
  html {
    scroll-behavior: smooth;
  }
}
