* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --secondary: #764ba2;
    --ink: #1f2933;
    --light-bg: #f8fafc;
    --light-accent: #edf2f7;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Space Grotesk', sans-serif;
    color: var(--ink);
    background: var(--light-bg);
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 15% 20%, rgba(102, 126, 234, 0.1), transparent 45%),
        radial-gradient(circle at 80% 10%, rgba(118, 75, 162, 0.08), transparent 50%);
    z-index: -1;
}

.home-shell {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 24px 60px calc(260px + 24px);
    min-height: 100vh;
}

.page-hero {
    position: relative;
    background: #ffffff;
    border-radius: 28px;
    padding: 32px 34px;
    box-shadow: 0 20px 60px var(--shadow);
    overflow: hidden;
    margin-bottom: 28px;
}

.page-hero,
.feed {
    max-width: 640px;
    
    .post-header {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap;
    }
    margin-left: auto;
    margin-right: auto;
}

.hero-copy h1 {
    font-family: 'Fraunces', serif;
    font-size: clamp(2rem, 3vw, 3rem);
    margin-top: 12px;
    margin-bottom: 10px;
    line-height: 1.1;
}

.hero-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--light-accent);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.hero-glow {
    position: absolute;
    top: -80px;
    right: -40px;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(246, 173, 85, 0.4), transparent 70%);
}

.location-layer {
    position: fixed;
    inset: 0;
    background: rgba(21, 20, 18, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    padding: 20px;
    pointer-events: auto;
}

.location-layer.hidden {
    display: none;
    pointer-events: none;
}

.location-card {
    background: #fff;
    border-radius: 24px;
    padding: 28px;
    width: min(420px, 95%);
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.location-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: var(--light-accent);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 16px;
}

.location-card h2 {
    font-family: 'Fraunces', serif;
    font-size: 1.6rem;
    margin-bottom: 8px;
}

.location-card p {
    color: #52606d;
}

.location-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.primary-btn,
.ghost-btn {
    border: none;
    border-radius: 999px;
    padding: 10px 18px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.primary-btn {
    background: var(--primary);
    color: #fff;
}

.ghost-btn {
    background: transparent;
    border: 1px solid #cbd2d9;
    color: #52606d;
}

.location-note {
    margin-top: 12px;
    color: #c05621;
    font-size: 0.9rem;
}

.feed {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.feed-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.shop-post {
    background: #fff;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 18px 50px var(--shadow);
    animation: rise 0.5s ease both;
}

.post-header {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 18px;
}

.shop-avatar {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.shop-avatar .company-initials {
    font-size: 24px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    z-index: 1;
}

.shop-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    display: none;
    z-index: 2;
}

.avatar-fallback {
    color: white;
    font-size: 28px;
}

.shop-meta {
    flex: 1;
    min-width: 0;
}

.shop-name {
    display: block;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shop-distance {
    font-size: 0.9rem;
    color: var(--primary);
    margin-top: 4px;
}

.post-products {
    background: var(--light-accent);
    border-radius: 18px;
    padding: 16px;
}

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

.products-title {
    font-weight: 600;
    color: #334e68;
}

.products-count {
    font-size: 0.85rem;
    color: #52606d;
}

.products-stage {
    display: grid;
    grid-template-columns: 34px 1fr 34px;
    gap: 10px;
    align-items: center;
}

.stage-nav {
    background: #fff;
    border: 1px solid #d9e2ec;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #52606d;
}

.products-strip {
    display: flex;
    gap: 0;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    padding-bottom: 0;
    scrollbar-width: none;
}

.products-strip::-webkit-scrollbar {
    height: 0;
}

.products-strip::-webkit-scrollbar-thumb {
    background: rgba(82, 96, 109, 0.3);
    border-radius: 999px;
}

.product-card {
    min-width: 100%;
    width: 100%;
    background: #fff;
    border-radius: 16px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 8px 20px rgba(31, 41, 51, 0.08);
    transition: transform 0.2s ease;
    scroll-snap-align: center;
}

.product-card.active {
    transform: translateY(-4px);
    border: 1px solid rgba(44, 122, 123, 0.4);
}

.product-media {
    width: 100%;
    min-height: 120px;
    height: auto;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Desktop: Apply 4:3 aspect ratio for better showcase */
@media (min-width: 1024px) {
    .product-media {
        min-height: 200px;
        aspect-ratio: 4 / 3;
    }
}

.product-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-fallback {
    color: #94a3b8;
    font-size: 30px;
}

.product-kind-pill {
    position: absolute;
    top: 8px;
    left: 8px;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    z-index: 2;
    color: #fff;
    background: rgba(51, 65, 85, 0.85);
}

.product-kind-pill.product {
    background: rgba(36, 101, 87, 0.9);
}

.product-kind-pill.sellable {
    background: rgba(27, 94, 32, 0.92);
}

.product-kind-pill.post-product {
    background: rgba(180, 83, 9, 0.9);
}

.product-kind-pill.update {
    background: rgba(55, 65, 81, 0.88);
}

.product-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: #334e68;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-empty {
    padding: 30px;
    color: #74808c;
    font-style: italic;
}

.post-actions-row {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
}

.post-action-item {
    border: 0;
    background: transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: #0f172a;
    padding: 2px;
}

.post-action-item i {
    font-size: 1.28rem;
}

.post-action-item.active {
    color: #dc2626;
}

.post-action-item.favourite-action.active i,
.post-action-item.favourite-action.active i.bxs-heart {
    color: #dc2626;
}

.post-action-item.favourite-action.active .post-action-count {
    color: #ffffff;
}

.post-action-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.post-action-item.loading {
    opacity: 0.65;
}

.post-action-count {
    font-size: 0.86rem;
    font-weight: 600;
    color: #334155;
}

.post-badges-row {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.post-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid #bbf7d0;
    background: #ecfdf3;
    color: #166534;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 6px 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.post-badge.out {
    border-color: #fed7aa;
    background: #fff7ed;
    color: #9a3412;
}

.post-badge.under {
    border-color: #fde68a;
    background: #fffbeb;
    color: #92400e;
}

.post-badge.price {
    border-color: #dbeafe;
    background: #eff6ff;
    color: #1d4ed8;
}

.post-badge.badge-change {
    animation: badgePulse 0.45s ease;
}

.feed-sentinel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #52606d;
    padding: 14px 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.feed-sentinel.active {
    opacity: 1;
}

.loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(82, 96, 109, 0.3);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.empty-state {
    text-align: center;
    background: #fff;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px var(--shadow);
}

.empty-icon {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 8px;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes badgePulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(59, 130, 246, 0);
    }
    40% {
        transform: scale(1.08);
        box-shadow: 0 0 0 7px rgba(59, 130, 246, 0.14);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(59, 130, 246, 0);
    }
}

@media (max-width: 1024px) {
    .home-shell {
        padding-left: 24px;
    }

    .page-hero,
    .feed {
        max-width: 100%;
    }
}

@media (max-width: 720px) {
    .page-hero {
        padding: 24px;
    }

    .post-header {
        flex-direction: row;
        align-items: center;
    }

    .post-actions-row {
        flex-wrap: wrap;
    }
}

.single-media img:hover {
    transform: scale(1.02);
}

.media-carousel {
    position: relative;
    width: 100%;
    max-height: 500px;
    overflow: hidden;
}

.carousel-track {
    display: flex;
    transition: transform 0.3s;
}

.carousel-slide {
    min-width: 100%;
    height: 500px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s;
}

.carousel-slide.active {
    opacity: 1;
}

.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.carousel-dots {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 10px;
    z-index: 2;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s;
}

.carousel-dot.active {
    background: white;
    transform: scale(1.2);
}

.carousel-prev,
.carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #2d3748;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s;
    z-index: 2;
}

.carousel-prev:hover,
.carousel-next:hover {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.carousel-prev {
    left: 20px;
}

.carousel-next {
    right: 20px;
}

/* Post Content */
.post-content {
    padding: 20px;
}

.post-title {
    color: #2d3748;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.post-text {
    color: #4a5568;
    line-height: 1.6;
    margin-bottom: 10px;
}

.see-more-btn {
    background: none;
    border: none;
    color: #667eea;
    font-weight: 600;
    cursor: pointer;
    padding: 5px 0;
    font-size: 14px;
}

.see-more-btn:hover {
    text-decoration: underline;
}

/* Post Actions */
.post-actions {
    padding: 15px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 20px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: #718096;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    padding: 8px 12px;
    border-radius: 6px;
}

.action-btn:hover {
    background: #f7fafc;
    color: #4a5568;
}

.action-btn.like-btn:hover {
    color: #f56565;
}

.action-btn.like-btn i.bxs-heart {
    color: #f56565;
}

.action-btn.comment-btn:hover {
    color: #667eea;
}

.action-btn.share-btn:hover {
    color: #48bb78;
}

.action-btn.shop-btn {
    text-decoration: none;
    color: #718096;
}

.action-btn.shop-btn:hover {
    color: #667eea;
    background: #f7fafc;
}

/* Empty States */
.empty-state {
    padding: 60px 30px;
    text-align: center;
}

.empty-state i {
    font-size: 64px;
    color: #a0aec0;
    margin-bottom: 20px;
}

.empty-state h3 {
    color: #2d3748;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.empty-state p {
    color: #718096;
    margin-bottom: 20px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.btn-explore {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 25px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-explore:hover {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* Load More */
.load-more-container {
    padding: 30px;
    text-align: center;
    border-top: 1px solid #e2e8f0;
}

.load-more-btn {
    padding: 15px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 auto;
}

.load-more-btn:hover {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.load-more-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

/* Skeleton Loading */
.skeleton-posts {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.skeleton-post {
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 20px;
}

.skeleton-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.skeleton-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: pulse 1.5s infinite;
}

.skeleton-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    border-radius: 6px;
    animation: pulse 1.5s infinite;
}

.skeleton-line.short {
    width: 40%;
}

.skeleton-line.shorter {
    width: 30%;
}

.skeleton-line.distance {
    width: 20%;
}

.skeleton-line.half {
    width: 50%;
}

.skeleton-image {
    height: 300px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    border-radius: 8px;
    margin-bottom: 20px;
    animation: pulse 1.5s infinite;
}

.skeleton-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Responsive Design */
@media (max-width: 992px) {
    .home-shell {
        padding: 56px 20px 60px 20px;
    }
    
    .home-container {
        padding-left: 20px;
        padding-right: 20px;
    }
    
    .feed-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .location-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .refresh-feed-btn,
    .enable-location-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .home-header h1 {
        font-size: 2rem;
    }
    
    .feed-tab {
        padding: 15px;
        font-size: 14px;
    }
    
    .posts-feed {
        padding: 20px;
    }
    
    .post-header {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap;
    }
    
    .post-type {
        align-self: flex-start;
    }
    
    .carousel-slide {
        height: 300px;
    }
    
    .carousel-prev,
    .carousel-next {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .home-header {
        padding: 20px;
    }
    
    .home-header h1 {
        font-size: 1.8rem;
    }
    
    .header-subtitle {
        font-size: 1rem;
    }
    
    .feed-tab {
        padding: 12px;
        font-size: 13px;
    }
    
    .tab-badge {
        padding: 2px 6px;
        font-size: 10px;
    }
    
    .feed-header h2 {
        font-size: 1.1rem;
    }
    
    .post-actions {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .action-btn {
        font-size: 13px;
        padding: 6px 10px;
    }
    
    .carousel-slide {
        height: 250px;
    }
    
    .skeleton-image {
        height: 200px;
    }
}

/* Animation for tab switching */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-content.active {
    animation: fadeIn 0.3s ease-out;
}

/* Toastify custom styles */
.toastify {
    border-radius: 8px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* Smooth scrolling for feed */
.posts-feed {
    scroll-behavior: smooth;
}

.observer-target {
    height: 20px;
    width: 100%;
    margin: 10px 0;
}

html[data-theme='dark'] body {
    background: #0b1220;
    color: #e2e8f0;
}

html[data-theme='dark'] body::before {
    background:
        radial-gradient(circle at 15% 20%, rgba(59, 130, 246, 0.22), transparent 45%),
        radial-gradient(circle at 80% 10%, rgba(30, 64, 175, 0.18), transparent 50%);
}

html[data-theme='dark'] .page-hero,
html[data-theme='dark'] .shop-post,
html[data-theme='dark'] .post-products,
html[data-theme='dark'] .product-card,
html[data-theme='dark'] .empty-state,
html[data-theme='dark'] .location-card,
html[data-theme='dark'] .stage-nav,
html[data-theme='dark'] .feed-tab,
html[data-theme='dark'] .post-actions,
html[data-theme='dark'] .single-media,
html[data-theme='dark'] .carousel-prev,
html[data-theme='dark'] .carousel-next {
    background: #111827;
    border-color: #334155;
    color: #e2e8f0;
}

html[data-theme='dark'] .hero-copy h1,
html[data-theme='dark'] .shop-name,
html[data-theme='dark'] .products-title,
html[data-theme='dark'] .feed-header h2,
html[data-theme='dark'] .post-title,
html[data-theme='dark'] .empty-state h3,
html[data-theme='dark'] .location-card h2,
html[data-theme='dark'] .product-title {
    color: #f8fafc;
}

html[data-theme='dark'] .hero-copy p,
html[data-theme='dark'] .shop-distance,
html[data-theme='dark'] .products-count,
html[data-theme='dark'] .post-action-count,
html[data-theme='dark'] .post-text,
html[data-theme='dark'] .location-card p,
html[data-theme='dark'] .feed-sentinel {
    color: #94a3b8;
}

html[data-theme='dark'] .hero-pill {
    background: #1e293b;
    color: #93c5fd;
}

html[data-theme='dark'] .location-layer {
    background: rgba(2, 6, 23, 0.78);
}

html[data-theme='dark'] .ghost-btn {
    background: #0f172a;
    border-color: #334155;
    color: #cbd5e1;
}

html[data-theme='dark'] .ghost-btn:hover,
html[data-theme='dark'] .stage-nav:hover,
html[data-theme='dark'] .action-btn:hover {
    background: #1e293b;
    color: #f8fafc;
}

html[data-theme='dark'] .product-media,
html[data-theme='dark'] .product-fallback,
html[data-theme='dark'] .skeleton-image,
html[data-theme='dark'] .skeleton-content,
html[data-theme='dark'] .skeleton-item {
    background: #0f172a;
    color: #64748b;
}

html[data-theme='dark'] .post-badge {
    border-color: rgba(134, 239, 172, 0.4);
    background: rgba(6, 78, 59, 0.35);
    color: #bbf7d0;
}

html[data-theme='dark'] .post-badge.out {
    border-color: rgba(253, 186, 116, 0.45);
    background: rgba(124, 45, 18, 0.38);
    color: #fed7aa;
}

html[data-theme='dark'] .post-badge.under {
    border-color: rgba(250, 204, 21, 0.4);
    background: rgba(113, 63, 18, 0.36);
    color: #fde68a;
}

html[data-theme='dark'] .post-badge.price {
    border-color: rgba(96, 165, 250, 0.45);
    background: rgba(30, 64, 175, 0.34);
    color: #bfdbfe;
}

html[data-theme='dark'] .post-actions,
html[data-theme='dark'] .post-content,
html[data-theme='dark'] .feed-tabs {
    border-color: #334155;
}

html[data-theme='dark'] .action-btn,
html[data-theme='dark'] .post-action-item {
    color: #cbd5e1;
}
