:root {
    --primary-blue: #3498db;
    --light-blue: #5bc0de;
    --text-dark: #333;
    --text-red: #e74c3c;
    --border-light: #ecf0f1;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --success-green: #2ecc71;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    /* Using Battambang for Khmer support, Inter for English */
    font-family: 'Koulen', 'Inter', sans-serif; 
}

body {
    background-color: #f4f7f9;
    color: var(--text-dark);
    font-family: 'Koulen', 'Inter', sans-serif;
}

/* Base Mobile Container - ensures padding is consistent */
.container {
    padding: 0 15px; /* Increased padding slightly for better look */
    margin: 0 auto;
}

/* --- Header/Navbar Styling --- */
.navbar {
    background-color: var(--primary-blue);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    box-shadow: 0 2px 4px var(--shadow-light);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-area {
    display: flex;
    align-items: center;
}

.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0, 0, 0, 0.6); /* Black w/ opacity */
    padding-top: 50px; /* Space from top */
    backdrop-filter: blur(5px); /* Optional: nice blur effect */
}

/* Example CSS for the selection visual feedback */
.price-option {
    cursor: pointer;
    border: 2px solid transparent; /* Default transparent border */
    transition: border 0.2s ease-in-out, background-color 0.2s ease-in-out;
    border-radius: 8px; /* Added for a rounded look */
}

.price-option:hover {
    border-color: #a0a0a0; /* Subtle hover effect */
}

/* This class is added/removed by JavaScript */
.price-option.selected {
    /* Main selection outline effect */
    border: 2px solid #10b981; /* A clear, friendly green outline */
    background-color: #f0fdf4; /* Very light green background */
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2); /* Light glow for emphasis */
}

/* You may need to add this to ensure the base price line is also well-styled */
.base-price-line {
    padding: 8px 10px; /* Give it some space */
    margin-bottom: 10px;
}

/* Ensure the elements inside the grid items have padding for selection border to work */
.price-grid .price-item {
    padding: 8px 10px;
}
.modal-content {
    background-color: #fff;
    margin: 10% auto; /* Center modal vertically and horizontally */
    padding: 25px;
    border-radius: 12px;
    max-width: 400px; /* Fixed width for the phone-like view */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    position: relative;
    /* Ensure the content is using the Khmer font */
    font-family: 'Inter', 'Battambang', sans-serif; 
}

/* Styles to match the Base Price line in the image */
.base-price-line {
    font-size: 1.1rem;
    color: #333;
    margin: 15px 0 10px;
}
.price-value-large {
    color: #e3342f; /* Red color matching the image */
    font-weight: 700;
}

.logo-icon {
    /* Assuming user image is loaded, otherwise a placeholder style */
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: white;
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-blue);
    font-size: 1.2em;
    object-fit: cover; /* Ensure user's logo image fits */
}

.navbar h1 {
    font-size: 1.3em;
    font-weight: bold;
}

.nav-btn {
    padding: 8px 15px;
    margin-left: 8px;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s, transform 0.1s;
}

.nav-btn:active {
    transform: scale(0.98);
}

.buy-btn {
    background-color: white;
    color: var(--primary-blue);
}

.sell-btn {
    background-color: var(--light-blue);
    color: white;
    border: 1px solid white;
}

/* --- Banner Styling --- */
.banner {
    margin: 15px 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); /* Slightly stronger shadow for banner */
}

.banner-image {
    width: 100%;
    height: auto;
    display: block;
}

/* --- Search Bar Styling --- */
.search-bar {
    display: flex;
    align-items: center;
    background-color: white;
    padding: 10px 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px var(--shadow-light);
}

.search-bar input {
    flex-grow: 1;
    border: none;
    padding: 5px 10px;
    font-size: 1em;
    outline: none;
}

.search-bar i {
    color: #95a5a6;
    margin-right: 10px;
}

/* --- Product Card Styling --- */
.product-card {
    display: flex;
    background-color: white;
    border-radius: 12px;
    margin-bottom: 18px;
    box-shadow: 0 2px 4px var(--shadow-light);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.18);
}

.product-image-container {
    flex-shrink: 0;
    width: 140px; 
    height: 140px;
    overflow: hidden;
    border-radius: 12px 0 0 12px; 
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image {
    transform: scale(1.08); 
}

.product-details {
    padding: 12px 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1; 
}

.product-title {
    font-size: 1.15em;
    font-weight: bold;
    margin-bottom: 4px;
    line-height: 1.2;
}

.product-price {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--text-red);
    margin-bottom: 4px;
}

.product-description {
    font-size: 0.85em;
    color: #777;
    line-height: 1.4;
    max-height: 40px; 
    overflow: hidden;
}

.buy-now-btn {
    background-color: var(--primary-blue);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 0.9em;
    align-self: flex-start; 
    margin-top: 8px; 
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.buy-now-btn:hover {
    background-color: #2980b9;
}


/* --- Modal Styling --- */
.modal {
    display: none; 
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    padding-top: 50px;
}

.modal-content {
    background-color: white;
    margin: 10% auto; 
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px; 
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    position: relative;
    text-align: center;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 32px;
    font-weight: bold;
    position: absolute;
    top: 5px;
    right: 15px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close-btn:hover, .close-btn:focus {
    color: var(--text-dark);
    text-decoration: none;
    cursor: pointer;
}

.modal-title {
    font-size: 1.4em;
    color: var(--primary-blue);
    margin-bottom: 15px;
    padding-right: 30px; 
    text-align: left;
}

.modal-ad-image-container {
    margin-bottom: 15px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    overflow: hidden;
}

.modal-ad-image {
    width: 100%;
    height: auto;
    display: block;
}

.modal-pricing-details {
    text-align: left;
    padding-bottom: 10px;
}

.description-text {
    font-size: 0.9em;
    line-height: 1.4;
    color: #555;
    padding: 5px 0 15px 10px; 
    border-left: 3px solid var(--light-blue);
    margin-bottom: 15px;
    white-space: pre-line; /* Essential for displaying line breaks from data */
}

/* Price Grid Styling for the Modal */
.price-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
    padding: 10px;
    border: 1px dashed var(--border-light);
    border-radius: 8px;
}

.price-item {
    padding: 8px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95em;
    font-weight: 500;
    border: 1px solid var(--border-light);
}

.price-item p:first-child {
    color: #666;
}

/* Highlight the base price prominently */
.price-item.quality-base {
    grid-column: 1 / 3; 
    background-color: var(--primary-blue);
    color: white;
    font-weight: bold;
    font-size: 1.1em;
    border: none;
}

.price-item.quality-base .price-value {
    color: white;
}

.price-value {
    font-weight: bold;
    color: var(--text-red);
}


.buy-now-modal-btn {
    background-color: var(--success-green);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    width: 100%;
    margin-top: 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    box-shadow: 0 4px 6px rgba(46, 204, 113, 0.4);
}

.buy-now-modal-btn:hover {
    background-color: #27ae60;
}

/* Error message styling */
.error-message {
    padding: 15px;
    background-color: #fce4e4;
    border: 1px solid var(--text-red);
    color: var(--text-red);
    border-radius: 8px;
    margin: 15px 0;
    font-size: 1em;
    text-align: center;
    line-height: 1.4;
}


/* ------------------------------------------------------------------ */
/* --- ENFORCING MOBILE-ONLY LOOK ON LARGER SCREENS (Desktops/Tablets) */
/* ------------------------------------------------------------------ */

@media (min-width: 600px) {
    
    body {
        background-color: #ddd; 
    }

    .container {
        max-width: 400px; 
        margin: 0 auto; 
        box-shadow: 0 0 15px rgba(0, 0, 0, 0.25); 
        min-height: 100vh; 
        background-color: #f4f7f9; 
    }

    .navbar {
        max-width: 400px; 
        margin: 0 auto;
    }
    
    .modal-content {
        margin-top: 80px; 
    }
}
