:root {
    --primary-color: #ff6b6b;
    --secondary-color: #4ecdc4;
    --dark: #2c3e50;
    --light: #f7f7f7;
    --white: #ffffff;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 5px 20px rgba(0, 0, 0, 0.15);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Poppins', sans-serif;
    line-height: 1.6;
    color: var(--dark);
    background-color: var(--light);
}

/* Prevent scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header & Navigation */
.navbar {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
}

.nav-brand h1 {
    color: var(--primary-color);
    font-size: 2rem;
    font-weight: 700;
}

.tagline {
    color: var(--dark);
    font-size: 0.9rem;
    font-weight: 300;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    background: transparent;
    border: none;
    cursor: pointer;
}

.nav-toggle span {
    width: 25px;
    height: 3px;
    background: var(--dark);
    margin: 3px 0;
    transition: var(--transition);
}

.nav-links {
    display: flex;
    display: none;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    color: var(--dark);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.nav-links a:hover {
    color: var(--primary-color);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    padding: 4rem 0;
    text-align: center;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.2rem;
    font-weight: 300;
    margin-bottom: 2rem;
}

.search-box {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    gap: 1rem;
}

#searchInput {
    flex: 1;
    padding: 1rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
}

#searchBtn {
    padding: 1rem 2rem;
    background: var(--dark);
    color: var(--white);
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

#searchBtn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* Filters */
.filters {
    position: sticky;
    top: 0;
    z-index: 900;
    padding: 2rem 0;
    background: var(--white);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: padding 0.3s ease;
}

.filters.compact {
    padding: 1rem 0;
}

.filter-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    transition: gap 0.3s ease;
}

.filters.compact .filter-buttons {
    gap: 0.5rem;
}

.filters.compact .filter-btn {
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
}

/* Recipe Counter in navbar */
.navbar .recipe-counter {
    color: var(--dark);
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    background: var(--light);
    border-radius: 25px;
    white-space: nowrap;
}

.navbar .recipe-counter strong {
    color: var(--primary-color);
    font-weight: 600;
}

.filter-btn {
    padding: 0.7rem 1.5rem;
    background: var(--white);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 25px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--primary-color);
    color: var(--white);
}

/* Recipes Grid */
.recipes {
    padding: 3rem 0;
    min-height: 60vh;
}

.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    align-items: stretch;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

.recipe-card {
    background: var(--white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.recipe-image-wrapper {
    width: 100%;
    height: 200px;
    position: relative;
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    overflow: hidden;
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.recipe-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.recipe-image.loaded {
    opacity: 1;
}

.recipe-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.recipe-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--dark);
    height: 3.6rem;
    line-height: 1.5;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    -webkit-box-pack: end;
}

.recipe-description {
    color: #666;
    margin-bottom: 0.8rem;
    line-height: 1.4;
    font-size: 0.9rem;
    flex: 1;
    min-height: 2.8em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.recipe-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem;
    font-size: 0.85rem;
    margin-top: auto;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.recipe-time,
.recipe-difficulty,
.recipe-servings {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    color: #888;
    font-size: 0.8rem;
}

.recipe-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.7rem;
    padding-top: 0.2rem;
}

.tag {
    padding: 0.15rem 0.5rem;
    background: var(--light);
    color: var(--dark);
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.2;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal.show {
    display: block;
}

.modal-content {
    background-color: var(--white);
    margin: 2vh auto;
    padding: 0;
    width: 95%;
    max-width: 1000px;
    max-height: 96vh;
    border-radius: var(--border-radius);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-close {
    position: fixed;
    right: calc(50% - 500px + 20px);
    top: calc(1vh + 20px);
    z-index: 2001;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: var(--white);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.modal-close:hover {
    color: var(--dark);
    background: var(--light);
}

#modalBody {
    padding: 0;
    overflow-y: auto;
    max-height: 98vh;
    scroll-behavior: smooth;
    position: relative;
}

/* Sticky recipe title header */
.modal-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--white);
    padding: 1.5rem 2rem 1rem;
    border-bottom: 2px solid var(--light);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.modal-header h2 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.8rem;
}

.modal-content-wrapper {
    padding: 2rem;
}

/* Custom Scrollbar */
#modalBody::-webkit-scrollbar {
    width: 8px;
}

#modalBody::-webkit-scrollbar-track {
    background: var(--light);
    border-radius: 4px;
}

#modalBody::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

#modalBody::-webkit-scrollbar-thumb:hover {
    background: #ff4444;
}

.recipe-detail-header {
    text-align: center;
    margin-bottom: 2rem;
}

.recipe-detail-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.recipe-detail-title {
    font-size: 2rem;
    color: var(--dark);
    margin-bottom: 1rem;
}

.recipe-detail-meta {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.ingredients-section,
.instructions-section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.ingredients-list {
    list-style: none;
    padding: 0;
}

.ingredient-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--light);
    display: flex;
    justify-content: space-between;
}

.instructions-list {
    list-style: none;
    counter-reset: step-counter;
}

.instruction-step {
    position: relative;
    padding-left: 3rem;
    margin-bottom: 1.5rem;
    counter-increment: step-counter;
}

.instruction-step::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 2rem;
    height: 2rem;
    background: var(--primary-color);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.tips-section {
    background: var(--light);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-top: 2rem;
}

.tips-list {
    list-style: none;
    padding: 0;
}

.tips-list li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.tips-list li::before {
    content: "💡";
    position: absolute;
    left: 0;
}

/* Nutrition Section */
.nutrition-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--light);
}

.nutrition-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.nutrition-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    text-align: center;
    color: var(--white);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.nutrition-card:nth-child(1) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.nutrition-card:nth-child(2) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.nutrition-card:nth-child(3) {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.nutrition-card:nth-child(4) {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.nutrition-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.nutrition-label {
    font-size: 0.9rem;
    font-weight: 300;
    opacity: 0.95;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nutrition-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.nutrition-unit {
    font-size: 0.95rem;
    font-weight: 400;
    opacity: 0.9;
}

/* Footer */
footer {
    background: var(--dark);
    color: var(--white);
    padding: 2rem 0;
    text-align: center;
    margin-top: 3rem;
}

.social-links {
    margin-top: 1rem;
}

.social-links a {
    font-size: 1.5rem;
    margin: 0 0.5rem;
    text-decoration: none;
}

/* Responsive */
@media (max-width: 768px) {
    .nutrition-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .nutrition-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .modal-close {
        right: 15px;
        top: calc(1vh + 15px);
    }

    .modal-header {
        padding: 1rem 1.5rem 0.75rem;
    }

    .modal-header h2 {
        font-size: 1.4rem;
    }

    .filters {
        top: 0;
    }

    .filters.compact {
        padding: 0.75rem 0;
    }

    .filters.compact .filter-btn {
        padding: 0.4rem 1rem;
        font-size: 0.85rem;
    }

    .nav-brand h1 {
        font-size: 1.2rem;
    }

    .nav-brand .tagline {
        font-size: 0.75rem;
    }

    .navbar .container {
        flex-wrap: wrap;
        align-items: center;
        padding: 0.6rem 15px;
    }

    .nav-toggle {
        display: flex;
        flex-shrink: 0;
        padding: 0.25rem;
        order: 2;
    }

    .nav-menu {
        display: contents;
    }

    .nav-brand {
        order: 1;
    }

    .navbar .recipe-counter {
        width: 100%;
        order: 3;
        margin-top: 0.3rem;
        margin-bottom: 0;
        font-size: 0.8rem;
        padding: 0.25rem 0.75rem;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--white);
        flex-direction: column;
        padding: 1rem;
        box-shadow: var(--shadow);
    }

    .nav-links.show {
        display: flex;
    }

    .hero {
        padding: 2rem 0;
    }

    .hero-title {
        font-size: 1.6rem;
        line-height: 1.2;
    }

    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 1.2rem;
    }

    .search-box {
        flex-direction: column;
    }

    .recipes-grid {
        grid-template-columns: 1fr;
    }

    .recipe-detail-meta {
        gap: 1rem;
    }
}