/* =========================================
   1. GLOBAL DESIGN SYSTEM & FONTS
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-main: #f4f7fb;
    --surface-white: #ffffff;
    --brand-dark: #0B1120;
    --brand-primary: #0284C7;
    --brand-primary-hover: #0369A1;
    --brand-accent: #38BDF8;
    --text-main: #0F172A;
    --text-muted: #64748B;
    --text-light: #94A3B8;

    --badge-sell-bg: #E0F2FE; --badge-sell-text: #0284C7;
    --badge-exchange-bg: #FEF3C7; --badge-exchange-text: #D97706;
    --badge-giveaway-bg: #DCFCE7; --badge-giveaway-text: #15803D;
    --badge-lend-bg: #F3E8FF; --badge-lend-text: #7E22CE;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-float: 0 10px 30px -10px rgba(11, 17, 32, 0.06);
    --shadow-hover: 0 20px 40px -15px rgba(2, 132, 199, 0.15);
    --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.4);
    
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', system-ui, sans-serif;
}

html, body {
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden; 
    max-width: 100vw;
}

/* =========================================
   2. FLOATING FROSTED NAVBAR
   ========================================= */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 4%;
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid #E2E8F0 !important;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
}

.logo {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand-dark), var(--brand-primary));
    -webkit-background-clip: text;
    background-clip: text; /* <-- The standard property added for compatibility! */
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

/* =========================================
   3. ACTIVE NAVBAR & NAV ITEMS
   ========================================= */
.nav-item {
    text-decoration: none !important;
    font-weight: 600 !important;
    color: var(--text-muted) !important;
    padding: 8px 12px !important;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-item:hover {
    color: var(--brand-primary) !important;
    background: #F0F9FF !important;
}

.active-nav {
    color: var(--brand-primary) !important;
    font-weight: 800 !important;
    background: #E0F2FE !important;
    pointer-events: none !important; 
}

/* Desktop Hamburger (Hidden) */
.hamburger-btn {
    display: none; 
    background: none;
    border: none;
    cursor: pointer;
    color: var(--brand-dark);
    padding: 5px;
    transition: var(--transition-fast);
}

.hamburger-btn:hover {
    color: var(--brand-primary);
}

/* =========================================
   4. PREMIUM BUTTONS
   ========================================= */
.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    color: white;
    border: none;
    padding: 0.8rem 1.8rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3);
}
.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--surface-white);
    color: var(--brand-dark);
    border: 1px solid #E2E8F0;
    padding: 0.8rem 1.8rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
    border-color: var(--brand-dark);
    transform: translateY(-2px);
}

/* =========================================
   5. STUNNING HERO SECTION
   ========================================= */
.hero {
    text-align: center;
    padding: 8rem 2rem;
    background: radial-gradient(circle at top right, rgba(14, 165, 233, 0.1), transparent 40%),
                radial-gradient(circle at bottom left, rgba(14, 165, 233, 0.05), transparent 40%);
    background-color: var(--brand-dark);
    color: white;
    border-radius: 0 0 40px 40px;
    margin-bottom: 4rem;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGNpcmNsZSBjeD0iMSIgY3k9IjEiIHI9IjEiIGZpbGw9InJnYmEoMjU1LDI1NSwyNTUsMC4wNSkiLz48L3N2Zz4=');
    mask-image: linear-gradient(to bottom, white, transparent);
    -webkit-mask-image: linear-gradient(to bottom, white, transparent);
}
.hero h1 { font-size: 4.5rem; font-weight: 800; margin-bottom: 1rem; letter-spacing: -2px; line-height: 1.1; position: relative; z-index: 2; }
.hero p { font-size: 1.2rem; color: #94A3B8; margin-bottom: 3rem; font-weight: 400; max-width: 600px; margin-inline: auto; position: relative; z-index: 2; }

/* =========================================
   6. FLOATING SEARCH BAR
   ========================================= */
.search-wrapper { display: flex; justify-content: center; max-width: 650px; margin: 0 auto; background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(10px); padding: 0.5rem; border-radius: 50px; border: 1px solid rgba(255,255,255,0.2); position: relative; z-index: 2; transition: var(--transition-smooth); }
.search-wrapper:focus-within { background: rgba(255, 255, 255, 0.15); border-color: rgba(255,255,255,0.4); box-shadow: 0 0 30px rgba(14, 165, 233, 0.2); }
.search-wrapper input { flex: 1; border: none; background: transparent; padding: 1rem 1.5rem; font-size: 1.1rem; color: white; outline: none; }
.search-wrapper input::placeholder { color: rgba(255,255,255,0.5); }
.search-wrapper button { border-radius: 50px; padding: 0.8rem 2rem; }

/* =========================================
   7. ULTRA-CLEAN CARDS
   ========================================= */
.container { padding: 0 4%; flex: 1; max-width: 1400px; margin: 0 auto; width: 100%; }
.section-title { font-size: 2rem; font-weight: 800; margin-bottom: 2rem; color: var(--brand-dark); letter-spacing: -0.5px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 2.5rem; margin-bottom: 5rem; }

.card { background: var(--surface-white); border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; position: relative; border: 1px solid #E2E8F0 !important; box-shadow: var(--shadow-float) !important; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important; }
.card:hover { transform: translateY(-6px) !important; box-shadow: var(--shadow-hover) !important; border-color: rgba(2, 132, 199, 0.3) !important; }
.card-img-placeholder { height: 220px; background: #F8FAFC; display: flex; align-items: center; justify-content: center; font-size: 4rem; position: relative; }
.card-content { padding: 1.8rem; flex: 1; display: flex; flex-direction: column; }

.badge-container { position: absolute; top: 16px; left: 16px; z-index: 10; }
.badge { display: inline-block; padding: 6px 14px; border-radius: 50px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; backdrop-filter: blur(4px); box-shadow: 0 2px 5px rgba(0,0,0,0.03); }
.badge-sell { background: var(--badge-sell-bg); color: var(--badge-sell-text); }
.badge-exchange { background: var(--badge-exchange-bg); color: var(--badge-exchange-text); }
.badge-giveaway { background: var(--badge-giveaway-bg); color: var(--badge-giveaway-text); }
.badge-lend { background: var(--badge-lend-bg); color: var(--badge-lend-text); }

.card-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--text-main); line-height: 1.3; }
.card-price { font-size: 1.6rem; font-weight: 800; color: var(--brand-primary); margin-bottom: 1.5rem; }
.card-meta { margin-top: auto; font-size: 0.9rem; color: var(--text-muted); display: flex; flex-direction: column; gap: 8px; padding-top: 1rem; border-top: 1px solid #F1F5F9; }

/* =========================================
   8. BEAUTIFUL FORMS & INPUTS
   ========================================= */
.post-form { background: var(--surface-white); padding: 2.5rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-float); border: 1px solid rgba(0,0,0,0.02); }
.form-group { margin-bottom: 1.8rem; }
.form-group label { display: block; margin-bottom: 0.6rem; font-weight: 600; color: var(--brand-dark); font-size: 0.95rem; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 1rem; background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: var(--radius-sm); font-family: inherit; font-size: 1rem; transition: all 0.2s ease !important; color: var(--text-main); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; background: white; border-color: var(--brand-primary) !important; box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12) !important; }

/* =========================================
   9. FOOTER
   ========================================= */
.footer { text-align: center; padding: 2.5rem; margin-top: auto; background: transparent; color: var(--text-muted); font-weight: 500; font-size: 0.95rem; }
.footer span { color: #ef4444; }
.footer strong { color: var(--brand-dark); font-weight: 700;}

/* =========================================
   10. PREMIUM MODALS & LISTING DETAILS
   ========================================= */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(11, 17, 32, 0.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 2000; opacity: 0; pointer-events: none; transition: var(--transition-smooth); }
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-content { background: var(--surface-white); padding: 3rem; border-radius: var(--radius-lg); width: 100%; max-width: 450px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important; border: 1px solid rgba(2, 132, 199, 0.1) !important; transform: translateY(20px) scale(0.95); transition: var(--transition-smooth); }
.modal-overlay.active .modal-content { transform: translateY(0) scale(1); }
.modal-content h2 { color: var(--brand-dark); margin-bottom: 1rem; font-size: 1.8rem; font-weight: 800; letter-spacing: -0.5px; }

/* =========================================
   11. AVATAR GRID
   ========================================= */
.avatar-grid { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-bottom: 1.5rem; max-height: 250px; overflow-y: auto; padding: 10px; background: #F8FAFC; border-radius: var(--radius-md); border: 1px solid #E2E8F0; }
.avatar-option { width: 65px !important; height: 65px !important; min-width: 65px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: var(--transition-fast); object-fit: cover; background: white; }
.avatar-option.selected { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.3); transform: scale(1.1); }

/* =========================================
   12. LISTING IMAGE FRAMES (SHRINK TO FIT)
   ========================================= */
.listing-hero { background: var(--surface-white); border-radius: var(--radius-lg); box-shadow: var(--shadow-float); padding: 3rem; display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; margin-bottom: 3rem; border: 1px solid rgba(0,0,0,0.02); }
.listing-image-container { height: 500px !important; width: 100%; background: #F8FAFC; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; padding: 1.5rem; border: 1px solid #E2E8F0; overflow: hidden; }
.gallery-wrapper { display: flex; flex-direction: column; width: 100%; height: 100%; }
.main-image-wrapper { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; overflow: hidden; margin-bottom: 15px; }
#mainGalleryImg, .listing-image-container > img { max-width: 100% !important; max-height: 100% !important; width: auto !important; height: auto !important; object-fit: contain !important; margin: auto !important; display: block; border-radius: 8px; }

/* =========================================
   13. AUTHENTICATION PAGE
   ========================================= */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: radial-gradient(circle at top right, rgba(14, 165, 233, 0.05), transparent 40%), var(--bg-main); }
.auth-container { width: 100%; max-width: 450px; padding: 2rem; }
.auth-card { background: var(--surface-white); padding: 3rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-float); text-align: center; border: 1px solid rgba(0,0,0,0.02); }
.auth-card h2 { color: var(--brand-dark); font-size: 1.8rem; margin-bottom: 0.5rem; letter-spacing: -0.5px; }
.auth-card p { color: var(--text-muted); margin-bottom: 2.5rem; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; background: white; color: var(--text-main); border: 1px solid #E2E8F0; padding: 0.9rem; border-radius: 50px; font-size: 1.05rem; font-weight: 600; cursor: pointer; transition: var(--transition-smooth); box-shadow: var(--shadow-sm); margin-bottom: 1rem; }
.btn-google:hover { background: #F8FAFC; border-color: #CBD5E1; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.btn-google img { width: 24px; height: 24px; }
.auth-divider { display: flex; align-items: center; margin: 1.5rem 0; color: var(--text-light); font-size: 0.9rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; border-bottom: 1px solid #E2E8F0; }
.auth-divider span { padding: 0 10px; }

/* =========================================
   14. PROFILE HEADER & STATS
   ========================================= */
.profile-header { background: var(--surface-white); padding: 2rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 1.5rem; margin-bottom: 2rem; border: 1px solid rgba(0,0,0,0.03); }
.profile-avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 3px solid var(--brand-primary); }
.profile-info h1 { font-size: 1.6rem; margin-bottom: 0.2rem; }
.profile-stats { display: flex; gap: 1rem; margin-top: 0.8rem; }
.stat-box { background: var(--bg-main); padding: 0.8rem 1.2rem; border-radius: var(--radius-sm); text-align: center; }
.seller-card-clickable { cursor: pointer; transition: var(--transition-fast); }
.seller-card-clickable:hover { background: #F1F5F9 !important; border-color: var(--brand-primary) !important; }

/* =========================================
   15. HORIZONTAL FILTERS (BROWSE PAGE)
   ========================================= */
.horizontal-filters { display: flex; gap: 1rem; background: var(--surface-white); padding: 1rem; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); border: 1px solid rgba(0,0,0,0.03); margin-bottom: 1rem; }
.horizontal-filters input { flex: 2; padding: 0.8rem 1rem; border: 1px solid #E2E8F0; border-radius: var(--radius-sm); font-family: inherit; outline: none; }
.horizontal-filters select { flex: 1; padding: 0.8rem 1rem; border: 1px solid #E2E8F0; border-radius: var(--radius-sm); outline: none; background: var(--bg-main); }

/* =========================================
   16. MOBILE RESPONSIVENESS & HAMBURGER MENU
   ========================================= */
@media (max-width: 768px) {
    .hamburger-btn { display: block !important; }
    .navbar { padding: 1rem 1.5rem !important; }
    
    .nav-links {
        display: none !important; 
        flex-direction: column !important;
        position: absolute !important;
        top: 70px !important;
        left: 0 !important;
        width: 100% !important;
        background: rgba(255, 255, 255, 0.98) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        padding: 2rem 1.5rem !important;
        box-shadow: 0 15px 30px rgba(0,0,0,0.15) !important;
        gap: 1.5rem !important;
        text-align: center !important;
        z-index: 9999 !important;
        border-bottom: 1px solid #E2E8F0 !important;
    }

    .nav-links.active { 
        display: flex !important; 
        animation: slideDown 0.3s ease forwards; 
    }

    @keyframes slideDown {
        from { opacity: 0; transform: translateY(-10px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .nav-links a, .nav-item { font-size: 1.2rem !important; padding: 12px !important; width: 100% !important; justify-content: center !important; border-radius: 8px !important; }
    #userBadge { justify-content: center; margin: 15px 0 !important; padding: 10px; background: #F8FAFC; border-radius: 50px; }
    #userName { display: block !important; }

    .hero { padding: 4rem 1.5rem; border-radius: 0 0 20px 20px; margin-bottom: 2rem; }
    .hero h1 { font-size: 2.2rem; }
    .hero p { font-size: 1rem; margin-bottom: 2rem; }

    .search-wrapper, .horizontal-filters { flex-direction: column; border-radius: var(--radius-md); gap: 0.5rem; background: transparent; border: none; box-shadow: none; padding: 0; }
    .search-wrapper input, .horizontal-filters input, .horizontal-filters select { width: 100%; border-radius: var(--radius-sm); background: var(--surface-white); border: 1px solid #E2E8F0; }
    .search-wrapper button { width: 100%; border-radius: var(--radius-sm); }

    .grid { grid-template-columns: 1fr; gap: 1.5rem; }
    .profile-header { flex-direction: column; text-align: center; padding: 1.5rem; }
    .profile-stats { flex-wrap: wrap; justify-content: center; }
    .stat-box { flex: 1 1 40%; }
    .listing-hero { grid-template-columns: 1fr; padding: 1.5rem; gap: 2rem; }
    .listing-image-container { min-height: 250px; height: 350px !important; }
    .listing-hero h1 { font-size: 2rem; }
    .modal-content, .post-form, .auth-card { padding: 1.5rem; }
    .avatar-grid { gap: 10px; }
    .avatar-option { width: 55px !important; height: 55px !important; min-width: 55px; }
}

/* =========================================
   17. LIVE TOAST NOTIFICATION SYSTEM
   ========================================= */
#toastContainer {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-notification {
    background: var(--surface-white);
    color: var(--text-main);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-left: 5px solid var(--brand-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: all;
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    max-width: 350px;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast-notification.fade-out {
    animation: fadeOutRight 0.3s ease forwards;
}

@keyframes fadeOutRight {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(50px); }
}

/* =========================================
   18. INBOX CHAT FULLSCREEN ON MOBILE
   ========================================= */
@media (max-width: 768px) {
    #chatModal {
        padding: 0 !important;
    }
    #chatModal .modal-content {
        width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        max-width: 100vw !important;
        border-radius: 0 !important;
        margin: 0 !important;
        transform: none !important;
        padding: 1.5rem 1rem !important;
    }
    #chatHistory {
        max-height: 70vh !important;
    }
}