/* ========================================================== */
/* 1. CSS Variables & Global Resets (Modern Approach)         */
/* ========================================================== */
:root {
    /* Primary Colors (New Highlight: #1DA1F2 - Light Blue) */
    --primary-color: #1DA1F2;      /* Light Blue/Twitter Blue */
    --primary-hover: #0C85D2;      /* Darker shade of Blue */
    --secondary-color: #6c757d;    /* Grey for text */
    
    /* Accent & Action Colors (New Highlight: #F58220 - Orange) */
    --accent-color: #F58220;       /* Orange for positive actions (Post Ad) */
    --warning-color: #ffc107;      /* Yellow for standard warnings/status (Kept for contrast) */
    
    /* Danger Color (New Highlight: #E91E63 - Pink/Magenta) */
    --danger-color: #E91E63;       /* Pink/Magenta for price highlight/delete */
    
    /* Backgrounds & Shadows */
    --body-bg: #ffffff;            /* CHANGED: Global white background */
    --card-bg: #ffffff;            /* Kept white */
    --box-shadow-light: 0 4px 12px rgba(0, 0, 0, 0.08); /* Soft, deep shadow */
    --box-shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.15);
    
    /* Spacing & Radius */
    --spacing-unit: 1rem;
    --border-radius-large: 10px;
    --border-radius-small: 5px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--body-bg);
    color: #343a40;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
}

/* ========================================================== */
/* 2. Layout & Container                                      */
/* ========================================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-unit);
    display: flex;
    flex-direction: column;
}

/* ========================================================== */
/* 3. Header & Auth Status (Styling the Top Bar)              */
/* ========================================================== */
header {
    background-color: var(--card-bg);
    /* CHANGE: Removed padding/margin and bottom border to collapse the header */
    padding: 0;
    margin-bottom: 0; 
    box-shadow: var(--box-shadow-light);
    border-bottom: none; 
}
/* Hiding the header h1, only the logo container is visible */
header h1 {
    display: none; 
}

#logo-under-filter {
    text-align: center;
    /* CHANGE: Reduced margin and padding for less vertical space */
    margin-bottom: 5px; 
    padding-top: 5px;
    order: -2;
}

#header-logo {
    /* LOGO SIZE CHANGE: Increased logo width */
    width: 200px;
    height: auto;
    cursor: pointer;
    transition: transform 0.3s ease;
}
#header-logo:hover {
    transform: scale(1.05);
}

#auth-status {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    /* CHANGE: Removed padding for minimum height */
    padding: 0;
    order: -1;
}

#profile-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid var(--primary-color);
    transition: box-shadow 0.2s;
}
#profile-img:hover {
    box-shadow: 0 0 0 4px rgba(29, 161, 242, 0.3);
}

#profile-dropdown-container {
    position: relative;
}

#profile-dropdown-menu {
    position: absolute;
    top: 50px;
    right: 0;
    background-color: var(--card-bg);
    min-width: 180px;
    box-shadow: var(--box-shadow-light);
    border-radius: var(--border-radius-small);
    z-index: 1000;
    overflow: hidden;
}

#profile-dropdown-menu a {
    display: block;
    padding: 10px 15px;
    text-decoration: none;
    color: var(--secondary-color);
    transition: background-color 0.2s;
}

#profile-dropdown-menu a:hover {
    background-color: var(--body-bg);
    color: var(--primary-color);
}

#google-login-btn, #post-ad-btn {
    padding: 10px 15px;
    border-radius: var(--border-radius-small);
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s, transform 0.1s;
    white-space: nowrap;
}

#google-login-btn {
    background-color: var(--primary-color);
    color: white;
}
#google-login-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

#post-ad-btn {
    background-color: var(--accent-color);
    color: white;
}
#post-ad-btn:hover {
    background-color: #D56B13;
    transform: translateY(-1px);
}

/* ========================================================== */
/* 4. Filter Bar (Modern Flex Layout)                         */
/* ========================================================== */
#filter-bar {
    display: flex;
    gap: 10px;
    padding: 15px;
    background-color: var(--card-bg);
    border-radius: var(--border-radius-large);
    box-shadow: var(--box-shadow-light);
    margin-bottom: var(--spacing-unit);
    flex-wrap: wrap;
}

#filter-bar input, #filter-bar select {
    flex-grow: 1;
    min-width: 150px;
    padding: 10px 15px;
    border: 1px solid #ced4da;
    border-radius: var(--border-radius-small);
    font-size: 1rem;
}

/* ========================================================== */
/* 5. Listings & Product Cards (Grid & Slider)                */
/* ========================================================== */

#listings-container h3, #listings-container h2 {
    margin: 20px 0 10px 0;
    color: var(--primary-color);
    border-left: 5px solid var(--accent-color);
    padding-left: 10px;
}

/* --- Card Styling (The core aesthetic) --- */
.product-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius-large);
    overflow: hidden;
    box-shadow: var(--box-shadow-light);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    padding: var(--spacing-unit);
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--box-shadow-hover);
}

.product-card-img {
    width: 100%;
    /* Product size (small): Reduced image height */
    height: 120px;
    object-fit: cover;
    border-radius: var(--border-radius-small);
    margin-bottom: 10px;
}

.product-card h3 {
    /* Product size (small): Reduced font size */
    font-size: 1rem;
    margin: 0 0 5px 0;
    color: var(--primary-color);
    /* CHANGE: Limit title to 2 lines with ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-card .price {
    /* Product size (small): Reduced font size */
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--danger-color);
    margin-bottom: 5px;
}

/* --- Grid View --- */
.grid-view {
    display: grid;
    /* Product size (small): Reduced minmax width for smaller cards */
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--spacing-unit);
    margin-top: 15px;
}

/* --- Slider View (Latest CSS Scroll Snap) --- */
.category-slider {
    margin-bottom: 30px;
}
.category-slider h2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 1.5rem;
}
.see-more-link {
    font-size: 0.9rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: normal;
}

.slider-content {
    display: flex;
    overflow-x: scroll;
    padding-bottom: 15px;
    gap: 15px;
    /* --- Modern Scroll Snap Feature --- */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.slider-content > .product-card {
    /* Product size (small): Reduced fixed width for slider items */
    flex: 0 0 240px;
    scroll-snap-align: start;
}

/* Hide Scrollbar for cleaner look (Optional but recommended for modern feel) */
.slider-content::-webkit-scrollbar {
    display: none;
}
.slider-content {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ========================================================== */
/* 6. Detail View & Image Gallery                             */
/* ========================================================== */
#detail-view-container {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius-large);
    box-shadow: var(--box-shadow-light);
}

/* --- Image Slider (MUST BE FLEX with hidden overflow) --- */
#image-gallery-container {
    position: relative;
    margin-bottom: 20px;
    overflow: hidden;
    border-radius: var(--border-radius-large);
}

#detail-image-slider {
    display: flex;
    overflow-x: scroll;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    height: 350px;
    border-radius: var(--border-radius-large);
    background-color: #eee;
}
#detail-image-slider::-webkit-scrollbar { display: none; }
#detail-image-slider { -ms-overflow-style: none; scrollbar-width: none; }


.detail-gallery-img {
    flex-shrink: 0;
    width: 100%;
    object-fit: contain;
    scroll-snap-align: start;
}

#slider-nav {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
}
.slider-dot {
    width: 10px;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid var(--primary-color);
}
.slider-dot.active {
    background-color: var(--primary-color);
    border-color: white;
}

/* --- Detail Buttons --- */
#ad-action-buttons-container {
    display: flex;
    gap: 10px;
}
#ad-action-buttons-container button {
    padding: 12px;
    border-radius: var(--border-radius-small);
    font-weight: bold;
    flex-grow: 1;
    transition: transform 0.1s;
}
#ad-action-buttons-container button:active {
    transform: scale(0.98);
}
#favorite-ad-btn {
    background-color: var(--warning-color);
    color: #343a40;
    border: none;
}
#favorite-ad-btn.active {
     background-color: var(--primary-color);
     color: white;
}
#share-ad-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
}

/* !!! MODIFICATION START: Hiding the "Share Ad" button as requested !!! */
#share-ad-btn {
    display: none !important; 
}
/* The remaining button in #ad-action-buttons-container (the WhatsApp Share button in your image, 
   which is likely a custom element or another button like #favorite-ad-btn repurposed) 
   will automatically expand to full width due to flex-grow: 1. */
/* !!! MODIFICATION END !!! */

.chat-contact-btn {
    display: block;
    width: 100%;
    padding: 15px;
    text-align: center;
    border-radius: var(--border-radius-small);
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    margin-top: 10px;
    transition: background-color 0.2s;
}

/* Quick contact buttons are smaller */
#quick-contact-container {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 20px;
}
#quick-contact-container .chat-contact-btn {
    flex-grow: 1;
    margin: 0;
    font-size: 0.9rem;
    padding: 10px;
}

#in-app-chat-btn-quick, #in-app-chat-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
}
#whatsapp-chat-btn-quick, #whatsapp-chat-btn {
    background-color: #25d366;
    color: white;
    border: none;
}

/* --- Related Ads Slider (Same as Category Slider) --- */
#related-ads-content {
    /* Uses .slider-content and .product-card styling */
    margin-bottom: 10px;
}


/* ========================================================== */
/* 7. Ad Post Form (Clean Input Styles)                       */
/* ========================================================== */
#ad-post-view-container {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius-large);
    box-shadow: var(--box-shadow-light);
}

#ad-post-form input[type="text"], 
#ad-post-form input[type="file"],
#ad-post-form select, 
#ad-post-form textarea {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 15px;
    border: 1px solid #ced4da;
    border-radius: var(--border-radius-small);
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

#ad-post-form textarea {
    min-height: 120px;
    resize: vertical;
}

#ad-post-form input:focus, 
#ad-post-form select:focus, 
#ad-post-form textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(29, 161, 242, 0.25);
    outline: none;
}

#ad-post-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--secondary-color);
}

#ad-post-form button[type="submit"] {
    display: block;
    width: 100%;
    padding: 15px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    transition: background-color 0.3s, transform 0.1s;
}
#ad-post-form button[type="submit"]:hover {
    background-color: var(--primary-hover);
}
#ad-post-form button[type="submit"]:disabled {
    background-color: #a0c9f1;
    cursor: not-allowed;
}


/* ========================================================== */
/* 8. My Account & Inbox (Card Layout)                        */
/* ========================================================== */

#my-account-view-container {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius-large);
    box-shadow: var(--box-shadow-light);
}

.account-btn {
    padding: 10px 15px;
    margin-right: 10px;
    border: 1px solid var(--secondary-color);
    background-color: transparent;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    margin-bottom: 10px;
}

.account-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: bold;
}
.account-btn:hover:not(.active) {
    background-color: #f0f0f0;
}

hr {
    border: 0;
    height: 1px;
    background: #e0e0e0;
    margin: 15px 0;
}


/* --- Inbox Thread Styling --- */
.inbox-thread-card {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px 0;
    transition: background-color 0.2s;
    border-radius: var(--border-radius-small);
    /* CHANGE: Added min-width and max-width to ensure the card fits the container and doesn't push out */
    min-width: 0;
    max-width: 100%;
}

.inbox-thread-card:hover {
    background-color: #f0f0f0;
}

.inbox-thread-card img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--border-radius-small);
    margin-right: 15px;
    flex-shrink: 0;
}

.inbox-thread-info {
    flex-grow: 1;
    /* CHANGE: Explicitly set min-width to 0 and use overflow-x: hidden on the parent to prevent content overflow from pushing the card out */
    min-width: 0;
}

.inbox-ad-title {
    font-weight: bold;
    color: var(--primary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-last-message {
    font-size: 0.9rem;
    color: var(--secondary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-timestamp {
    font-size: 0.8rem;
    color: #999;
    flex-shrink: 0;
    align-self: flex-start;
}
/* Assuming the 'red X' button is placed after the timestamp or is a small, non-flex-growing element.
   By ensuring .inbox-thread-info has min-width: 0 and flex-grow: 1, and the parent is correctly sized, 
   the content should wrap/truncate correctly without horizontal overflow.
*/


/* ========================================================== */
/* 9. Chat View (Modern Messaging)                            */
/* ========================================================== */
#chat-section {
    background-color: var(--body-bg);
    border-radius: var(--border-radius-large);
    overflow: hidden;
}

.chat-product-header {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--card-bg);
    border-bottom: 1px solid #ddd;
    box-shadow: var(--box-shadow-light);
}

.chat-product-header img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: var(--border-radius-small);
    margin-right: 10px;
}

#message-list {
    height: 60vh;
    overflow-y: scroll;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: #f7f7f7;
}

.message-item {
    /* CHANGE: Limiting max-width to 70% is correct, no change needed here */
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    font-size: 0.95rem;
}

.message-item.sent {
    background-color: var(--primary-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message-item.received {
    background-color: var(--card-bg);
    color: #343a40;
    align-self: flex-start;
    border: 1px solid #ddd;
    border-bottom-left-radius: 4px;
}

.message-meta {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 5px;
}
.message-item.received .message-meta {
     color: #999;
}

/* --- Input Form --- */
#message-input-form {
    display: flex;
    padding: 10px 15px;
    background-color: var(--card-bg);
    border-top: 1px solid #ddd;
}

#message-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius-small);
    margin-right: 10px;
    font-size: 1rem;
}

#message-input-form button {
    padding: 10px 15px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    font-weight: bold;
    flex-shrink: 0;
}

/* --- Quick Replies (Flexbox Scrollable) --- */
#chat-quick-reply-container {
    display: flex;
    overflow-x: scroll;
    gap: 8px;
    padding: 10px 15px;
    background-color: var(--card-bg);
    border-bottom: 1px solid #eee;
    -webkit-overflow-scrolling: touch;
}
#chat-quick-reply-container::-webkit-scrollbar { display: none; }

.quick-reply-btn {
    flex-shrink: 0;
    padding: 8px 12px;
    border: 1px solid var(--primary-color);
    background-color: transparent;
    color: var(--primary-color);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background-color 0.2s;
}
.quick-reply-btn:hover {
    background-color: var(--primary-color);
    color: white;
}


/* ========================================================== */
/* 10. Footer & Splash Screen                                 */
/* ========================================================== */
#main-footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 30px;
    border-top: 1px solid #ddd;
    background-color: var(--card-bg);
    font-size: 0.9rem;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 20px;
    margin-bottom: 15px;
}

.footer-links a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: color 0.2s;
}
.footer-links a:hover {
    color: var(--primary-color);
}


/* --- Global Notification Bar --- */
#inbox-notification-bar {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--accent-color);
    color: white;
    padding: 15px 20px;
    border-radius: var(--border-radius-large);
    box-shadow: var(--box-shadow-hover);
    z-index: 5000;
    cursor: pointer;
    font-weight: bold;
    transition: opacity 0.3s;
    display: none;
}

/* --- Splash Screen --- */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 1s ease-out, visibility 1s;
}
#splash-screen.hidden-splash {
    opacity: 0;
    visibility: hidden;
}
.splash-content img {
    width: 250px;
    height: auto;
    animation: pulse 1.5s infinite alternate;
}
@keyframes pulse {
    from { transform: scale(0.95); opacity: 0.8; }
    to { transform: scale(1.05); opacity: 1; }
}


/* ========================================================== */
/* 11. Static Page (Contact/Policy) Styles (From contact.html)*/
/* ========================================================== */

.static-page-container { 
    max-width: 800px; 
    margin: 30px auto;
    padding: 40px;
    background-color: var(--card-bg);
    border-radius: var(--border-radius-large);
    box-shadow: var(--box-shadow-light);
}

.static-page-header { 
    text-align: center; 
    margin-bottom: 30px; 
    border-bottom: 2px dashed #eee; 
    padding-bottom: 20px; 
}
.static-page-header h1 {
    color: var(--primary-color);
    margin-top: 15px;
}
.static-page-header a { 
    color: var(--accent-color); 
    text-decoration: none; 
    font-weight: bold;
}

.urdu-text { 
    direction: rtl; 
    text-align: right; 
    margin-bottom: 20px; 
    border-bottom: 1px solid #eee; 
    padding-bottom: 15px; 
    font-size: 1.1rem;
}
.urdu-text p, .urdu-text li { 
    margin-bottom: 10px; 
} 

.english-translation { 
    direction: ltr; 
    text-align: left; 
    background-color: #e8f4ff;
    padding: 15px; 
    border-left: 5px solid var(--primary-color); 
    margin-top: 15px; 
    border-radius: var(--border-radius-small);
}

/* Reusing ad-post form styles for contact form */
.contact-form-group { 
    margin-bottom: 20px; 
    direction: rtl; 
    text-align: right; 
}
.contact-form-group label { 
    display: block; 
    margin-bottom: 8px; 
    font-weight: bold; 
    color: var(--primary-color);
}
.contact-form-group input, 
.contact-form-group textarea {
    /* Reuses core input styles from ad-post-form */
    width: 100%;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: var(--border-radius-small);
    box-sizing: border-box; 
    direction: rtl; 
}
.contact-form-group button {
    /* Reuses core submit button styles */
    background-color: var(--primary-color);
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    font-size: 1.1em;
}


/* ========================================================== */
/* 12. Media Queries (Mobile First)                           */
/* ========================================================== */

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    #auth-status {
        justify-content: space-between;
        /* CHANGE: Removed padding for minimum height on mobile */
        padding: 0; 
    }

    #filter-bar {
        flex-direction: column;
        padding: 10px;
        gap: 8px;
        border-radius: var(--border-radius-small);
    }
    #filter-bar input, #filter-bar select {
        min-width: 100%;
    }
    
    .grid-view {
        /* Two columns side-by-side on mobile for smaller product cards */
        grid-template-columns: repeat(2, 1fr); 
    }
    
    /* Center the quick contact container on mobile */
    #quick-contact-container {
        flex-wrap: wrap;
    }
    #quick-contact-container .chat-contact-btn {
        width: 100%;
    }
    
    #detail-image-slider {
        height: 300px;
    }
    
    .static-page-container {
        padding: 20px;
        margin: 10px;
    }

    .footer-links {
        flex-direction: column;
        gap: 5px;
    }
    .footer-links a {
        padding: 5px 0;
        border-bottom: 1px dotted #eee;
    }
}