:root {
    --bg-cream: #FEF3E2;
    --accent-yellow: #FAB12F;
    --primary-orange: #FA812F;
    --highlight-red: #DD0303;
    --text-dark: #2D2D2D;
    --white: #ffffff;
    --gray-light: #f0f0f0;
    --text-gray: #666;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 12px 30px rgba(250, 129, 47, 0.2);
    --font-heading: 'Montserrat', sans-serif;
    --font-body: 'Open Sans', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--bg-cream);
    color: var(--text-dark);
    line-height: 1.6;
}

.page {
    max-width: 1400px;
    margin: 60px auto;
    padding: 0 5%;
}

/* TOP BAR */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 50px;
    flex-wrap: wrap;
    gap: 20px;
}

.filters-btn {
    display: none;
    background: var(--white);
    color: var(--text-dark);
    border: none;
    padding: 16px 28px;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: var(--shadow-soft);
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.filters-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    color: var(--primary-orange);
}

.search-box {
    flex: 1;
    max-width: 600px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 16px 24px 16px 56px;
    border: 2px solid transparent;
    border-radius: 50px;
    background: var(--white);
    font-size: 1.1rem;
    box-shadow: var(--shadow-soft);
    outline: none;
    transition: all 0.3s ease;
}

.search-box input:focus {
    box-shadow: var(--shadow-hover);
    border-color: rgba(250, 129, 47, 0.3);
}

body.dark-mode .search-box input {
    background: #333;
    color: white;
}

.search-box::before {
    content: "\f002";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3rem;
    color: var(--primary-orange);
}

/* SORT BUTTON */
.sort-wrapper {
    position: relative;
    z-index: 50;
}

.sort-btn {
    background: var(--white);
    color: var(--text-dark);
    border: none;
    padding: 16px 32px;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.sort-btn strong {
    color: var(--primary-orange);
}

.sort-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.sort-menu {
    position: absolute;
    top: 120%;
    right: 0;
    background: var(--white);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 12px 0;
    width: 200px;
    list-style: none;
    display: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.sort-menu.open {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.sort-menu li {
    padding: 14px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.sort-menu li:hover {
    background: rgba(250, 129, 47, 0.1);
    color: var(--primary-orange);
}

/* CONTENT LAYOUT */
.content {
    display: flex;
    gap: 50px;
}

/* FILTERS SIDEBAR */
aside.filters {
    width: 280px;
    flex-shrink: 0;
}

aside.filters h3 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 30px;
    background: linear-gradient(90deg, var(--primary-orange), var(--highlight-red));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.filter-group {
    margin-bottom: 35px;
}

.filter-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.05);
}

/* Scrollable Filter List */
.filter-list {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 5px;
}

/* Custom Scrollbar */
.filter-list::-webkit-scrollbar {
    width: 5px;
}

.filter-list::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 10px;
}

.filter-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-orange);
}

.filter-item {
    margin-bottom: 10px;
    position: relative;
    display: flex;
    align-items: center;
}

.filter-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.filter-item label {
    display: block;
    position: relative;
    padding-left: 32px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: color 0.3s ease;
    user-select: none;
    color: #555;
    line-height: 1.4;
}

.filter-item label::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: var(--white);
    transition: all 0.3s ease;
}

.filter-item input:checked~label::before {
    background: var(--primary-orange);
    border-color: var(--primary-orange);
}

.filter-item label::after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    left: 4px;
    top: 3px;
    font-size: 13px;
    color: white;
    opacity: 0;
    transition: all 0.2s ease;
    transform: scale(0.5);
}

.filter-item input:checked~label::after {
    opacity: 1;
    transform: scale(1);
}

.filter-item input:checked~label {
    color: var(--primary-orange);
    font-weight: 600;
}

/* Small Search Box for Ingredients */
.search-box-small {
    position: relative;
}

.search-box-small input {
    width: 100%;
    padding: 10px 15px;
    padding-left: 35px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.3s;
}

.search-box-small input:focus {
    border-color: var(--primary-orange);
}

.search-box-small::before {
    content: "\f002";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    color: #999;
}


/* RECIPE GRID */
main.recipes {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    align-content: start;
}

/* Loading & No Results */
.loading,
.error,
.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    font-size: 1.2rem;
    color: #777;
    background: white;
    border-radius: 20px;
    border: 2px dashed #eee;
}

.loading i {
    font-size: 2rem;
    color: var(--primary-orange);
    margin-bottom: 10px;
    display: block;
}

.no-results i {
    font-size: 3rem;
    color: #ddd;
    margin-bottom: 20px;
    display: block;
}

/* RECIPE CARD */
.recipe-card {
    background: transparent;
    /* Clean look usually implies no box around text or minimal */
    /* But the image provided shows cards with white background? */
    /* Let's keep it white with shadow but lighter. */
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    /* Clickable */
    height: 100%;
    /* Fill grid cell */
}

.recipe-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.1);
}

.recipe-image-wrapper {
    position: relative;
    padding-bottom: 65%;
    /* Slightly shorter than 4:3 to save space */
    width: 100%;
    overflow: hidden;
    background: #eee;
}

.recipe-image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.recipe-card:hover .recipe-image-wrapper img {
    transform: scale(1.05);
}

.recipe-info {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
    /* Pushes content to fill height */
    justify-content: space-between;
    /* Spacing */
}

.recipe-info h4 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
    /* Tight spacing like image */
    color: var(--text-dark);
    line-height: 1.4;

    /* Truncation (2 lines max) */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 3em;
    /* Fixed height for 2 lines roughly */
}



.category-overlay {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
    pointer-events: none;
    /* Let clicks pass through if needed */
}

/* Save / Heart Button */
.save-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    outline: none;
    z-index: 10;
    /* Ensure above image */
    color: #ccc;
    font-size: 1.1rem;
}

.save-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.save-btn.active {
    color: #ff4757;
    /* Red/Pink for love */
}

.save-btn i {
    transition: transform 0.2s;
}

.card-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #888;
    margin-top: auto;
    /* Push to bottom */
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.meta-item i {
    color: #aeaeae;
    /* Softer gray icon */
    font-size: 0.9rem;
}

.meta-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    color: var(--text-dark);
}

.meta-rating i {
    color: var(--accent-yellow);
    font-size: 0.9rem;
}

/* PAGINATION */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 60px 0;
}

/* Prev / Next Buttons */
.pag-btn {
    background: #FFF0E0;
    /* Light Peach */
    color: #CC7A20;
    /* Darker Orange/Brown text */
    border: none;
    padding: 10px 24px;
    border-radius: 50px;
    /* Fully rounded pill */
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    box-shadow: none;
    /* Flat look based on image */
}

.pag-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f8f8f8;
    color: #ccc;
}

.pag-btn:not(:disabled):hover {
    background: var(--primary-orange);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(250, 129, 47, 0.2);
}

/* Page Numbers Container */
.pag-numbers {
    background: #FFF0E0;
    /* Light Peach */
    padding: 8px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-num {
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    /* Rounded square */
    cursor: pointer;
    font-weight: 700;
    color: #CC7A20;
    transition: all 0.2s ease;
    background: transparent;
    font-size: 1rem;
}

.page-num:hover {
    color: var(--primary-orange);
}

.page-num.active {
    background: #DE8928;
    /* Strong Orange/Brown */
    color: white;
    box-shadow: 0 2px 8px rgba(222, 137, 40, 0.3);
}

.page-ellipsis {
    color: #CC7A20;
    font-weight: 900;
    letter-spacing: 2px;
}


/* MOBILE RESPONSIVE */
@media (max-width: 1200px) {
    main.recipes {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .content {
        flex-direction: column;
        gap: 0;
    }

    aside.filters {
        display: none;
        /* Hidden on mobile, use overlay */
    }

    .filters-btn {
        display: flex;
        /* Show toggle button */
    }

    main.recipes {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    main.recipes {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .top-bar {
        gap: 15px;
    }

    .search-box {
        order: 3;
        /* Move search below buttons on tiny screens */
        min-width: 100%;
    }
}

/* Mobile Filter Panel Styles */
.mobile-filter-panel {
    /* (Kept from original or style.css logic but ensured here) */
    position: fixed;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: var(--bg-cream);
    padding: 30px;
    z-index: 2000;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 5px 0 30px rgba(0, 0, 0, 0.2);
}

.mobile-filter-panel.open {
    transform: translateX(0);
}

.mobile-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.mobile-filter-header h3 {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.5rem;
}

.close-filters {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-dark);
}