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

:root {
    --primary-color: #4CAF50;
    --primary-dark: #388E3C;
    --secondary-color: #FF9800;
    --background: #f5f5f5;
    --card-background: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --error-color: #f44336;
    --success-color: #4CAF50;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
    width: 100%;
}

/* Header */
header {
    text-align: center;
    padding: 2rem 0;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Card Component */
.card {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.card h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-primary);
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Button Styles */
.btn {
    padding: 0.875rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    display: block;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
}

.btn-primary:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Meal List Grid */
.meal-grid {
    display: grid;
    gap: 1rem;
}

.meal-item {
    background: var(--background);
    border-radius: 8px;
    padding: 1rem;
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s ease;
}

.meal-item:hover {
    transform: translateX(4px);
}

.meal-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.meal-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.meal-date {
    background-color: var(--secondary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}

.meal-details {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.meal-cook {
    display: block;
    margin-bottom: 0.25rem;
}

.meal-recipe {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    margin-top: 0.5rem;
    font-weight: 500;
}

.meal-recipe:hover {
    text-decoration: underline;
}

/* Loading and Error States */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.error {
    background-color: #ffebee;
    color: var(--error-color);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--error-color);
}

.success {
    background-color: #e8f5e9;
    color: var(--success-color);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--success-color);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    margin-top: auto;
}

/* Responsive Design */
@media (max-width: 640px) {
    .container {
        padding: 0.75rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .card {
        padding: 1.25rem;
    }

    .card h2 {
        font-size: 1.25rem;
    }

    .meal-header {
        flex-direction: column;
    }

    .meal-date {
        align-self: flex-start;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.meal-item {
    animation: fadeIn 0.3s ease;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Ingredients Section */
.ingredients-section {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: var(--background);
    border-radius: 8px;
}

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

.ingredients-header label {
    font-weight: 600;
    color: var(--text-primary);
}

.ingredients-mode {
    display: flex;
    gap: 0.5rem;
}

.btn-mode {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    background-color: white;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-mode:hover {
    border-color: var(--primary-color);
}

.btn-mode.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.ingredient-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    align-items: center;
}

.ingredient-row input {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

.ingredient-row input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.ingredient-name {
    grid-column: 1;
}

.ingredient-quantity {
    grid-column: 2;
}

.ingredient-unit {
    grid-column: 3;
}

.btn-remove {
    width: 2rem;
    height: 2rem;
    border: none;
    background-color: var(--error-color);
    color: white;
    border-radius: 4px;
    font-size: 1.25rem;
    cursor: pointer;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove:hover {
    opacity: 0.8;
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--primary-color);
    background-color: white;
    color: var(--primary-color);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: white;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.helper-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    font-style: italic;
}

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

/* Shopping List Styles */
.shopping-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.shopping-list-actions {
    display: flex;
    gap: 0.5rem;
}

.week-range {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 1rem;
    padding: 0.75rem;
    background-color: var(--background);
    border-radius: 6px;
    text-align: center;
}

.shopping-category {
    margin-bottom: 1.5rem;
}

.shopping-category h3 {
    font-size: 1.125rem;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

.shopping-items {
    list-style: none;
    padding: 0;
}

.shopping-items li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.shopping-items li::before {
    content: "☐";
    position: absolute;
    left: 0;
    font-size: 1.125rem;
    color: var(--primary-color);
}

.item-name {
    color: var(--text-primary);
}

/* Responsive Updates for New Features */
@media (max-width: 640px) {
    .ingredient-row {
        grid-template-columns: 1fr;
    }

    .ingredient-row input {
        grid-column: 1;
    }

    .btn-remove {
        justify-self: start;
    }

    .ingredients-mode {
        width: 100%;
    }

    .btn-mode {
        flex: 1;
    }

    .shopping-list-header {
        flex-direction: column;
        align-items: stretch;
    }

    .shopping-list-actions {
        width: 100%;
    }

    .shopping-list-actions button {
        flex: 1;
    }
}
