/* ===========================
   SEARCH PAGE STYLES
   =========================== */
:root {
    --primary: #28a745;
    --primary-dark: #1e7e34;
    --primary-light: rgba(40, 167, 69, 0.08);
    --accent: #2ecc71;
    --accent-light: #a8e6cf;
    --price-color: #ff4757;
    --price-gradient: linear-gradient(135deg, #ff6b6b 0%, #ff4757 100%);
    --bg-light: #f8f9fa;
    --white: #ffffff;
    --text-dark: #1a1a1a;
    --text-muted: #6c757d;
    --border: #e9ecef;
    --border-light: #f1f3f5;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-premium: 0 12px 32px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --radius-sm: 6px;
    --radius-lg: 16px;
}

* {
    box-sizing: border-box;
}

body {
    background: linear-gradient(180deg, #f8f9fa 0%, #ffffff 100%);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    color: var(--text-dark);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===========================
   HEADER STYLES
   =========================== */
.header {
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.04);
    border-bottom: 1px solid var(--border-light);
    backdrop-filter: blur(10px);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary);
    font-size: 18px;
    pointer-events: none;
    z-index: 1;
}

.search-input {
    width: 100%;
    padding: 16px 24px 16px 52px;
    border: 2px solid var(--border);
    border-radius: 50px;
    background: var(--white);
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-dark);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(40, 167, 69, 0.15);
    background: #ffffff;
}

.search-input::placeholder {
    color: #adb5bd;
}

/* ===========================
   ENHANCED FILTER SECTION
   =========================== */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
}

.search-filter {
    padding: 16px 20px;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 89px;
    z-index: 999;
    backdrop-filter: blur(10px);
}

.filter-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 4px 0;
}

.filter-tabs::-webkit-scrollbar {
    display: none;
}

.filter-tab {
    padding: 10px 24px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid var(--border);
    user-select: none;
    position: relative;
    overflow: hidden;
}

.filter-tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-light) 0%, rgba(46, 204, 113, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.filter-tab:hover {
    border-color: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.1);
}

.filter-tab:hover::before {
    opacity: 1;
}

.filter-tab.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: var(--white);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.filter-tab.active::before {
    opacity: 0;
}

.search-info {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    font-weight: 500;
}

.search-info i {
    color: var(--primary);
}

/* ===========================
   PREMIUM GRID SYSTEM
   =========================== */
.posts-container {
    padding: 20px;
    background: transparent;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.users-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

/* Responsive breakpoints */
@media (min-width: 640px) {
    .products-grid { 
        grid-template-columns: repeat(3, 1fr);
        gap: 14px;
    }
}

@media (min-width: 768px) {
    .products-grid { 
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
    .users-grid { 
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .products-grid { 
        grid-template-columns: repeat(5, 1fr);
        gap: 18px;
    }
    .users-grid { 
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) {
    .products-grid { 
        grid-template-columns: repeat(6, 1fr);
    }
}

/* ===========================
   PREMIUM PRODUCT CARD - DOMINANT IMAGES
   =========================== */
.product-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border-light);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(40, 167, 69, 0.02) 0%, rgba(46, 204, 113, 0.02) 100%);
    opacity: 0;
    transition: opacity 0.35s ease;
    z-index: 1;
    pointer-events: none;
}

.product-card:hover {
    box-shadow: var(--shadow-premium);
    transform: translateY(-6px);
    border-color: var(--accent-light);
}

.product-card:hover::before {
    opacity: 1;
}

.product-card:active {
    transform: translateY(-3px);
}

.product-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    overflow: hidden;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card:hover .product-image {
    transform: scale(1.08);
}

.product-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 10px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 3px 8px rgba(40, 167, 69, 0.35);
    z-index: 2;
    backdrop-filter: blur(4px);
}

.product-badge.used {
    background: linear-gradient(135deg, #ff9800 0%, #ff6f00 100%);
    box-shadow: 0 3px 8px rgba(255, 152, 0, 0.35);
}

.product-info {
    padding: 12px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: var(--white);
    position: relative;
    z-index: 2;
}

.product-price {
    font-size: 20px;
    font-weight: 800;
    background: var(--price-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.product-description {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-dark);
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 39px;
    flex-grow: 1;
    font-weight: 500;
}

.product-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

.product-meta div {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-meta i {
    font-size: 11px;
    flex-shrink: 0;
    color: var(--primary);
}

.product-meta span {
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.product-footer {
    display: none;
}

/* ===========================
   PREMIUM USER CARD
   =========================== */
.user-card {
    background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
    padding: 16px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--border-light);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.user-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary) 0%, var(--accent) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.user-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    border-color: var(--accent-light);
    transform: translateX(4px);
}

.user-card:hover::before {
    opacity: 1;
}

.user-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--accent-light) 100%);
    flex-shrink: 0;
    border: 3px solid var(--white);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1);
}

.user-info {
    flex-grow: 1;
    min-width: 0;
}

.user-name {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-dark);
}

.user-username {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.btn-view-profile {
    padding: 8px 18px;
    border: 2px solid var(--primary);
    color: var(--primary);
    background: transparent;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-view-profile:hover {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.25);
    transform: translateY(-2px);
}

/* ===========================
   PREMIUM SECTION HEADERS
   =========================== */
.results-section {
    margin-bottom: 36px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 3px solid transparent;
    background: linear-gradient(90deg, var(--border) 0%, transparent 100%) bottom / 100% 3px no-repeat;
    position: relative;
}

.section-header::before {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
}

.section-header i {
    color: var(--primary);
    font-size: 20px;
    background: var(--primary-light);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.section-header h2 {
    font-size: 20px;
    font-weight: 800;
    margin: 0;
    color: var(--text-dark);
    letter-spacing: -0.3px;
}

.section-count {
    background: linear-gradient(135deg, var(--primary-light) 0%, rgba(46, 204, 113, 0.15) 100%);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 700;
    margin-left: auto;
    border: 1px solid var(--accent-light);
}

/* ===========================
   PREMIUM LOADING STATES
   =========================== */
.loading-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--border-light);
    border-top: 4px solid var(--primary);
    border-right: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    margin: 0 auto;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.15);
}

@keyframes spin { 
    0% { transform: rotate(0deg); } 
    100% { transform: rotate(360deg); } 
}

#loadingState {
    text-align: center;
    padding: 60px 20px;
}

#loadingState p {
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 500;
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    background: linear-gradient(135deg, #fafbfc 0%, #ffffff 100%);
    border-radius: var(--radius-lg);
    margin: 20px;
}

.empty-state i {
    font-size: 64px;
    color: var(--accent-light);
    margin-bottom: 20px;
    display: block;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 10px 0;
    color: var(--text-dark);
}

.empty-state p {
    font-size: 15px;
    color: var(--text-muted);
    margin: 0;
    font-weight: 500;
}

/* ===========================
   MOBILE OPTIMIZATIONS
   =========================== */
@media (max-width: 639px) {
    .header {
        padding: 12px 0;
    }
    
    .header-container {
        padding: 0 16px;
    }
    
    .search-input {
        font-size: 16px;
        padding: 14px 20px 14px 48px;
    }
    
    .search-filter {
        padding: 12px 16px;
        top: 81px;
    }
    
    .posts-container {
        padding: 16px;
    }
    
    .products-grid {
        gap: 10px;
    }
    
    .product-price {
        font-size: 18px;
    }
    
    .product-description {
        font-size: 12px;
    }
    
    .product-info {
        padding: 10px;
    }
    
    .section-header h2 {
        font-size: 18px;
    }
    
    .section-header i {
        font-size: 18px;
        width: 32px;
        height: 32px;
    }
    
    .user-avatar {
        width: 48px;
        height: 48px;
    }
}

/* ===========================
   PREMIUM ANIMATIONS
   =========================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-card,
.user-card {
    animation: fadeInUp 0.4s ease-out backwards;
}

.product-card:nth-child(1) { animation-delay: 0.05s; }
.product-card:nth-child(2) { animation-delay: 0.1s; }
.product-card:nth-child(3) { animation-delay: 0.15s; }
.product-card:nth-child(4) { animation-delay: 0.2s; }
.product-card:nth-child(5) { animation-delay: 0.25s; }
.product-card:nth-child(6) { animation-delay: 0.3s; }

/* ===========================
   ACCESSIBILITY
   =========================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.product-card:focus-visible,
.user-card:focus-visible,
.filter-tab:focus-visible,
.search-input:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* ===========================
   PREMIUM TOUCHES
   =========================== */
::selection {
    background: var(--primary);
    color: white;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 50px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
}

/* ============================================================
   PREMIUM DARK MODE – MODERN MARKETPLACE
   ============================================================ */
@media (prefers-color-scheme: dark) {

  /* ===========================
     ROOT COLOR OVERRIDES
     =========================== */
  :root {
    --bg-light: #0f1115;
    --white: #161a20;
    --text-dark: #e4e6eb;
    --text-muted: #9aa0a6;
    --border: #262b33;
    --border-light: #1f242c;

    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.5);
    --shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
    --shadow-hover: 0 10px 28px rgba(0, 0, 0, 0.7);
    --shadow-premium: 0 16px 40px rgba(0, 0, 0, 0.75);
  }

  body {
    background: linear-gradient(180deg, #0f1115 0%, #12161c 100%);
    color: var(--text-dark);
  }

  /* ===========================
     HEADER + SEARCH
     =========================== */
  .header,
  .search-filter {
    background: linear-gradient(180deg, #161a20 0%, #141820 100%);
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.6);
  }

  .search-input {
    background: #0f1319;
    border-color: var(--border);
    color: var(--text-dark);
  }

  .search-input::placeholder {
    color: #8b9199;
  }

  .search-input:focus {
    background: #0f1319;
  }

  /* ===========================
     FILTER TABS
     =========================== */
  .filter-tab {
    background: linear-gradient(135deg, #141820 0%, #1a1f27 100%);
    border-color: var(--border);
    color: var(--text-dark);
  }

  .filter-tab:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
  }

  .filter-tab.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #ffffff;
  }

  .search-info {
    color: var(--text-muted);
  }

  /* ===========================
     PRODUCT CARDS
     =========================== */
  .product-card {
    background: #161a20;
    border-color: var(--border-light);
    box-shadow: var(--shadow);
  }

  .product-card:hover {
    box-shadow: var(--shadow-premium);
    border-color: #2ecc71;
  }

  .product-image-container {
    background: linear-gradient(135deg, #1a1f27 0%, #12161c 100%);
  }

  .product-info {
    background: #161a20;
  }

  .product-description {
    color: var(--text-dark);
  }

  .product-meta {
    border-top-color: var(--border-light);
    color: var(--text-muted);
  }

  .product-meta i {
    color: var(--primary);
  }

  /* ===========================
     USER CARDS
     =========================== */
  .user-card {
    background: linear-gradient(135deg, #161a20 0%, #141820 100%);
    border-color: var(--border-light);
    box-shadow: var(--shadow-sm);
  }

  .user-card:hover {
    box-shadow: var(--shadow-hover);
  }

  .user-avatar {
    border-color: #161a20;
  }

  .user-name {
    color: var(--text-dark);
  }

  .user-username {
    color: var(--text-muted);
  }

  .btn-view-profile {
    color: var(--primary);
    border-color: var(--primary);
  }

  .btn-view-profile:hover {
    color: #ffffff;
  }

  /* ===========================
     SECTION HEADERS
     =========================== */
  .section-header h2 {
    color: var(--text-dark);
  }

  .section-count {
    background: rgba(40, 167, 69, 0.15);
    border-color: rgba(46, 204, 113, 0.4);
  }

  /* ===========================
     EMPTY & LOADING STATES
     =========================== */
  .empty-state {
    background: linear-gradient(135deg, #141820 0%, #161a20 100%);
  }

  .empty-state h3 {
    color: var(--text-dark);
  }

  .empty-state p {
    color: var(--text-muted);
  }

  #loadingState p {
    color: var(--text-muted);
  }

  /* ===========================
     SCROLLBARS
     =========================== */
  ::-webkit-scrollbar-track {
    background: #0f1115;
  }

  ::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary) 0%, var(--accent) 100%);
  }
}