/* General Styling */
:root {
    /* Light Mode (Default) */
    --color-bg: #f4f7f6;
    --color-text: #333;
    --color-card-bg: #ffffff;
    --color-primary: #2a9d8f;
    --color-shadow: rgba(0, 0, 0, 0.05);
}

body.dark-mode {
    /* Dark Mode */
    --color-bg: #1a1a1a;
    --color-text: #f0f0f0;
    --color-card-bg: #2b2b2b;
    --color-primary: #2a9d8f;
    /* Can stay the same or change */
    --color-shadow: rgba(0, 0, 0, 0.2);
    --color-text-secondary: #aaa;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--color-bg);
    margin: 0;
    padding: 20px;
    color: var(--color-text);
    min-height: 100vh;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: var(--color-primary);
    margin-bottom: 5px;
}

/* Search Form */
#search-form {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

/* NEW CSS FOR FILTER DROPDOWNS */
#filter-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    /* Adds space between the dropdowns */
    margin-bottom: 30px;
    flex-wrap: wrap;
    /* Allows filters to wrap on small screens */
}

#filter-container select {
    padding: 8px 12px;
    font-size: 15px;
    border: 2px solid var(--color-shadow);
    border-radius: 8px;
    background-color: var(--color-card-bg);
    color: var(--color-text);
    outline: none;
}

/* END NEW CSS FOR FILTER DROPDOWNS */

#search-input {
    width: 60%;
    background-color: var(--color-card-bg);
    color: var(--color-text);
    max-width: 400px;
    padding: 12px 15px;
    font-size: 16px;
    border: 2px solid var(--color-shadow);
    border-radius: 8px 0 0 8px;
    outline: none;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: #2a9d8f;
}

#search-form button {
    padding: 12px 20px;
    font-size: 16px;
    background-color: #2a9d8f;
    color: white;
    border: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    transition: background-color 0.2s;
}

#search-form button:hover {
    background-color: #264653;
}

/* Results Container & Recipe Cards */
#results-container {
    display: grid;
    /* This is the magic for a responsive grid:
       It creates columns that are at least 300px wide.
       'auto-fit' tells it to fill the space with as many columns as fit.
       '1fr' means each column shares the remaining space equally. */
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    padding: 10px;
}

.recipe-card {
    background-color: var(--color-card-bg);
    border-radius: 10px;
    box-shadow: 0 4px 12px var(--color-shadow);
    overflow: hidden;
    /* Clips the image inside the border radius */
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    /* Stacks card content vertically */
}

.recipe-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px var(--color-shadow);
}

.recipe-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    /* Prevents image from stretching */
}

.recipe-card-content {
    padding: 20px;
    flex-grow: 1;
    /* Makes this section fill the remaining card space */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* Pushes the button to the bottom */
}

/*  ADD THIS NEW BLOCK  */
.recipe-card-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--color-text-secondary, #777);
    /* This will be too light in dark mode, we'll fix it */
    margin-bottom: 15px;
}

.recipe-card-info span {
    font-weight: 500;
}

/*  END NEW BLOCK  */

.recipe-card h2 {
    font-size: 1.25rem;
    margin-top: 0;
    margin-bottom: 15px;
}

.recipe-card a {
    text-decoration: none;
    color: #ffffff;
    background-color: #e76f51;
    padding: 8px 12px;
    border-radius: 5px;
    display: inline-block;
    font-weight: 500;
    text-align: center;
    transition: background-color 0.2s;
}

.recipe-card a:hover {
    background-color: #f4a261;
}

/*  ADD THIS NEW BLOCK  */
.recipe-card-buttons {
    display: flex;
    gap: 10px;
    /* Space between groups */
}

.recipe-card-buttons-row {
    display: flex;
    gap: 10px;
}

.recipe-card-buttons-row a,
.recipe-card-buttons-row button {
    flex-grow: 1;
    /* Make them share the space */
    text-align: center;
}

/* Message for empty favorites page */
#favorites-container p {
    text-align: center;
    font-size: 1.2rem;
    color: var(--color-text);
}

/*  END OF NEW BLOCK  */

/* Helper classes for loading/errors */
#loading-message {
    text-align: center;
    font-size: 1.2rem;
    color: var(--color-text);
    padding: 30px;
}

.hidden {
    display: none;
}

/*  MODAL STYLES  */

.modal-overlay {
    position: fixed;
    /* Sits on top of all content */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    /* Start hidden */
    pointer-events: none;
    /* Can't click it */
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
    /* Clickable */
}

.modal {
    background: var(--color-card-bg);
    color: var(--color-text);
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    /* Max height */
    overflow-y: auto;
    /* Scrollable if content is too tall */
    position: relative;
    transform: scale(0.9);
    /* Start slightly small */
    transition: transform 0.3s ease;
}

.modal-overlay.visible .modal {
    transform: scale(1);
    /* Grow to full size */
}

.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    font-weight: bold;
    background: none;
    border: none;
    color: var(--color-text);
    cursor: pointer;
}

.modal h2 {
    margin-top: 0;
    color: var(--color-primary);
}

.modal-ingredients li {
    line-height: 1.6;
    margin-bottom: 8px;
}

/*  END OF MODAL STYLES  */

/* Style for nav links in the header */
.nav-link {
    display: block;
    margin-top: 15px;
    font-weight: 500;
    color: var(--color-primary);
    text-decoration: none;
    font-size: 1.1rem;
}

.nav-link:hover {
    text-decoration: underline;
}

/* New button styles */
.save-btn,
.remove-btn {
    padding: 8px 12px;
    font-size: 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: #6c757d;
    /* A neutral gray */
    color: white;
    font-weight: 500;
    width: 100%;
    /* Make it fill the space */
}

.save-btn:hover,
.remove-btn:hover {
    background-color: #5a6268;
}

/* Style for the "Saved" state */
.save-btn.saved {
    background-color: #28a745;
    /* Green */
}

/* This part is important! We need to update the
  .recipe-card-buttons class you added before
  to stack the new "Save" button.
*/