/**
 * PopRace.org - Mobile Optimizations
 * Responsive sidebar and enhanced card layouts for mobile devices
 */

/* ============================================
   MOBILE BREAKPOINT
   ============================================ */
@media (max-width: 768px) {

  /* ============================================
     MOBILE BOTTOM NAV FIXES
     ============================================ */

  /* Add padding to prevent mobile bottom nav overlap */
  #models-content {
    padding-bottom: 100px !important; /* 64px nav + 36px buffer */
  }

  /*
     NOTE: z-index for .view-density-controls and .filter-results-summary
     is now defined in styles.css and filters.css respectively.
     Removed duplicate rules here (Phase 2.2 cleanup).
  */

  /* ============================================
     RESPONSIVE FILTER SIDEBAR
     ============================================ */

  /* Make sidebar full-width on mobile, stacked above content */
  .filter-sidebar {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bs-body-bg, #fff);
    border-radius: var(--radius-xl); /* 12px - standardized (Phase 2.4) */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-height: none;
  }
  
  [data-bs-theme="dark"] .filter-sidebar {
    background: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
  
  /* Remove fixed positioning for mobile */
  .container-fluid {
    padding: 0;
  }
  
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }
  
  /* ============================================
     MOBILE CARD OPTIMIZATIONS
     ============================================ */
  
  /* Model Grid - Single Column */
  .model-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px;
  }
  
  /* Individual Model Cards */
  .model-card {
    background: var(--bs-body-bg, #fff);
    border-radius: var(--radius-2xl); /* 16px - standardized (Phase 2.4) */
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 0;
  }
  
  [data-bs-theme="dark"] .model-card {
    background: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
  
  /* Card Image Container */
  .model-card .card-img-top-container {
    position: relative;
    width: 100%;
    padding-top: 75%;
    overflow: hidden;
    background: #f8fafc;
  }
  
  [data-bs-theme="dark"] .model-card .card-img-top-container {
    background: #0f172a;
  }
  
  .model-card .card-img-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
  }
  
  /* Card Body */
  .model-card .card-body {
    padding: 16px;
  }
  
  /* Card Title */
  .model-card .card-title {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 8px;
    color: var(--bs-body-color);
  }
  
  /* Card Text */
  .model-card .card-text {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 12px;
    color: var(--bs-secondary-color, #64748b);
  }
  
  /* Badge Groups */
  .model-card .badge {
    font-size: 12px;
    padding: 4px 10px;
    margin-right: 6px;
    margin-bottom: 6px;
    border-radius: var(--radius-md); /* 6px - standardized (Phase 2.4) */
  }
  
  /* Touch targets (44px minimum) */
  .model-card .btn {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 500;
    border-radius: var(--radius-lg); /* ~10px (using 8px variable) - standardized (Phase 2.4) */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s, background-color 0.2s;
  }
  
  .model-card .btn:active {
    transform: scale(0.97);
  }
  
  /* Button Group */
  .model-card .btn-group {
    display: flex;
    gap: 8px;
    margin-top: 12px;
  }
  
  .model-card .btn-group .btn {
    flex: 1;
  }
  
  /* Card Footer */
  .model-card .card-footer {
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
  }
  
  [data-bs-theme="dark"] .model-card .card-footer {
    background: #0f172a;
    border-top-color: #334155;
  }
  
  /* Image Gallery */
  .model-card .image-gallery {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -16px;
    padding: 0 16px;
  }
  
  .model-card .image-gallery::-webkit-scrollbar {
    display: none;
  }
  
  .model-card .image-gallery img {
    flex-shrink: 0;
    width: 80%;
    max-width: 280px;
    height: 200px;
    object-fit: cover;
    border-radius: var(--radius-xl); /* 12px - standardized (Phase 2.4) */
    scroll-snap-align: center;
  }
  
  /* Image Counter Badge */
  .model-card .image-counter {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-full); /* pill shape - standardized (Phase 2.4) */
    backdrop-filter: blur(4px);
  }
  
  /* Status Badges */
  .model-card .status-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 6px 12px;
    border-radius: var(--radius-lg); /* 8px - standardized (Phase 2.4) */
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  
  .model-card .status-badge.new {
    background: #10b981;
    color: white;
  }
  
  .model-card .status-badge.limited {
    background: #f59e0b;
    color: white;
  }
  
  .model-card .status-badge.sold-out {
    background: #ef4444;
    color: white;
  }
  
  /* Specs Section */
  .model-card .specs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
  }
  
  .model-card .spec-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f1f5f9;
    border-radius: var(--radius-lg); /* 8px - standardized (Phase 2.4) */
    font-size: 13px;
  }
  
  [data-bs-theme="dark"] .model-card .spec-item {
    background: #334155;
  }
  
  .model-card .spec-item svg,
  .model-card .spec-item i {
    width: 16px;
    height: 16px;
    opacity: 0.7;
  }
  
  /* Price Display */
  .model-card .price {
    font-size: 20px;
    font-weight: 700;
    color: #3b82f6;
    margin-top: 8px;
  }
  
  [data-bs-theme="dark"] .model-card .price {
    color: #60a5fa;
  }
  
  /* Icon Buttons */
  .model-card .icon-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--bs-body-color);
    cursor: pointer;
    border-radius: var(--radius-lg); /* ~10px (using 8px variable) - standardized (Phase 2.4) */
    transition: background-color 0.2s, transform 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  .model-card .icon-btn:active {
    transform: scale(0.9);
  }
  
  .model-card .icon-btn:hover {
    background: rgba(59, 130, 246, 0.1);
  }
  
  .model-card .icon-btn.active {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
  }
  
  .model-card img {
    border-radius: var(--radius-xl); /* 12px - standardized (Phase 2.4) */
  }
  
  /* ============================================
     SEARCH BAR MOBILE
     ============================================ */
  
  .search-container {
    padding: 16px;
    background: var(--bs-body-bg, #fff);
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
  }
  
  [data-bs-theme="dark"] .search-container {
    background: rgba(15, 23, 42, 0.95);
    border-bottom-color: #334155;
  }
  
  .search-container input {
    font-size: 16px;
    min-height: 44px;
    padding: 12px 16px;
    border-radius: var(--radius-xl); /* 12px - standardized (Phase 2.4) */
    border: 2px solid #e2e8f0;
    width: 100%;
    transition: border-color 0.2s;
  }
  
  [data-bs-theme="dark"] .search-container input {
    border-color: #334155;
    background: #1e293b;
    color: #e2e8f0;
  }
  
  .search-container input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  }
  
  .search-container .search-icon {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
  }
  
  .search-container .results-count {
    font-size: 14px;
    color: var(--bs-secondary-color, #64748b);
    margin-top: 8px;
    text-align: center;
  }
  
  /* ============================================
     PERFORMANCE
     ============================================ */
  
  .model-grid {
    -webkit-overflow-scrolling: touch;
  }
  
  /* ============================================
     HORIZONTAL SCROLL GALLERY (OPTIONAL)
     ============================================ */
  
  .model-grid.horizontal-scroll {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 16px;
    padding: 16px;
    scrollbar-width: none;
  }
  
  .model-grid.horizontal-scroll::-webkit-scrollbar {
    display: none;
  }
  
  .model-grid.horizontal-scroll .model-card {
    flex: 0 0 85%;
    max-width: 340px;
    scroll-snap-align: center;
  }
  
  .scroll-indicator {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 16px 0;
  }
  
  .scroll-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e0;
    transition: background 0.3s, transform 0.3s;
  }
  
  [data-bs-theme="dark"] .scroll-indicator .dot {
    background: #4a5568;
  }
  
  .scroll-indicator .dot.active {
    background: #3b82f6;
    transform: scale(1.2);
  }
}

/* ============================================
   TABLET (768px - 1024px)
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {

  /* Add padding to prevent mobile bottom nav overlap on tablets */
  #models-content {
    padding-bottom: 100px !important;
  }

  .filter-sidebar {
    width: 220px;
  }

  .main-content {
    margin-left: 240px;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .model-card,
  .model-card .btn,
  .model-card .icon-btn {
    transition: none;
  }
}
