/* ----------------------------
     Mobile Filter Modal Styling
---------------------------- */
@media (max-width: 991px) {
    #mobileFilterModal {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: 2000;
        background: rgba(255,255,255,0.98);
        overflow-y: auto;
        box-shadow: 0 0 40px rgba(7,117,25,0.10);
        animation: modalFadeIn 0.2s;
    }
}

#mobileFilterModal.active {
    display: block !important;
}
    #mobileFilterModal .container {
        background: #fff;
        border-radius: 18px;
        box-shadow: 0 2px 16px rgba(7,117,25,0.10);
        padding: 2rem 1rem 1rem 1rem;
        margin-top: 2.5rem;
        margin-bottom: 2.5rem;
        max-width: 500px;
    }
    #mobileFilterModal h5 {
        color: #077519;
        font-weight: 700;
        font-size: 1.3rem;
    }
    #mobileFilterModal label {
        color: #077519;
        font-weight: 500;
        margin-bottom: 0.3rem;
    }
    #mobileFilterModal .form-select {
        border-radius: 25px;
        border: 2px solid #077519;
        box-shadow: 0 2px 8px rgba(7,117,25,0.07);
        padding: 0.5rem 1rem;
        font-size: 1rem;
        background-color: #f8f9fa;
        color: #212529;
        margin-bottom: 1rem;
        transition: border-color 0.2s, box-shadow 0.2s;
    }
    #mobileFilterModal .form-select:focus {
        border-color: #055a15;
        box-shadow: 0 0 0 2px #eaf4ec;
        background-color: #fff;
        outline: none;
    }
    #mobileFilterModal .sources-group {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }
    #mobileFilterModal .source-pill {
        display: flex;
        align-items: center;
        gap: 0.3rem;
        padding: 0.4rem 0.9rem;
        border-radius: 999px;
        background-color: #fff;
        border: 1px solid #ccc;
        font-size: 0.9rem;
        cursor: pointer;
        box-shadow: 0 1px 2px rgba(0,0,0,0.05);
        transition: all 0.2s ease;
    }
    #mobileFilterModal .source-pill input[type="checkbox"] {
        accent-color: #006400;
    }
    #mobileFilterModal .source-pill:hover {
        background-color: #FFD700;
        color: #000;
        border-color: #e6b800;
    }
    #mobileFilterModal .source-pill:has(input:checked) {
        background-color: #077519;
        color: #fff;
        border-color: #055a15;
    }
    #mobileFilterModal .d-flex.gap-2 {
        position: sticky;
        bottom: 0;
        background: #fff;
        padding-bottom: 1rem;
        z-index: 10;
        margin-top: 2rem;
        box-shadow: 0 -2px 12px rgba(7,117,25,0.07);
    }
    #closeFiltersBtn {
        font-size: 2rem;
        line-height: 1;
        padding: 0 0.5rem;
        background: none;
        border: none;
        color: #d9534f;
        cursor: pointer;
        transition: color 0.2s;
    }
    #closeFiltersBtn:hover {
        color: #a94442;
    }

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
/* ----------------------------
   Results Container & Product Grid
/* Sticky Footer Layout */
html, body {
    height: 100%;
}
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
main {
    flex: 1;
}
.results-container {
    background-color: #fff;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    padding: 1.5rem 1rem;
    min-height: 400px;
}

#productGrid {
    row-gap: 2rem;   /* vertical spacing */
    column-gap: 1.5rem; /* horizontal spacing */
}

/* Product Card */
.card {
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
    border: none;
    transition: box-shadow 0.2s, transform 0.2s;
    overflow: hidden;
    background: #fff;
}
.card:hover {
    box-shadow: 0 8px 24px rgba(7,117,25,0.12);
    transform: translateY(-4px) scale(1.02);
}
.card-img-top {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}
.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.card .price-badge {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}
.card .source-badge {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}
.card .btn-success {
    border-radius: 25px;
    font-weight: 600;
    letter-spacing: 0.5px;
    background: linear-gradient(90deg, #077519 80%, #FFD700 100%);
    border: none;
    transition: background 0.2s, box-shadow 0.2s;
}
.card .btn-success:hover {
    background: linear-gradient(90deg, #055a15 80%, #FFD700 100%);
    box-shadow: 0 4px 12px rgba(7,117,25,0.18);
}

/* Responsive Product Grid */
@media (max-width: 991px) {
    #productGrid {
        gap: 1.2rem;
    }
    .card-img-top {
        height: 140px;
    }
}
@media (max-width: 576px) {
    #productGrid {
        flex-direction: column;
        gap: 1rem;
    }
    .card-img-top {
        height: 100px;
    }
}
/* ----------------------------
   Hero Banner
---------------------------- */
.hero-banner {
    background: linear-gradient(90deg, #f4f5f7 60%, #eaf4ec 100%);
    border-radius: 18px;
    box-shadow: 0 2px 12px rgba(7,117,25,0.07);
    padding: 2.5rem 2rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}
.hero-banner h1 {
    font-size: 2.2rem;
    color: #077519;
    margin-bottom: 1rem;
}
.hero-banner p {
    font-size: 1.2rem;
    color: #212529;
    margin-bottom: 1.5rem;
}
.hero-banner img {
    max-height: 180px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
@media (max-width: 991px) {
    .hero-banner {
        flex-direction: column;
        text-align: center;
        padding: 2rem 1rem;
    }
    .hero-banner img {
        max-height: 120px;
    }
}

header input#titleSearch {
    border-radius: 25px;
    padding: 0.5rem 1rem;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    border: 1px solid #ddd;
    width: 100%;
    max-width: 600px;
}

/* ----------------------------
   Sidebar Filters
---------------------------- */
.sidebar label {
    font-weight: 500;
    color: #077519;
    margin-bottom: 0.3rem;
}
.sidebar .form-select {
    border-radius: 25px;
    border: 2px solid #077519;
    box-shadow: 0 2px 8px rgba(7,117,25,0.07);
    padding: 0.5rem 1rem;
    font-size: 1rem;
    background-color: #f8f9fa;
    color: #212529;
    margin-bottom: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.sidebar .form-select:focus {
    border-color: #055a15;
    box-shadow: 0 0 0 2px #eaf4ec;
    background-color: #fff;
    outline: none;
}
.sidebar .form-select:hover {
    border-color: #055a15;
}
/* Remove default arrow and use custom */
.sidebar .form-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23077519" height="20" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"><path d="M7.293 7.293a1 1 0 011.414 0L10 8.586l1.293-1.293a1 1 0 111.414 1.414l-2 2a1 1 0 01-1.414 0l-2-2a1 1 0 010-1.414z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2em;
}
header {
    background-color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}
header nav a {
    font-weight: 500;
    color: #212529;
    text-decoration: none;
    margin: 0 0.5rem;
    transition: color 0.2s;
}
header nav a:hover {
    color: #077519;
}

/* Desktop search form styling */
header .search-form {
    width: 350px;
    max-width: 350px;
}

header input#titleSearch {
    border-radius: 25px;
    padding: 0.5rem 1rem;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    border: 1px solid #ddd;
    width: 100%;
    max-width: 350px;
}
header form .btn-primary {
    border-radius: 25px;
    font-weight: 600;
    padding: 0.5rem 1.2rem;
    margin-left: 0.5rem;
}
.sources-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.source-pill {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    background-color: #fff;
    border: 1px solid #ccc;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

.source-pill input[type="checkbox"] {
    accent-color: #006400;
}

.source-pill:hover {
    background-color: #FFD700;
    color: #000;
    border-color: #e6b800;
}

.source-pill:has(input:checked) {
    background-color: #077519;
    color: #fff;
    border-color: #055a15;
}

/* ----------------------------
   Buttons
---------------------------- */
/* Primary (green) buttons for other actions */
.btn-primary {
    background-color: #077519;
    border-color: #077519;
    transition: all 0.2s;
    border-radius: 25px;
    padding: 0.5rem 1rem;
}
.btn-primary:hover {
    background-color: #055a15;
    border-color: #055a15;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(7,117,25,0.3);
}

/* Success (green) buttons for pagination */
.btn-success {
    background-color: #077519;
    border-color: #077519;
    color: #fff;
    transition: all 0.2s;
    border-radius: 25px;
    padding: 0.5rem 1rem;
}
.btn-success:hover {
    background-color: #055a15;
    border-color: #055a15;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(7,117,25,0.3);
}
.btn-outline-success {
    background-color: #fff;
    border-color: #077519;
    color: #077519;
    border-radius: 25px;
    padding: 0.5rem 1rem;
    transition: all 0.2s;
}
.btn-outline-success:hover {
    background-color: #eaf4ec;
    color: #055a15;
    border-color: #055a15;
}

/* ----------------------------
   Results Table
---------------------------- */
.results-container {
    background-color: #fff;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    padding: 1rem;
}

#resultsTable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.5rem;
}

#resultsTable th,
#resultsTable td {
    padding: 12px 15px;
}

#resultsTable th {
    background-color: #f1f3f5;
    font-weight: 600;
}

#resultsTable tbody tr {
    background-color: #fafafa;
    border-radius: 10px;
    transition: background-color 0.3s;
}

#resultsTable tbody tr:hover {
    background-color: #eaf4ec;
}

/* Price badge */
.price-badge {
    display: inline-block;
    background-color: #FFD700;
    color: #212529;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 50px;
    transition: all 0.2s ease;
    cursor: pointer;
}
.price-badge:hover {
    box-shadow: 0 5px 15px rgba(230,172,0,0.4);
}

/* Source badge */
.source-badge {
    display: inline-block;
    background-color: #077519;
    color: #fff;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 50px;
    transition: all 0.2s ease;
}
.source-badge:hover {
    box-shadow: 0 5px 15px rgba(7,117,25,0.4);
}

/* ----------------------------
   Spinner
---------------------------- */
.spinner-border {
    width: 3rem;
    height: 3rem;
    color: #077519;
}

/* ----------------------------
   Mobile / Responsive
---------------------------- */
@media (max-width: 991px) {
    #productGrid {
        gap: 1.2rem;
    }
    .card-img-top {
        height: 140px;
    }
    .hero-banner {
        flex-direction: column;
        text-align: center;
        padding: 2rem 1rem;
    }
    .hero-banner img {
        max-height: 120px;
    }
}

/* Tablet screens - improve search form */
@media (max-width: 991px) and (min-width: 769px) {
    header .search-form {
        width: 280px;
        max-width: 280px;
    }
    header input#titleSearch {
        max-width: 280px;
    }
}

/* Mobile-first responsive design */
@media (max-width: 768px) {
    /* Header layout improvements */
    header .container {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem 0.5rem;
        gap: 1rem;
    }
    
    /* Logo section */
    header .container > a {
        align-self: center;
        margin-bottom: 0.5rem;
    }
    
    /* Navigation */
    header nav {
        order: 2;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem 1rem;
        margin: 0;
    }
    header nav a {
        font-size: 0.9rem;
        padding: 0.3rem 0.6rem;
        border-radius: 15px;
        transition: all 0.2s;
    }
    header nav a:hover {
        background-color: #f8f9fa;
    }
    
    /* Search form - prioritize and make prominent */
    header form {
        order: 1;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        display: flex !important;
        gap: 0.75rem;
    }
    header input#titleSearch {
        flex: 1;
        min-height: 44px; /* Better touch target */
        font-size: 16px !important; /* Prevent zoom on iOS */
        padding: 0.75rem 1rem !important;
        border-radius: 22px;
        border: 2px solid #077519;
    }
    header form .btn-primary {
        min-width: 80px;
        min-height: 44px;
        padding: 0.75rem 1.2rem;
        font-size: 14px;
        font-weight: 600;
        border-radius: 22px;
        flex-shrink: 0;
    }
}

@media (max-width: 576px) {
    /* Hero Banner */
    .hero-banner {
        flex-direction: column;
        text-align: center;
        padding: 1rem 0.5rem;
        gap: 0.8rem;
    }
    .hero-banner h1 {
        font-size: 1.5rem;
        line-height: 1.3;
        margin-bottom: 0.5rem;
    }
    .hero-banner p {
        font-size: 1rem;
        line-height: 1.4;
        margin-bottom: 0.8rem;
    }
    .hero-banner img {
        max-width: 60%;
        max-height: 120px;
        margin: 0 auto;
    }
    .hero-banner .btn {
        width: 90%;
        font-size: 1rem;
        padding: 0.6rem 0;
        margin-bottom: 0.5rem;
    }

    /* Product Grid & Cards */
    #productGrid {
        flex-direction: column;
        gap: 1rem;
    }
    .card-img-top {
        height: 120px;
    }
    .card-title {
        font-size: 1rem;
    }
    .card .price-badge {
        font-size: 0.95rem;
    }
    .card .btn-success {
        font-size: 0.95rem;
        padding: 0.5rem 0.8rem;
    }

    /* Further mobile refinements for very small screens */
    header input#titleSearch {
        font-size: 16px !important; /* Prevent zoom */
        min-height: 48px; /* Even better touch target */
        padding: 0.8rem 1rem !important;
    }
    header form .btn-primary {
        min-height: 48px;
        min-width: 70px;
        font-size: 13px;
        padding: 0.8rem 1rem;
    }
    
    /* Stack search button below input on very small screens */
    header form {
        flex-direction: column;
        gap: 0.5rem;
    }
    header form .btn-primary {
        width: 100%;
        min-width: unset;
    }

    /* Sidebar */
    .sidebar {
        order: -1;
        width: 100%;
    }
}

/* ----------------------------
     Active Filters Display Styling
---------------------------- */
#activeFiltersSection {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid #e9ecef;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    background: #077519;
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
}

.filter-tag .remove-filter {
    background: rgba(255,255,255,0.3);
    border: none;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    margin-left: 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.filter-tag .remove-filter:hover {
    background: rgba(255,255,255,0.5);
}

#clearAllFilters {
    border-radius: 20px;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
}

#clearAllFilters:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}