/* Import variables from main style.css if not already defined globally */
/* This is a fallback, ideally :root variables are in a single main CSS file */
:root {
    --primary-color: #4A90E2; /* Modern Blue */
    --secondary-color: #50E3C2; /* Teal/Mint accent */
    --accent-color: #E24A68; /* Soft Red for highlights/errors */
    --text-dark: #2C3E50; /* Darker text for headings */
    --text-light: #5A6A7D; /* Lighter text for body */
    --bg-light: #F8F9FA; /* Light background */
    --bg-card: #FFFFFF; /* Card background */
    --border-color: #E0E6EB; /* Light border */
    --shadow-light: rgba(0, 0, 0, 0.05);
    --shadow-medium: rgba(0, 0, 0, 0.1);
    --border-radius-card: 12px;
    --border-radius-button: 8px;
    --transition-speed: 0.3s ease;
}

/* --- Ads Page Header --- */
.ads-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 25px 30px; /* Adjust padding for header card */
    margin-bottom: 30px;
}

.ads-page-header .page-title {
    margin: 0;
    font-size: 2.2em;
    color: var(--text-dark);
    flex-grow: 1; /* Allow title to take space */
    text-align: center;
}

.back-home-btn {
    /* Inherits btn-secondary-modern styles */
    padding: 10px 20px; /* Slightly smaller button for header */
    font-size: 0.9em;
    white-space: nowrap; /* Prevent text wrap */
}

/* --- Filter and Sort Section --- */
.filter-sort-section {
    padding: 25px 30px;
    margin-bottom: 30px;
    background-color: var(--bg-card);
    border-radius: var(--border-radius-card);
    box-shadow: 0 6px 20px var(--shadow-light);
}

.filter-sort-form {
    display: flex;
    flex-wrap: wrap; /* Allow items to wrap on smaller screens */
    gap: 20px; /* Space between form groups */
    align-items: flex-end; /* Align items to the bottom */
    justify-content: center; /* Center form elements */
}

.form-group-inline {
    display: flex;
    flex-direction: column;
    flex: 1; /* Allow items to grow and shrink */
    min-width: 180px; /* Minimum width for select boxes */
}

.form-label {
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 0.95em;
}

.form-select {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-button);
    background-color: var(--bg-light);
    color: var(--text-dark);
    font-size: 1em;
    appearance: none; /* Remove default dropdown arrow */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%234A90E2%22%20d%3D%22M287%2C197.3L159.9%2C69.8c-4.8-4.8-12.5-4.8-17.3%2C0L5.4%2C197.3c-4.8%2C4.8-4.8%2C12.5%2C0%2C17.3c4.8%2C4.8%2C12.5%2C4.8%2C17.3%2C0l130-130l130%2C130c4.8%2C4.8%2C12.5%2C4.8%2C17.3%2C0C291.8%2C209.8%2C291.8%2C202.1%2C287%2C197.3z%22%2F%3E%3C%2Fsvg%3E'); /* Custom arrow */
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    padding-right: 30px; /* Space for custom arrow */
}

.form-select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

.filter-sort-btn {
    /* Inherits btn-primary-modern styles */
    padding: 10px 25px; /* Adjust padding for filter button */
    font-size: 0.95em;
    margin-top: 10px; /* Space from select boxes on wrap */
}


/* --- Ads Grid --- */
.ads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Default desktop view */
    gap: 25px;
    list-style: none;
    padding: 0;
}

.ad-card-item {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-card);
    overflow: hidden;
    box-shadow: 0 4px 15px var(--shadow-light);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    display: flex;
    flex-direction: column;
    height: 100%;
}
.ad-card-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 30px var(--shadow-medium);
}

.ad-card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.ad-image-container {
    width: 100%;
    padding-top: 75%; /* 4:3 aspect ratio */
    position: relative;
    overflow: hidden;
}
.ad-image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-speed);
}
.ad-card-item:hover .ad-image-container img {
    transform: scale(1.05); /* Slight zoom on hover */
}

.ad-content-wrapper {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.ad-title {
    font-size: 1.3em;
    margin-bottom: 8px;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ad-category, .ad-date {
    font-size: 0.9em;
    color: var(--text-light);
    margin-bottom: 5px;
    display: flex;
    align-items: center;
}
.ad-category i, .ad-date i {
    margin-right: 5px;
    color: var(--secondary-color);
}
.ad-description {
    font-size: 0.95em;
    color: var(--text-light);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* Limit to 3 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 10px;
}

.empty-state-message-grid {
    grid-column: 1 / -1; /* Span full width */
    text-align: center;
    padding: 40px;
    background-color: var(--bg-card);
    border-radius: var(--border-radius-card);
    box-shadow: 0 4px 15px var(--shadow-light);
    font-size: 1.1em;
    color: var(--text-light);
}

/* --- Responsive Adjustments --- */
@media (max-width: 992px) {
    .ads-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
    .ads-page-header .page-title {
        font-size: 2em;
    }
}

@media (max-width: 768px) {
    .ads-page-header {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    .ads-page-header .page-title {
        margin-top: 20px;
        margin-bottom: 0;
        font-size: 1.8em;
    }
    .back-home-btn {
        margin-right: 0;
    }
    .filter-sort-form {
        flex-direction: column;
        align-items: stretch;
    }
    .form-group-inline {
        min-width: unset; /* Remove min-width to allow full flexibility */
        width: 100%; /* Take full width */
    }
    .filter-sort-btn {
        width: 100%;
        margin-top: 20px;
    }
    .ads-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Maintain 2 columns for slightly larger mobiles */
    }
}

@media (max-width: 576px) {
    .ads-grid {
        grid-template-columns: 1fr 1fr; /* Two columns for mobile view */
        gap: 15px; /* Smaller gap for tighter layout */
    }
    .ad-card-item {
        max-width: unset; /* Remove max-width for grid item */
        margin-left: unset;
        margin-right: unset;
    }
    .ad-image-container {
        padding-top: 65%; /* Slightly wider aspect ratio for small screens if needed */
    }
    .ad-content-wrapper {
        padding: 15px; /* Smaller padding */
    }
    .ad-title {
        font-size: 1.1em; /* Smaller title font */
    }
    .ad-description {
        font-size: 0.85em; /* Smaller description font */
        -webkit-line-clamp: 2; /* Limit to 2 lines on small screens */
    }
    .ad-category, .ad-date {
        font-size: 0.8em;
    }
    .ads-page-header .page-title {
        font-size: 1.6em;
    }
}

/* Ensure existing main style.css variables are correctly applied or copied here */
/* For example, if you have a .container class in style.css, ensure it's compatible */