/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #ff6b35;
    --primary-hover: #e55a2b;
    --secondary-color: #4a4a4a;
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-primary: #2d3436;
    --text-secondary: #636e72;
    --border-color: #dfe6e9;
    --success-color: #00b894;
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.12);
    --shadow-heavy: 0 8px 30px rgba(0, 0, 0, 0.16);
    --border-radius: 12px;
    --border-radius-small: 8px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, var(--primary-color), #ff8c5a);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 50px;
    height: 50px;
    border-radius: 10px;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.tagline {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-top: 0.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Section Styles */
section {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-light);
}

section h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Ingredient Input */
.ingredient-input-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

#ingredientInput {
    flex: 1;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-small);
    transition: var(--transition);
    outline: none;
}

#ingredientInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

/* Ingredient Suggestions */
.ingredient-suggestions {
    position: relative;
    margin-bottom: 1rem;
}

.suggestions-dropdown {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-small);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-medium);
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.suggestion-item:hover {
    background-color: #fff3ef;
    color: var(--primary-color);
}

/* Selected Ingredients */
.selected-ingredients {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: var(--border-radius-small);
    margin-bottom: 0.75rem;
}

.placeholder-text {
    color: var(--text-secondary);
    font-style: italic;
    padding: 0.25rem;
}

.ingredient-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), #ff8c5a);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    animation: tagAppear 0.2s ease;
}

@keyframes tagAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ingredient-tag button {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
    transition: var(--transition);
}

.ingredient-tag button:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Buttons */
.btn {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #ff8c5a);
    color: white;
}

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

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #3d3d3d;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* Filter Section */
.filter-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.filter-checkbox:hover {
    background: #fff3ef;
    border-color: var(--primary-color);
}

.filter-checkbox input[type="checkbox"] {
    display: none;
}

.filter-checkbox .checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.filter-checkbox input[type="checkbox"]:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.filter-checkbox input[type="checkbox"]:checked + .checkmark::after {
    content: "✓";
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
}

.filter-label {
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* Search Container */
.search-container {
    text-align: center;
    margin-bottom: 2rem;
}

/* Results Section */
.results-section {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.results-header h2 {
    margin-bottom: 0;
}

.results-count {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Recipe Grid */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    background: var(--card-background);
    border-radius: var(--border-radius);
}

/* Recipe Card */
.recipe-card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
    cursor: pointer;
}

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

.recipe-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
}

.recipe-image-placeholder {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
}

.recipe-content {
    padding: 1.25rem;
}

.recipe-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.recipe-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.recipe-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.recipe-match {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.match-bar {
    flex: 1;
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
}

.match-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), #55efc4);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.match-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--success-color);
    min-width: 45px;
}

.recipe-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.diet-tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 4px;
}

.missing-ingredients {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.missing-ingredients strong {
    color: var(--primary-color);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-background);
    border-radius: var(--border-radius);
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalAppear 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.2);
}

.modal-body {
    padding: 0;
}

.modal-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
}

.modal-image-placeholder {
    width: 100%;
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 6rem;
    background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
}

.modal-details {
    padding: 1.5rem;
}

.modal-details h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.modal-section ul {
    padding-left: 1.25rem;
}

.modal-section li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.modal-section li.has-ingredient {
    color: var(--success-color);
}

.modal-section li.missing-ingredient {
    color: var(--primary-color);
}

.modal-section ol {
    padding-left: 1.25rem;
}

.modal-section ol li {
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Footer */
.footer {
    background: var(--secondary-color);
    color: white;
    padding: 1.5rem;
    text-align: center;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.footer a:hover {
    color: #ff8c5a;
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 0.95rem;
    }

    .main-content {
        padding: 1rem;
    }

    section {
        padding: 1rem;
    }

    .filter-options {
        grid-template-columns: 1fr;
    }

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

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .modal-content {
        max-height: 100vh;
        border-radius: 0;
    }

    .modal-image,
    .modal-image-placeholder {
        height: 200px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .logo-container {
        flex-direction: column;
        gap: 0.5rem;
    }

    .ingredient-input-container {
        flex-direction: column;
    }

    .btn-large {
        width: 100%;
    }

    .recipe-meta {
        flex-wrap: wrap;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    grid-column: 1 / -1;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
