/* Modern Mercari-style Homepage */
* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

body {
    margin: 0;
    padding: 0;
    background: #f2f5f8;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Homepage Content Wrapper */
.homepage-content-wrapper {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 0;
}

/* Hero Banner Section */
.hero-banner {
    background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), 
                url('/static/marketplace/images/banner_homepage.jpg') center/cover no-repeat;
    margin: 20px auto 40px auto;
    max-width: 1280px;
    width: 100%;
    height: 304px;
    border-radius: 0;
    padding: 40px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hero-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

.hero-content h1 {
    font-size: 4rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0;
    letter-spacing: -2px;
    text-transform: none;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.hero-content p {
    font-size: 1.3rem;
    color: #ffffff;
    margin: 20px 0 30px 0;
    font-weight: 400;
}

.hero-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
}

.hero-btn {
    padding: 14px 32px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.hero-btn-primary {
    background: white;
    color: #1f2937;
    border: 2px solid #1f2937;
}

.hero-btn-primary:hover {
    background: #1f2937;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.hero-btn-secondary {
    background: white;
    color: #1f2937;
    border: 2px solid #1f2937;
}

.hero-btn-secondary:hover {
    background: #1f2937;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Category Showcase Section */
.category-showcase {
    margin: 0 0 50px 0;
    padding: 0;
}

.category-showcase-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.category-card {
    display: block;
    position: relative;
    width: 410px;
    height: 260px;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: none;
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.category-card-content {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 2;
}

.category-subtitle {
    display: block;
    font-size: 0.875rem;
    color: #ffffff;
    margin-bottom: 4px;
    font-weight: 400;
}

.category-title {
    font-size: 2rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    line-height: 1.2;
}

.category-card-image {
    width: 100%;
    height: 100%;
    position: relative;
}

.category-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Smaller category card variant */
.category-card-small {
    width: 302px;
    height: 265px;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.category-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 12px;
    text-decoration: none;
    color: #6b7280;
    border-radius: 12px;
    transition: all 0.2s ease;
    background: #fafafa;
    border: 1px solid transparent;
}

.category-item:hover {
    background: #f0f9ff;
    border-color: #3b82f6;
    color: #3b82f6;
    text-decoration: none;
    transform: translateY(-2px);
}

.category-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 1.4rem;
    transition: all 0.2s ease;
}

.category-item:hover .category-icon {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

.category-name {
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    line-height: 1.3;
}

/* Featured Listings Section */
.featured-section {
    margin: 0 0 50px 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s ease;
}

.section-title:hover {
    color: #2563eb;
}

.featured-badge {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.featured-carousel {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 20px;
    scroll-behavior: smooth;
    scrollbar-width: none;
}

.featured-carousel::-webkit-scrollbar {
    display: none;
}

/* Local items carousel with cyan/sky blue scrollbar */
#local-carousel::-webkit-scrollbar {
    height: 12px;
}

#local-carousel::-webkit-scrollbar-track {
    background: #e0f2fe;
    border-radius: 6px;
    margin: 0 10px;
}

#local-carousel::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    border-radius: 6px;
    min-width: 40px;
}

#local-carousel::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
}

/* Item Feed Section */
.items-feed {
    margin: 0;
    padding: 0 10px;
    width: 100%;
    box-sizing: border-box;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 180px);
    gap: 16px;
    max-width: 100vw;
    width: 100%;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    justify-content: center;
}

.item-card {
    background: white;
    border-radius: 0;
    overflow: visible;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    width: 180px !important;
    height: 270px;
    display: flex;
    flex-direction: column;
}

.item-card:hover {
    text-decoration: none;
    color: inherit;
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Disable hover effect for recommended items in grid */
.items-grid .item-card:hover {
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

/* Trending Items Card Hover */
.trending-item-card:hover {
    text-decoration: none;
    color: inherit;
}

/* Mobile Responsiveness for Trending Grid */
@media (max-width: 1200px) {
    #trending-items-section > div > div {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 768px) {
    #trending-items-section > div > div {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 480px) {
    #trending-items-section > div > div {
        grid-template-columns: 1fr !important;
    }
}

.item-image-container {
    position: relative;
    width: 180px;
    height: 180px;
    background: white;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
}

/* Favorite Button */
.item-favorite {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 15;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.item-favorite:hover {
    background: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.item-favorite i {
    font-size: 1.1rem;
    color: #ef4444;
    transition: color 0.2s ease;
}

.item-favorite i.fas {
    color: #ef4444;
}

/* Image Carousel */
.item-images-carousel {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.item-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.item-images-carousel img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
    user-drag: none;
    -webkit-user-drag: none;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
}

.item-card:hover .item-images-carousel img {
    transform: scale(1.05);
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 1;
    transition: all 0.2s ease;
    z-index: 10;
    font-size: 1.2rem;
    color: #374151;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.local-item-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.item-card:hover .carousel-nav,
.local-item-card:hover .carousel-nav {
    opacity: 1;
}

.carousel-nav:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
}

.carousel-nav.prev {
    left: 8px;
}

.carousel-nav.next {
    right: 8px;
}

.carousel-indicators {
    position: absolute;
    bottom: 12px;
    left: 0;
    right: 0;
    margin: 0 auto;
    display: flex;
    gap: 6px;
    z-index: 10;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 14px;
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    width: fit-content;
}

.carousel-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    flex-shrink: 0;
    margin: 0;
}

.carousel-indicator.active {
    background: white;
    transform: scale(1.2);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

.image-count-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    z-index: 10;
}

.item-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
    user-drag: none;
    -webkit-user-drag: none;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
}

.item-card:hover .item-image {
    transform: scale(1.05);
}

.featured-item-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.item-content {
    padding: 12px;
    position: relative;
    overflow: hidden;
    z-index: 1;
    background: #f2f5f8;
    width: 100%;
    box-sizing: border-box;
    min-height: 80px;
}

.item-price {
    font-size: 1.4rem;
    font-weight: 700;
    color: #000000;
    margin: 0 0 6px 0;
}

.item-title {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-location {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
    font-size: 0.8rem;
    color: #9ca3af;
}

/* Load More Section */
.load-more-section {
    text-align: center;
    margin: 60px 10px 40px 10px;
    min-height: 100px;
}

.load-more-btn {
    background: linear-gradient(135deg, #1f1f1f 0%, #000000 100%);
    color: white;
    border: none;
    padding: 16px 40px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.load-more-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.load-more-btn.loading {
    background: linear-gradient(135deg, #4a4a4a 0%, #2a2a2a 100%);
    pointer-events: none;
}

.load-more-btn.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: loading-shimmer 1.5s infinite;
}

.load-more-btn.completed {
    background: linear-gradient(135deg, #6b6b6b 0%, #4a4a4a 100%);
    cursor: default;
}

.load-more-btn.error {
    background: linear-gradient(135deg, #333333 0%, #1a1a1a 100%);
    animation: shake 0.5s;
}

@keyframes loading-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Skeleton Loading States */
.skeleton-card {
    pointer-events: none;
    animation: skeleton-fade-in 0.3s ease;
}

@keyframes skeleton-fade-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.skeleton-image {
    width: 100%;
    height: 180px;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

.skeleton-content {
    padding: 12px;
    background: #f8fafc;
}

.skeleton-price {
    width: 60%;
    height: 24px;
    background: linear-gradient(90deg, #e2e8f0 25%, #cbd5e1 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-title {
    width: 90%;
    height: 16px;
    background: linear-gradient(90deg, #e2e8f0 25%, #cbd5e1 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 6px;
}

.skeleton-title-short {
    width: 70%;
    height: 16px;
    background: linear-gradient(90deg, #e2e8f0 25%, #cbd5e1 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

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

/* Item Card Loaded Animation */
.item-card-loaded {
    animation: item-fade-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes item-fade-in {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Error Message Styling */
.load-error-message {
    animation: error-slide-in 0.4s ease;
}

.load-error-message .error-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.load-error-message h3 {
    color: #dc2626;
    margin: 0 0 8px 0;
    font-size: 1.2rem;
}

.load-error-message p {
    color: #6b7280;
    margin: 0;
    font-size: 0.9rem;
}

@keyframes error-slide-in {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Load Trigger - Hidden element for Intersection Observer */
#load-trigger {
    width: 100%;
    height: 1px;
    margin: 20px 0;
    visibility: hidden;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .hero-banner {
        margin: 0 16px;
        padding: 60px 24px;
    }
    
    .hero-content h1 {
        font-size: 2.8rem;
    }
    
    .category-strip,
    .featured-section,
    .items-feed {
        margin-left: 16px;
        margin-right: 16px;
    }
    
    .categories-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 12px;
    }
    
    .category-item {
        padding: 16px 8px;
    }
    
    .category-icon {
        width: 40px;
        height: 40px;
    }
    
    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .hero-content h1 {
        font-size: 2.2rem;
        letter-spacing: -1px;
    }
    
    .categories-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* Dynamic Brand Filter Styling */
.category-item {
    transition: all 0.3s ease !important;
}

.category-item.active-category {
    background: linear-gradient(135deg, #4ade80, #22c55e) !important;
    color: white !important;
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(34, 197, 94, 0.3) !important;
}

.category-item.active-category .category-icon {
    transform: scale(1.1);
}

#brand-filter-group {
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.3s ease;
}

#brand-filter-group.active {
    border-color: #4ade80;
    background-color: #f0fdf4;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.1);
}

#brand-filter-group.active .filter-label {
    color: #16a34a;
    font-weight: 600;
}

/* Info Icon Tooltip Styles */
.info-icon-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    z-index: 100;
}

.info-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    width: 280px;
    max-width: 90vw;
    background: #1f2937;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    line-height: 1.5;
    z-index: 99999;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    pointer-events: none;
    white-space: normal;
    text-overflow: clip;
    overflow: visible;
}

.info-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: #1f2937;
}

.info-icon-wrapper:hover .info-tooltip {
    visibility: visible;
    opacity: 1;
}

.info-icon-wrapper i:hover {
    color: #22c55e;
}
