/* Google Font Import: Ubuntu */
@import url('https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;700&display=swap');

/* coupons.css - Specific styles for free-coupons.html */

/* General Body and Main Container Styles */
/* These are basic styles. If you have more comprehensive body styles in style.css,
   ensure these don't conflict or remove them if style.css is the primary for body. */
body {
    font-family: 'Ubuntu', sans-serif;
    margin: 0;
    background-color: #f0f2f5;
    color: #333;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.dark-mode {
    background-color: #2c2c2c;
    color: #f0f0f0;
}

/* This .wide-container defines the overall maximum width for the main content area */
.wide-container {
    max-width: 1200px; /* Consistently define the max content width here */
    width: 100%;
    margin: 20px auto;
    padding: 30px;
    background-color: #fff;
    border-radius: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
    box-sizing: border-box;
    flex-grow: 1; /* Allows container to grow and push footer down */
}

body.dark-mode .wide-container {
    background-color: #3a3a3a;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.title {
    color: #007bff;
    margin-bottom: 10px;
    font-size: 2.2em;
}

body.dark-mode .title {
    color: #64b5f6;
}

.input-help-text {
    color: #666;
    margin-bottom: 25px;
    font-size: 1.1em;
}

body.dark-mode .input-help-text {
    color: #bbb;
}

/* --- Coupon Grid Container Base Styles (Mobile First) --- */
/* This is the default for smaller screens (e.g., single column) */
.coupon-grid {
    display: grid;
    grid-template-columns: 1fr; /* Default: 1 column for very small screens */
    gap: 20px; /* Space between grid items */
    margin-top: 30px;
    margin-bottom: 30px;
    justify-content: center; /* Center items within the grid */
    align-items: stretch;     /* Ensures all items in a row have the same height */
    grid-auto-rows: minmax(auto, 1fr); /* Auto-adjust row height based on content */
    padding: 0 15px;          /* Padding inside the grid container */
    max-width: 100%;          /* Ensure it respects parent's width */
    box-sizing: border-box;
}

/* Basic styling for all coupon items */
.coupon-item {
    border: 1px solid #ddd;
    border-radius: 0px;
    padding: 15px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    box-sizing: border-box;
    height: 100%; /* Make sure the item itself fills the grid cell's height */
	position: relative; /*  Corrects the error of the "FEATURED" label is appearing at the top right of your webpage instead of staying within its respective paid ad coupon   */

    /* Default column span: 1. This is applied via inline style for wider ads via JS. */
    grid-column: span var(--column-span, 1);
}

.coupon-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Dark mode adjustments for coupon items */
body.dark-mode .coupon-item {
    background-color: #333;
    border-color: #555;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

body.dark-mode .coupon-item h4 {
    color: #64b5f6;
}

body.dark-mode .coupon-item p,
body.dark-mode .coupon-item .coupon-info {
    color: #e0e0e0;
}

body.dark-mode .coupon-item .coupon-offer {
    color: #90ee90;
}

body.dark-mode .coupon-link-button {
    background-color: #64b5f6;
    color: #333;
    border-color: #64b5f6;
}
body.dark-mode .coupon-link-button:hover {
    background-color: #4da6f5;
}

/* --- Coupon Item Inner Content Styles --- */

.coupon-item h4 {
    color: #007bff;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.3em;
}

.coupon-item p {
    font-size: 0.95em;
    color: #555;
    line-height: 1.5;
    margin-bottom: 10px;
    flex-grow: 1; /* Allows description to take available space */
}

.coupon-item .coupon-offer {
    font-weight: bold;
    color: #28a745;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.coupon-item .coupon-info {
    font-size: 0.85em;
    color: #777;
    margin-bottom: 15px; /* Space before the button */
}

/* Styles for the "Clip Coupon Now!" button within a coupon item */
.coupon-link-button {
    display: block;
    width: 100%;
    padding: 10px 15px;
    margin-top: 15px;
    background-color: #007bff;
    color: white;
    text-align: center;
    border: none;
    border-radius: 0px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s ease;
    flex-shrink: 0; /* Prevent button from shrinking */
    text-decoration: none;
}

.coupon-link-button:hover {
    background-color: #0056b3;
}

/* Lightbox styles */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.visible {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 0px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
    position: relative;
    text-align: center;
    box-sizing: border-box;
}

body.dark-mode .lightbox-content {
    background-color: #3a3a3a;
    color: #f0f0f0;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.6);
}

.lightbox-content h3 {
    color: #007bff;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 2em;
}
body.dark-mode .lightbox-content h3 {
    color: #64b5f6;
}

.close-button {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.8em;
    cursor: pointer;
    color: #666;
    transition: color 0.2s ease;
}

.close-button:hover {
    color: #333;
}
body.dark-mode .close-button {
    color: #ccc;
}
body.dark-mode .close-button:hover {
    color: #eee;
}

/* Styles for search input and button */
.search-section {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}
.search-section input[type="text"] {
    padding: 12px 18px;
    border: 1px solid #ccc;
    border-radius: 0px;
    font-size: 1.1em;
    width: 300px;
    max-width: 80%;
    transition: border-color 0.3s ease;
}
.search-section input[type="text"]:focus {
    border-color: #007bff;
    outline: none;
}
.search-section button {
    padding: 12px 25px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 0px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}
.search-section button:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

body.dark-mode .search-section input[type="text"] {
    background-color: #4a4a4a;
    color: #f0f0f0;
    border: 1px solid #555;
}
body.dark-mode .search-section input[type="text"]:focus {
    border-color: #64b5f6;
}
body.dark-mode .search-section button {
    background-color: #555;
    color: #f0f0f0;
    border: 1px solid #666;
}
body.dark-mode .search-section button:hover {
    background-color: #666;
}

/* Styles for individual coupon lightbox */
#singleCouponLightbox .lightbox-content {
    max-width: 500px; /* Smaller for single coupon */
}
#singleCouponAdvertiserLink {
    margin-top: 20px;
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    border-radius: 0px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.3s ease;
    display: inline-block;
    margin-bottom: 15px;
}
#singleCouponAdvertiserLink:hover {
    background-color: #0056b3;
}

#saveCouponBtn {
    background-color: #6c757d; /* Grey for save button */
    color: white;
    padding: 10px 20px;
    border-radius: 0px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s ease;
}
#saveCouponBtn:hover {
    background-color: #5a6268;
}

body.dark-mode #singleCouponAdvertiserLink {
    background-color: #64b5f6;
}
body.dark-mode #singleCouponAdvertiserLink:hover {
    background-color: #4da6f5;
}
body.dark-mode #saveCouponBtn {
    background-color: #777;
}
body.dark-mode #saveCouponBtn:hover {
    background-color: #888;
}

/* No search results message */
#noResultsMessage {
    font-size: 1.2em;
    color: #e74c3c;
    margin-top: 20px;
}
body.dark-mode #noResultsMessage {
    color: #ff8a80;
}
/* Utility Class for Hiding Elements */
.hidden {
    display: none !important;
}

/*
--- RESPONSIVE ADJUSTMENTS ---
Consolidated and ordered media queries to prevent conflicts and ensure consistent layout.
Mobile-first approach is maintained.
*/

/* Very small mobile devices (<480px) */
@media (max-width: 479px) {
    .wide-container {
        padding: 15px;
    }
    .title {
        font-size: 1.8em;
    }
    .input-help-text {
        font-size: 1em;
    }
    .coupon-item {
        padding: 12px;
    }
    .coupon-item h4 {
        font-size: 1.1em;
    }
    .coupon-item p {
        font-size: 0.9em;
    }
    .coupon-item .coupon-link-button {
        padding: 8px 12px;
        font-size: 0.9em;
    }
    .category-button {
        padding: 6px 12px;
        font-size: 0.85em;
    }
    .lightbox-content {
        padding: 20px;
    }
    .lightbox-content h3 {
        font-size: 1.6em;
    }
    #singleCouponOffer {
        font-size: 1.3em;
    }
    .search-controls {
        flex-direction: column;
        align-items: center;
    }
    .search-controls input[type="text"],
    .search-controls button {
        width: 100%;
        max-width: 300px;
    }
}

/* Medium mobile devices / small tablets (480px to 767px) - 2 columns */
@media (min-width: 480px) and (max-width: 767px) {
    .coupon-grid {
        grid-template-columns: repeat(2, 1fr); /* Force 2 equal columns */
    }
    .coupon-item.span-2-columns,
    .coupon-item.span-3-columns,
    .coupon-item.span-4-columns {
        grid-column: span 2; /* Clamp larger spans to 2 columns */
    }
    .wide-container {
        padding: 20px;
    }
}

/* Larger tablets / small laptops (768px to 991px) - 3 columns */
@media (min-width: 768px) and (max-width: 991px) {
    .coupon-grid {
        grid-template-columns: repeat(3, 1fr); /* Force 3 equal columns */
    }
    .coupon-item.span-2-columns {
        grid-column: span 2;
    }
    .coupon-item.span-3-columns,
    .coupon-item.span-4-columns {
        grid-column: span 3; /* Clamp larger spans to 3 columns */
    }
    .wide-container {
        padding: 25px;
    }
}

/* Desktops (992px and up) - 4 columns */
@media (min-width: 992px) {
    .coupon-grid {
        grid-template-columns: repeat(4, 1fr); /* Force exactly 4 equal columns */
        max-width: 100%; /* Important: Allows grid to fill .wide-container's width */
        margin-left: auto;
        margin-right: auto;
        justify-content: center;
    }
    /* Column Span Classes for Desktop (only apply when 4 columns are active) */
    .coupon-item.span-2-columns {
        grid-column: span 2;
    }
    .coupon-item.span-3-columns {
        grid-column: span 3;
    }
    .coupon-item.span-4-columns {
        grid-column: span 4;
    }
}

/* --- Specific Styles for free-coupons.html Content Sections --- */

/* Wrapper for Search and Categories */
.search-and-categories-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 1200px; /* Aligns with wide-container's max-width */
}

/* This media query ensures the wrapper elements stack on smaller screens */
@media (max-width: 1024px) {
    .search-and-categories-wrapper {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    .search-and-categories-wrapper .search-section,
    .categories-section {
        flex: 1 1 100%;
        max-width: 600px;
    }
}

/* Adjustments for the Search Section */
.search-section {
    flex: 1 1 45%;
    max-width: 500px;
    margin-bottom: 0;
    padding: 20px;
    background-color: #fff;
    border-radius: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    text-align: center;
}

body.dark-mode .search-section {
    background-color: #3a3a3a;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.search-section h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
}

body.dark-mode .search-section h2 {
    color: #f0f0f0;
}

/* Control positioning of search input and button */
.search-controls {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    box-sizing: border-box;
}

.search-controls input[type="text"] {
    flex-grow: 1;
    min-width: 150px;
    padding: 12px 18px;
    border: 1px solid #ccc;
    border-radius: 0;
    font-size: 1.1em;
    transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

.search-controls input[type="text"]:focus {
    border-color: #007bff;
    outline: none;
}

body.dark-mode .search-controls input[type="text"] {
    background-color: #4a4a4a;
    color: #f0f0f0;
    border: 1px solid #555;
}
body.dark-mode .search-controls input[type="text"]:focus {
    border-color: #64b5f6;
}

.search-controls button {
    padding: 12px 25px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 0;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.search-controls button:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

body.dark-mode #searchCouponsBtn {
    background-color: #64b5f6;
    color: #fff;
    border-color: #64b5f6;
}
body.dark-mode #searchCouponsBtn:hover {
    background-color: #4da6f5;
}

/* Categories Section Styles */
.categories-section {
    flex: 1 1 45%;
    max-width: 500px;
    padding: 20px;
    background-color: #fff;
    border-radius: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    text-align: center;
}

body.dark-mode .categories-section {
    background-color: #3a3a3a;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.category-heading {
    font-size: 1.2em;
    color: #333;
    margin-top: 0;
    margin-bottom: 15px;
    font-weight: 600;
}

body.dark-mode .category-heading {
    color: #f0f0f0;
}

.category-buttons-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.category-button {
    padding: 8px 15px;
    background-color: #e0e0e0;
    color: #555;
    border: 1px solid black;
    border-radius: 0;
    font-size: 0.9em;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
    white-space: nowrap;
}

.category-button:hover {
    background-color: #d0d0d0;
    color: #333;
    transform: translateY(-1px);
}

.category-button.active {
    background-color: #007bff;
    color: white;
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.3);
}

.category-button.active:hover {
    background-color: #0056b3;
}

body.dark-mode .category-button {
    background-color: #555;
    color: #eee;
}

body.dark-mode .category-button:hover {
    background-color: #666;
}

body.dark-mode .category-button.active {
    background-color: #64b5f6;
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.4);
}

body.dark-mode .category-button.active:hover {
    background-color: #4da6f5;
}

/* Section for the main coupon display grid */
.coupon-grid-section {
    background-color: #fff;
    padding: 25px 30px;
    border-radius: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    text-align: center;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

body.dark-mode .coupon-grid-section {
    background-color: #3a3a3a;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.coupon-grid-section h3 {
    color: #007bff;
    margin-top: 0;
    margin-bottom: 25px;
    font-size: 2em;
}

body.dark-mode .coupon-grid-section h3 {
    color: #64b5f6;
}

.no-category-results, .no-search-results {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 0;
    margin-top: 20px;
}

body.dark-mode .no-category-results, body.dark-mode .no-search-results {
    background-color: #444;
    color: #ccc;
}
/* Specific styles for paid ad coupons */
.coupon-item.coupon-paid-ad {
    background-color: #e6f0f5; /* Light blue-gray background */
    border: 3px solid #c8dbe6; /* Slightly darker blue-gray border */
    /* box-shadow: 0 4px 8px rgba(100, 181, 246, 0.2); /* Subtle blue-gray shadow */
}

body.dark-mode .coupon-item.coupon-paid-ad {
    background-color: #454d52; /* Darker, desaturated blue-gray for dark mode */
    border-color: #6a747c;
    /* box-shadow: 0 4px 12px rgba(100, 181, 246, 0.2);/* Subtle blue-gray shadow */
}

/* Optional: You can add a small "AD" label if desired */
.coupon-item.coupon-paid-ad::before {
    content: "FEATURED";
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: #90a4ae; /* Muted blue-gray background for "AD" label */
    color: #fff; /* White text for contrast */
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7em;
    font-weight: bold;
    z-index: 10; /* Ensure it's above other content */
}

body.dark-mode .coupon-item.coupon-paid-ad::before {
    background-color: #78909c; /* Darker muted blue-gray for dark mode "AD" */
    color: #eee;
}