/* style.css */
body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5; /* Light grey background */
    padding-bottom: 70px; /* Space for bottom nav */
}

/* Header */
.top-header {
    background-color: #1877f2; /* Similar blue to reference */
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky; /* Make header sticky */
    top: 0;
    z-index: 100;
}

.logo-area {
    display: flex;
    align-items: center;
}

.logo-placeholder {
    font-size: 1.5em; /* Adjust size as needed */
    margin-right: 8px;
}

.site-name {
    font-size: 1.2em;
    font-weight: bold;
}

.search-area i {
    font-size: 1.3em;
    cursor: pointer;
}

/* Main Content Area */
.content-area {
    padding: 15px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header h2 {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
}

.view-options i {
    margin-left: 10px;
    font-size: 1.2em;
    color: #888;
    cursor: pointer;
}

.view-options i.active {
    color: #1877f2; /* Highlight active view */
}

/* Product Grid */
.product-grid {
    display: grid;
    /* Mobile/Tablet Default: 2 columns */
    grid-template-columns: repeat(2, 1fr);
    gap: 15px; /* Spacing between cards */
}

/* Product Card */
.product-card {
    background-color: white;
    border-radius: 8px;
    overflow: hidden; /* Keep image corners rounded */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.product-image-container {
    position: relative; /* For positioning badges/icons */
}

.product-image-container img {
    width: 100%;
    height: 150px; /* Adjusted height */
    object-fit: cover; /* Cover the area, might crop */
    display: block; /* Remove extra space below image */
    background-color: #eee; /* Background for missing images */
}

/* Info icons on image - Simplified */
.image-count-placeholder {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.7em;
    padding: 3px 6px;
    border-radius: 4px;
}
.options-menu-placeholder {
     position: absolute;
    top: 8px;
    right: 8px;
    background-color: rgba(255, 255, 255, 0.8);
    color: #333;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8em;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}


.product-info {
    padding: 10px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.product-info h3 {
    font-size: 0.9em;
    margin: 0 0 4px 0;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -moz-line-clamp: 2; /* For older Firefox */
    line-clamp: 2; /* Standard */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.4em; /* Approx 2 lines */
}

.product-info .description {
    font-size: 0.8em;
    color: #555;
    margin: 0 0 4px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -moz-line-clamp: 2; /* For older Firefox */
    line-clamp: 2; /* Standard */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.2em; /* Approx 2 lines */
}
.product-info .location {
    font-size: 0.75em;
    color: #888;
    margin: 0 0 8px 0;
}

.price-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto; /* Pushes price to bottom */
}

.product-info .price {
    font-size: 1em;
    font-weight: bold;
    color: #d9534f; /* Reddish color */
    margin: 0;
}
.product-info .price.negotiable {
     color: #5cb85c; /* Green color */
     font-weight: normal;
}


.favorite-icon-placeholder {
    font-size: 1.1em;
    color: #ccc;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: white;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid #e0e0e0;
    padding: 5px 0;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.05);
    z-index: 100;
    height: 60px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #888;
    font-size: 0.7em;
    flex-grow: 1;
    text-align: center;
    padding-top: 5px;
    height: 100%;
}

.nav-item i {
    font-size: 1.6em;
    margin-bottom: 3px;
}

.nav-item span {
    display: block;
}
.nav-item.post-ad {
    position: relative;
    color: white;
}
.nav-item.post-ad i {
     font-size: 1.8em;
}
.post-icon-background {
    background-color: #ff9f0a; /* Orange */
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: -8px; /* Adjust vertical alignment */
    position: relative;
    top: -10px; /* Raise the button */
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.nav-item.active {
    color: #1877f2;
}

/* Styles for Admin Page */
.admin-container {
    max-width: 600px;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
}
.admin-container h1, .admin-container h2 {
    color: #333;
}
.admin-form label {
    display: block;
    margin-top: 10px;
    margin-bottom: 5px;
    font-weight: bold;
}
.admin-form input[type="text"],
.admin-form input[type="number"],
.admin-form input[type="password"], /* Ensure password field is styled */
.admin-form textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box; /* Prevents padding from expanding element */
    font-size: 16px;
}

.admin-form select {
    font-size: 16px; /* Example if you add select elements */
    /* Add other select styles as needed */
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.admin-form textarea {
    min-height: 80px;
}
.admin-form input[type="checkbox"] {
    margin-right: 5px;
    vertical-align: middle; /* Align checkbox better */
}
.admin-form label[for="is_negotiable"] { /* Style checkbox label */
    display: inline !important; /* Override block */
    font-weight: normal !important; /* Override bold */
}
.admin-form small { /* Style helper text */
    display: block;
    font-size: 0.8em;
    color: #666;
    margin-top: -3px;
    margin-bottom: 10px;
}

.admin-form button[type="submit"] { /* Style for Save button */
    background-color: #1877f2;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    margin-top: 15px;
    display: block;
    width: 100%;
}
.admin-form button[type="submit"]:hover {
    background-color: #166fe5;
}
.admin-form button[type="submit"]:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Styles for Admin Page Product List Area (within tab) */
#live-product-list {
    /* margin-top: 30px; */ /* Removed - now controlled by tab panel padding */
    /* border-top: 1px solid #eee; */ /* Removed - redundant with tab border */
    /* padding-top: 15px; */ /* Removed - controlled by tab panel */
}
#live-product-list h2 {
    text-align: left; /* Keep h2 left aligned */
    font-size: 1.2em;
    margin-bottom: 10px;
    margin-top: 0; /* Remove extra top margin */
}
#refresh-list-button { /* Style specifically for Refresh button */
    background-color: #28a745; /* Green */
    color: white;
    padding: 6px 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    margin-bottom: 15px;
    /* display: inline-block; */ /* No longer needed with block structure */
    /* width: auto; */
}
#refresh-list-button:hover {
    background-color: #218838;
}
#refresh-list-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Styling for each item in the product list */
.local-product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 5px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9em;
}
.local-product-item:last-child {
    border-bottom: none;
}
.local-product-item span { /* Product title/info */
    flex-grow: 1;
    margin-right: 10px;
    word-break: break-word; /* Prevent long titles from overflowing */
}
.local-product-item button { /* Style for Delete button */
    background-color: #dc3545; /* Red for delete */
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.8em;
    /* margin-top: 0; */ /* Not needed */
    /* width: auto; */ /* Not needed */
    flex-shrink: 0; /* Prevent delete button from shrinking */
}
.local-product-item button:hover {
    background-color: #c82333;
}
.local-product-item button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}


/* Success/Error message styling */
#ajax-message {
    /* Styles are set by JS, but ensure it has base layout */
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 15px;
    text-align: center;
}
.success-message { /* (Legacy, might remove if #ajax-message covers all) */
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 10px;
    margin-top: 15px;
    margin-bottom: 15px; /* Added margin bottom */
    border-radius: 4px;
    text-align: center;
}
/* Info/Instructions styling (if needed later) */
.instructions {
    margin-top: 15px;
    padding: 10px;
    background-color: #fffbe6;
    border: 1px solid #ffe58f;
    border-radius: 4px;
    font-size: 0.9em;
    margin-bottom: 15px; /* Added margin bottom */
}
.instructions ol {
    margin-top: 5px;
    padding-left: 20px;
}


/* --- Tab Styles for Admin Page --- */
.tab-buttons {
    display: flex;
    border-bottom: 2px solid #ddd; /* Line below tabs */
    margin-bottom: 15px;
}

.tab-button {
    padding: 10px 15px;
    cursor: pointer;
    background-color: #f1f1f1; /* Default tab background */
    border: none;
    border-bottom: 2px solid transparent; /* Placeholder for active border */
    margin-bottom: -2px; /* Align bottom border with container border */
    font-size: 1em;
    color: #555;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    outline: none; /* Remove browser default outline */
}

.tab-button:hover {
    background-color: #e0e0e0; /* Hover background */
}

.tab-button.active {
    background-color: #fff; /* Active tab background (same as panel) */
    border-bottom: 2px solid #1877f2; /* Active tab highlight color */
    color: #1877f2; /* Active tab text color */
    font-weight: bold;
}

/* Style the tab content panels */
.tab-content {
    /* No specific styles needed for the container itself */
}
.tab-panel {
    display: none; /* Hide panels by default */
    padding-top: 15px; /* Add some space above panel content */
}

.tab-panel.active {
    display: block; /* Show the active panel */
}

/* Optional: Style for Tool Buttons */
.admin-tool-button {
    background-color: #ffc107; /* Warning yellow */
    color: #333;
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    margin-top: 10px;
}
.admin-tool-button:hover {
    background-color: #e0a800;
}
.admin-tool-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.7;
}


/* --- Styles for Product List Table --- */
.table-responsive-container {
    width: 100%;
    overflow-x: auto; /* Enable horizontal scroll on small screens */
    -webkit-overflow-scrolling: touch; /* Smoother scrolling on iOS */
    margin-top: 15px; /* Space above table */
    border: 1px solid #ddd; /* Optional border around scroll container */
    border-radius: 4px;
}

.product-table {
    width: 100%;          /* Table tries to fill container */
    min-width: 500px;     /* Minimum width before scroll appears */
    border-collapse: collapse; /* Merge cell borders */
    font-size: 0.9em;     /* Adjust font size as needed */
}

.product-table thead {
    background-color: #f8f9fa; /* Light grey header */
    border-bottom: 2px solid #dee2e6; /* Header bottom border */
}

.product-table th,
.product-table td {
    padding: 8px 10px;       /* Cell padding */
    border: 1px solid #ddd; /* Cell borders */
    text-align: left;     /* Default text alignment */
    vertical-align: middle; /* Align cell content vertically */
}

.product-table th {
    font-weight: 600;     /* Make headers bold */
    white-space: nowrap;  /* Prevent header text wrapping */
}

/* Column Specific Alignment/Width */
.product-table th:nth-child(1), /* N Column */
.product-table td:nth-child(1) {
    text-align: center;
    width: 40px; /* Fixed width for N */
}
.product-table th:nth-child(2), /* Picture Column */
.product-table td:nth-child(2) {
    width: 70px; /* Fixed width for Picture */
    text-align: center;
}
.product-table th:nth-child(4), /* Price Column */
.product-table td:nth-child(4) {
    text-align: right;
    width: 100px; /* Approx width for Price */
    white-space: nowrap;
}
.product-table td.price-negotiable {
    font-style: italic;
    color: #5cb85c; /* Green for negotiable */
    text-align: center; /* Center 'Negotiable' */
}

.product-table th:nth-child(5), /* Actions Column */
.product-table td:nth-child(5) {
    width: 130px; /* Approx width for two buttons */
    text-align: center;
}

/* Thumbnail Image Styling */
.product-list-thumbnail {
    max-width: 50px;
    max-height: 50px;
    height: auto;
    display: block; /* Center block image */
    margin: 0 auto; /* Center block image */
    border-radius: 3px;
    background-color: #eee; /* BG for loading/missing */
}

/* Actions Cell Button Styling */
.product-table .actions-cell {
    white-space: nowrap; /* Keep buttons on one line */
}
.product-table .actions-cell button {
    padding: 4px 8px;
    font-size: 0.85em;
    margin: 0 3px; /* Space between buttons */
    border-radius: 4px;
    cursor: pointer;
    border: none;
    color: white;
}
.product-table .actions-cell .edit-button {
    background-color: #ffc107; /* Yellow */
    color: #333;
}
.product-table .actions-cell .edit-button:hover {
    background-color: #e0a800;
}
.product-table .actions-cell .delete-button {
    background-color: #dc3545; /* Red */
}
.product-table .actions-cell .delete-button:hover {
    background-color: #c82333;
}
.product-table .actions-cell button:disabled {
     background-color: #cccccc; cursor: not-allowed; opacity: 0.7;
}


/* Styling for Loading/Empty messages within table */
.product-table .table-message {
    text-align: center;
    padding: 20px;
    color: #555;
    font-style: italic;
}
.product-table .table-message.error {
    color: #dc3545; /* Red */
    font-style: normal;
    font-weight: bold;
}

/* Remove old list item styling if present */
.local-product-item {
    /* display: none; */ /* Or simply remove the class definition */
}

/* Style for Cancel Edit Button */
.cancel-edit-button {
    background-color: #6c757d; /* Grey */
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em; /* Slightly smaller */
    margin-top: 10px; /* Space above */
    display: block; /* Full width like save button */
    width: 100%;
    text-align: center;
}
.cancel-edit-button:hover {
    background-color: #5a6268;
}
.cancel-edit-button:disabled {
     background-color: #cccccc; cursor: not-allowed; opacity: 0.7;
}

/* Initially hide cancel button */
.cancel-edit-button {
    display: none;
}



/* Link to preview live site in admin */
.admin-action-links {
    text-align: right; /* Align link to the right */
    margin-bottom: 15px; /* Space below the link, above tabs */
    /* padding-right: 5px; /* Optional: Minor alignment adjustment */
}

.preview-site-link {
    display: inline-block; /* Allows padding/margin */
    padding: 6px 12px;
    background-color: #6c757d; /* Bootstrap secondary grey - stands out */
    border: 1px solid #5a6268;
    border-radius: 5px;
    color: #ffffff; /* White text */
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 500;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.preview-site-link i {
    margin-right: 6px; /* Space between icon and text */
    vertical-align: middle; /* Align icon slightly better */
}

.preview-site-link:hover {
    background-color: #5a6268;
    border-color: #545b62;
    color: #ffffff;
    text-decoration: none;
}


/* Prevent linked product cards from having default link styles */
a.product-card,
a.product-card:hover,
a.product-card:visited,
a.product-card:active {
    text-decoration: none; /* Remove underline */
    color: inherit;      /* Use the inherited text color (usually black or grey) */
}

/* Optional: Slightly change appearance on hover for linked cards */
a.product-card:hover {
   box-shadow: 0 4px 8px rgba(0,0,0,0.15); /* Slightly bigger shadow on hover */
   /* transform: translateY(-2px); /* Optional subtle lift */
}



/* Responsive adjustments */
@media (max-width: 360px) {
    .product-info h3 { font-size: 0.85em; min-height: 2.3em; }
    .product-info .description { font-size: 0.75em; min-height: 2.0em; }
    .product-info .price { font-size: 0.9em; }
    .nav-item i { font-size: 1.4em; }
    .nav-item span { font-size: 0.9em; /* Maintain readability */ }
    .post-icon-background { width: 40px; height: 40px; top: -8px; }
    .nav-item.post-ad i { font-size: 1.6em; }
    .admin-form button[type="submit"] { font-size: 0.9em; }
    #refresh-list-button { font-size: 0.8em; padding: 6px 10px;}
    .local-product-item button { font-size: 0.7em; padding: 3px 6px;}
    .tab-button { font-size: 0.9em; padding: 8px 12px; }
}

/* --- Desktop Styles (for wider screens) --- */
@media (min-width: 1200px) { /* Using 1200px as breakpoint for 8 columns */

    .content-area {
        /* Remove max-width restriction for desktop to allow 8 columns */
        max-width: none;
        margin-left: 0;  /* Reset centering */
        margin-right: 0; /* Reset centering */
        padding: 15px 30px; /* Add more horizontal padding maybe */
        margin-bottom: 80px; /* Keep bottom margin */
    }

    .product-grid {
        /* Desktop: 8 columns */
        grid-template-columns: repeat(8, 1fr);
        gap: 20px; /* Slightly larger gap maybe */
    }

    /* Optional: Hide mobile bottom nav on wide desktop? */
    /*
    .bottom-nav { display: none; }
    body { padding-bottom: 0; }
    .content-area { margin-bottom: 20px; }
    */
}
/* --- End Desktop Styles --- */


/* --- Keep the #loading-indicator styles --- */
#loading-indicator {
    display: none; /* HIDE BY DEFAULT using display */
    min-height: 70px;
    text-align: center;
    padding: 20px 0;
    grid-column: 1 / -1;
    box-sizing: border-box;
    /* Remove any .visible class styles */
}