/* Mobile Optimizations for DigiShop */

/* Better spacing on mobile */
@media (max-width: 640px) {
  /* Reduce padding on cards */
  .card-content {
    padding: 0.75rem !important;
  }
  
  /* Compact header */
  header .container {
    padding: 0.75rem 1rem;
  }
  
  /* Compact quick actions */
  .card-header {
    padding: 0.5rem;
  }
  
  /* Smaller icons on mobile */
  .card-header svg {
    width: 1.25rem;
    height: 1.25rem;
  }
  
  /* Compact tabs */
  .tab-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }
  
  /* Better product grid spacing */
  .product-grid {
    gap: 0.5rem;
  }
  
  /* Compact stats cards */
  .stats-card .card-header {
    padding: 0.75rem;
  }
  
  /* Compact modal content */
  .modal-content {
    padding: 1rem;
    margin: 0.5rem;
  }
  
  /* Better form spacing */
  form.space-y-4 > * {
    margin-bottom: 0.75rem;
  }
  
  /* Compact buttons in grids */
  .grid .btn {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
  }
  
  /* Hide less important text on mobile */
  .card-action-hint {
    display: none;
  }
  
  /* Compact receipt history */
  #receipts-history-container .flex {
    padding: 0.5rem;
  }
  
  /* Better chart containers */
  canvas {
    max-height: 150px !important;
  }
}

/* Tablet optimizations */
@media (min-width: 641px) and (max-width: 1024px) {
  .card-content {
    padding: 1rem 1.25rem;
  }
  
  canvas {
    max-height: 200px !important;
  }
}

/* Better line clamping */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Compact receipt items */
@media (max-width: 640px) {
  #receipts-history-container .flex {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  #receipts-history-container .flex > div:last-child {
    width: 100%;
    flex-direction: row;
  }
  
  #receipts-history-container .btn {
    flex: 1;
  }
}

/* Better scrollbar on mobile */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* Compact subscription cards */
@media (max-width: 640px) {
  #subscriptions-container .card {
    padding: 0.75rem;
  }
  
  #subscriptions-container .grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

/* Better user cards on mobile */
@media (max-width: 640px) {
  #users-container .card-content {
    padding: 0.75rem;
  }
  
  #users-container .flex {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  #users-container .btn {
    width: 100%;
  }
}

/* Compact activities */
@media (max-width: 640px) {
  #activities-container .flex {
    padding: 0.5rem;
    gap: 0.5rem;
  }
  
  #activities-container p {
    font-size: 0.75rem;
  }
}

/* Better billboard on mobile */
@media (max-width: 640px) {
  #billboard-banner .bg-gradient-primary {
    padding: 0.75rem;
  }
  
  #billboard-banner h3 {
    font-size: 0.875rem;
  }
  
  #billboard-banner p {
    font-size: 0.75rem;
  }
}

/* Compact header buttons */
@media (max-width: 640px) {
  header .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }
  
  header .btn svg {
    width: 1rem;
    height: 1rem;
  }
}

/* Better product cards spacing */
@media (max-width: 640px) {
  #products-container .product-card {
    padding: 0.5rem;
  }
  
  /* Fix product card images to show full image without cropping on mobile */
  #products-container .product-card .aspect-square,
  #products-container .product-card .relative.aspect-square {
    aspect-ratio: auto !important;
    height: auto !important;
    min-height: 200px !important;
    max-height: 300px !important;
    overflow: visible !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: var(--muted) !important;
  }
  
  #products-container .product-card img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 300px !important;
    min-height: 200px !important;
    object-fit: contain !important;
    object-position: center !important;
    display: block !important;
    border-radius: 0.5rem !important;
    margin: 0 auto !important;
  }
  
  /* Override inline styles from JavaScript */
  #products-container .product-card .relative[style*="aspect-ratio"],
  #products-container .product-card .relative[style*="aspect-ratio: 1 / 1"] {
    aspect-ratio: auto !important;
    height: auto !important;
  }
  
  #products-container .product-card img[style*="object-fit: cover"],
  #products-container .product-card img[style*="object-fit"] {
    object-fit: contain !important;
    height: auto !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  #products-container .product-card img[style*="width: 100%"],
  #products-container .product-card img[style*="height: 100%"] {
    height: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    object-fit: contain !important;
  }
  
  #products-container .product-card .relative {
    overflow: visible !important;
  }
  
  /* Shop view header improvements */
  header .container {
    padding: 0.75rem 1rem !important;
  }
  
  /* Product grid on mobile */
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
  }
  
  /* Cart drawer improvements */
  #cart-drawer {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  /* Ensure cart items are properly sized on mobile */
  #cart-drawer .card {
    margin-bottom: 0.75rem !important;
  }
  
  #cart-drawer .card .flex {
    gap: 0.75rem !important;
  }
  
  /* Payment method selection on mobile */
  #payment-method-selection {
    margin-bottom: 0.75rem !important;
  }
  
  /* Checkout button always visible on mobile */
  #cart-drawer #checkout-btn {
    position: relative !important;
    z-index: 20 !important;
    margin-top: 0.75rem !important;
  }
}

/* ============================================
   SHOP VIEW PAGE - COMPREHENSIVE MOBILE RESPONSIVE
   ============================================ */

/* Mobile Header Optimizations */
@media (max-width: 640px) {
  /* Shop view header */
  #shop-view-page header,
  header.sticky {
    padding: 0.5rem 0 !important;
  }
  
  header .container {
    padding: 0.75rem 0.5rem !important;
  }
  
  /* Shop owner avatar */
  #shop-owner-avatar {
    width: 2.5rem !important;
    height: 2.5rem !important;
    min-width: 2.5rem !important;
    min-height: 2.5rem !important;
  }
  
  /* Shop name and welcome message */
  #shop-name {
    font-size: 1rem !important;
    line-height: 1.2 !important;
  }
  
  #welcome-message {
    font-size: 0.625rem !important;
    line-height: 1.2 !important;
    margin-bottom: 0.25rem !important;
  }
  
  /* Contact number */
  #shop-contact-text {
    font-size: 0.625rem !important;
  }
  
  /* Header buttons */
  header .btn {
    padding: 0.375rem !important;
    min-width: 2rem !important;
    min-height: 2rem !important;
  }
  
  header .btn svg {
    width: 1rem !important;
    height: 1rem !important;
  }
  
  /* Suspension banner */
  #suspension-banner {
    margin-bottom: 0.75rem !important;
    padding: 0.75rem !important;
  }
  
  #suspension-banner h3 {
    font-size: 0.875rem !important;
  }
  
  #suspension-banner p {
    font-size: 0.75rem !important;
  }
  
  /* Billboard section */
  #billboard-toggle {
    padding: 0.5rem !important;
  }
  
  #billboard-toggle h2 {
    font-size: 0.875rem !important;
  }
  
  #billboard-toggle svg {
    width: 1rem !important;
    height: 1rem !important;
  }
  
  #billboard-posts-container {
    margin-top: 0.75rem !important;
  }
}

/* Main Content Area */
@media (max-width: 640px) {
  /* Main container */
  main.container {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    padding-top: 0.75rem !important;
    padding-bottom: 5.5rem !important; /* Space for bottom nav */
  }
  
  /* Search and filter bar */
  #search-input,
  #sort-select {
    font-size: 0.875rem !important;
    padding: 0.625rem 0.75rem !important;
    min-height: 44px !important; /* Better touch target */
  }
  
  #search-input {
    padding-left: 2.5rem !important;
  }
  
  /* Category filters */
  #category-filters {
    gap: 0.5rem !important;
    padding-bottom: 0.5rem !important;
  }
  
  #category-filters button {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.75rem !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
  
  /* Products section header */
  #products-section h2 {
    font-size: 1.125rem !important;
    margin-bottom: 0.75rem !important;
  }
  
  #products-count {
    font-size: 0.75rem !important;
  }
  
  /* Product cards */
  .product-grid .card,
  #products-container .card {
    padding: 0.5rem !important;
    border-radius: 0.5rem !important;
  }
  
  .product-grid .card img,
  #products-container .card img {
    height: 120px !important;
    object-fit: cover !important;
    border-radius: 0.375rem !important;
  }
  
  .product-grid .card h3,
  #products-container .card h3 {
    font-size: 0.875rem !important;
    line-height: 1.3 !important;
    margin: 0.5rem 0 0.25rem 0 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }
  
  .product-grid .card .text-primary,
  #products-container .card .text-primary {
    font-size: 1rem !important;
    font-weight: 700 !important;
  }
  
  .product-grid .card .text-muted-foreground,
  #products-container .card .text-muted-foreground {
    font-size: 0.75rem !important;
  }
  
  /* No products message */
  #no-products {
    margin: 0.5rem !important;
    padding: 2rem 1rem !important;
  }
  
  #no-products svg {
    width: 3rem !important;
    height: 3rem !important;
  }
  
  #no-products p {
    font-size: 0.875rem !important;
  }
}

/* Announcements Section */
@media (max-width: 640px) {
  #announcements-section .card-content {
    padding: 1rem !important;
  }
  
  #announcements-section h2 {
    font-size: 1.125rem !important;
  }
  
  #announcements-container .card {
    padding: 0.75rem !important;
    margin-bottom: 0.75rem !important;
  }
  
  #announcements-container h3 {
    font-size: 1rem !important;
    margin-bottom: 0.5rem !important;
  }
  
  #announcements-container p {
    font-size: 0.875rem !important;
    line-height: 1.5 !important;
  }
}

/* About Section */
@media (max-width: 640px) {
  #about-section .card-content {
    padding: 1rem !important;
  }
  
  #about-section h2 {
    font-size: 1.125rem !important;
  }
  
  #shop-info-content {
    gap: 1rem !important;
  }
  
  #shop-info-content .flex {
    gap: 0.75rem !important;
  }
  
  #shop-info-content svg {
    width: 1rem !important;
    height: 1rem !important;
    margin-top: 0.125rem !important;
  }
  
  #shop-info-content p {
    font-size: 0.875rem !important;
  }
  
  /* Quick actions */
  #about-section .grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
  
  #about-section .grid .btn {
    width: 100% !important;
    padding: 0.75rem 1rem !important;
    min-height: 44px !important;
  }
}

/* Product Detail Modal */
@media (max-width: 640px) {
  #product-detail-modal {
    padding: 0.5rem !important;
    padding-bottom: 80px !important; /* Space for fixed Add to Cart button */
    align-items: flex-start !important;
    z-index: 60 !important; /* Above bottom nav */
  }
  
  #product-detail-modal > div:last-child {
    max-width: 100% !important;
    max-height: calc(100vh - 80px) !important; /* Reserve space for fixed button */
    border-radius: 0.75rem !important;
    margin-bottom: 80px !important; /* Space for fixed Add to Cart button */
  }
  
  #close-product-detail {
    top: 0.5rem !important;
    right: 0.5rem !important;
    width: 2.5rem !important;
    height: 2.5rem !important;
    min-width: 40px !important;
    min-height: 40px !important;
    padding: 0 !important;
    z-index: 30 !important;
    background-color: var(--card) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
  }
  
  #product-detail-main-image {
    max-height: 35vh !important;
    min-height: 200px !important;
    object-fit: contain !important; /* Show full image */
  }
  
  #product-detail-name {
    font-size: 1.25rem !important;
    line-height: 1.3 !important;
    word-wrap: break-word !important;
  }
  
  #product-detail-price-display {
    font-size: 1.5rem !important;
  }
  
  #product-detail-description {
    font-size: 0.875rem !important;
    line-height: 1.5 !important;
    word-wrap: break-word !important;
  }
  
  /* Purchase type options on mobile */
  #product-detail-purchase-type {
    margin-bottom: 1rem !important;
  }
  
  .purchase-type-option {
    min-height: 60px !important;
    padding: 0.75rem !important;
    font-size: 0.875rem !important;
  }
  
  /* Quantity controls on mobile */
  #product-detail-decrease-qty,
  #product-detail-increase-qty {
    min-width: 44px !important;
    min-height: 44px !important;
    font-size: 1.25rem !important;
  }
  
  #product-detail-quantity {
    min-height: 44px !important;
    font-size: 16px !important; /* Prevent zoom on iOS */
  }
  
  /* Total price on mobile */
  #product-detail-total-price {
    font-size: 1.25rem !important;
  }
  
  #product-detail-add-to-cart {
    padding: 0.875rem 1rem !important;
    font-size: 1rem !important;
    min-height: 48px !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  
  /* Ensure Add to Cart button container is fixed on mobile */
  #product-detail-modal .product-detail-info-section > div:last-child {
    position: fixed !important;
    bottom: calc(70px + env(safe-area-inset-bottom)) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 70 !important;
    padding: 1rem !important;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
    background-color: var(--card) !important;
    border-top: 1px solid var(--border) !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15) !important;
  }
}

/* Bottom Navigation */
@media (max-width: 640px) {
  nav.fixed.bottom-0 {
    padding-bottom: env(safe-area-inset-bottom) !important;
    min-height: 60px !important;
  }
  
  nav.fixed.bottom-0 .container {
    padding: 0.5rem 0.25rem !important;
  }
  
  .bottom-nav-btn {
    padding: 0.375rem 0.25rem !important;
    min-height: 48px !important;
    gap: 0.125rem !important;
  }
  
  .bottom-nav-btn svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
  }
  
  .bottom-nav-btn span {
    font-size: 0.625rem !important;
    line-height: 1.2 !important;
  }
  
  #bottom-cart-count {
    width: 1.125rem !important;
    height: 1.125rem !important;
    font-size: 0.625rem !important;
    top: -0.25rem !important;
    right: -0.25rem !important;
  }
}

/* Chatbot */
@media (max-width: 640px) {
  #chatbot-toggle {
    width: 3rem !important;
    height: 3rem !important;
    bottom: 5rem !important;
    right: 1rem !important;
  }
  
  #chatbot-toggle svg {
    width: 1.5rem !important;
    height: 1.5rem !important;
  }
  
  #chatbot-window {
    width: calc(100vw - 2rem) !important;
    max-width: 100% !important;
    height: calc(100vh - 8rem) !important;
    max-height: 600px !important;
    bottom: 5rem !important;
    right: 1rem !important;
    left: 1rem !important;
    border-radius: 0.75rem !important;
  }
  
  #chat-messages {
    padding: 0.75rem !important;
    font-size: 0.875rem !important;
  }
  
  #chat-input {
    font-size: 0.875rem !important;
    padding: 0.625rem 0.75rem !important;
    min-height: 44px !important;
  }
  
  #send-chat-btn {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0.5rem !important;
  }
}

/* Footer */
@media (max-width: 640px) {
  footer {
    padding: 2rem 1rem !important;
  }
  
  footer .grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }
  
  footer h3 {
    font-size: 1rem !important;
    margin-bottom: 0.75rem !important;
  }
  
  footer p,
  footer li {
    font-size: 0.875rem !important;
    line-height: 1.6 !important;
  }
}

/* Tablet Optimizations */
@media (min-width: 641px) and (max-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 1rem !important;
  }
  
  main.container {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  
  #product-detail-modal {
    padding: 1rem !important;
  }
  
  #product-detail-modal > div:last-child {
    max-width: 90% !important;
    max-height: 90vh !important;
  }
  
  #product-detail-modal .product-detail-image-section {
    max-height: 50vh !important;
  }
  
  #product-detail-modal .product-detail-main-image {
    max-height: 45vh !important;
    object-fit: contain !important;
  }
  
  #product-detail-modal .product-detail-info-section {
    padding-bottom: 120px !important; /* Space for sticky button */
  }
  
  #product-detail-modal .product-detail-info-section > div:last-child {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 10 !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
  }
  
  #product-detail-add-to-cart {
    min-height: 48px !important;
    padding: 0.875rem 1rem !important;
    font-size: 1rem !important;
  }
}

/* Compact stats overview */
@media (max-width: 640px) {
  #stats-details .flex {
    padding: 0.5rem 0;
    font-size: 0.875rem;
  }
}

/* Better modal on mobile */
@media (max-width: 640px) {
  .modal-content {
    max-width: calc(100vw - 1rem);
    max-height: calc(100vh - 2rem);
  }
  
  .modal-content .card {
    margin-bottom: 1rem;
  }
}

/* Compact subscription stats */
@media (max-width: 640px) {
  #stat-total-subscriptions,
  #stat-active-subscriptions,
  #stat-subscription-revenue {
    font-size: 1.5rem;
  }
}

/* Better chart responsiveness */
canvas {
  width: 100% !important;
  height: auto !important;
}

/* Compact announcement cards */
@media (max-width: 640px) {
  #platform-announcements-banner .card {
    padding: 0.75rem;
  }
}

