/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

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

/* Header */
header {
    background: linear-gradient(135deg, #00873b, #00a844);
    color: white;
    text-align: center;
    padding: 2rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Controls */
.controls {
    background: white;
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-filter {
    display: flex;
    gap: 1rem;
    flex: 1;
    min-width: 300px;
}

.search-filter input,
.search-filter select {
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.search-filter input {
    flex: 2;
}

.search-filter select {
    flex: 1;
}

.search-filter input:focus,
.search-filter select:focus {
    outline: none;
    border-color: #00873b;
}

.sort-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.sort-controls label {
    font-weight: 600;
    color: #666;
}

.sort-controls select {
    padding: 0.5rem;
    border: 2px solid #e9ecef;
    border-radius: 5px;
    font-size: 0.9rem;
}

.sort-btn {
    padding: 0.5rem 0.75rem;
    background: #00873b;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s;
}

.sort-btn:hover {
    background: #006d2f;
}

/* Item count */
.item-count {
    margin: 1rem 0;
    font-size: 1.1rem;
    color: #666;
    text-align: center;
}

/* Menu grid */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Menu item card */
.menu-item {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.menu-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.menu-item h3 {
    color: #00873b;
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.category-badge {
    display: inline-block;
    background: #e9ecef;
    color: #495057;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.nutrition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.nutrition-item {
    text-align: center;
    padding: 0.75rem 0.5rem;
    background: #f8f9fa;
    border-radius: 5px;
}

.nutrition-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: #00873b;
}

.nutrition-label {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
}

/* Highlight key nutrition facts */
.nutrition-item.calories .nutrition-value {
    color: #dc3545;
    font-size: 1.4rem;
}

.nutrition-item.protein .nutrition-value {
    color: #17a2b8;
}

.nutrition-item.sodium .nutrition-value {
    color: #ffc107;
}

/* Loading spinner */
.loading {
    text-align: center;
    padding: 2rem;
    font-size: 1.2rem;
    color: #666;
}

/* Footer */
footer {
    background: #343a40;
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 3rem;
}

footer p {
    opacity: 0.8;
}

/* Info buttons */
.ingredient-item {
    position: relative;
}

.ingredient-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.info-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    color: #666;
    border-radius: 50%;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-weight: 600;
}

.info-btn:hover {
    background: #00873b;
    color: white;
    border-color: #00873b;
    transform: scale(1.05);
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    animation: scaleIn 0.2s ease-out;
}

.modal-header {
    background: linear-gradient(135deg, #00873b, #00a844);
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

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

.modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-nutrition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.modal-nutrition-item {
    text-align: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.modal-nutrition-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #00873b;
    display: block;
    margin-bottom: 0.25rem;
}

.modal-nutrition-label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

/* Modal animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-filter {
        flex-direction: column;
        width: 100%;
        min-width: auto;
    }
    
    .menu-grid {
        grid-template-columns: 1fr;
    }
    
    .nutrition-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

/* Animation for item loading */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.menu-item {
    animation: fadeInUp 0.5s ease-out;
}

/* Sandwich Builder Section */
.sandwich-builder-section {
    display: block;
}

/* Ingredient Search */
.ingredient-search {
    position: relative;
    margin: 2rem 0 1rem 0;
}

.ingredient-search input {
    width: 100%;
    padding: 12px 40px 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 16px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.ingredient-search input:focus {
    outline: none;
    border-color: #00873b;
    box-shadow: 0 0 0 3px rgba(0, 135, 59, 0.1);
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
    opacity: 0;
    pointer-events: none;
}

.clear-search-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.clear-search-btn:hover {
    background: #c82333;
}

/* Sandwich Builder */
.sandwich-builder {
    display: flex;
    gap: 2rem;
    margin: 1rem 0 2rem 0;
}

.builder-left {
    flex: 2;
}

.builder-right {
    flex: 1;
    position: sticky;
    top: 2rem;
    height: fit-content;
}

.ingredient-categories {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.ingredient-category {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.ingredient-category h3 {
    color: #00873b;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ingredient-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
}

.ingredient-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
}

.ingredient-option:hover {
    border-color: #00873b;
    background: #f0f8f4;
}

.ingredient-option.selected {
    border-color: #00873b;
    background: #e6f7e9;
}

.ingredient-info {
    flex: 1;
}

.ingredient-name {
    font-weight: 600;
    color: #333;
}

.ingredient-nutrition {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
}

.add-btn {
    background: #00873b;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-btn:hover {
    background: #006d2f;
}

.ingredient-option.selected .add-btn {
    background: #dc3545;
}

.ingredient-option.selected .add-btn::before {
    content: "×";
}

.ingredient-option:not(.selected) .add-btn::before {
    content: "+";
}

.ingredient-option.hidden {
    display: none;
}

.ingredient-category.hidden {
    display: none;
}

/* Custom Sandwich Summary */
.custom-sandwich-summary {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.custom-sandwich-summary h3 {
    color: #00873b;
    margin-bottom: 1rem;
}

.selected-ingredients {
    margin-bottom: 1.5rem;
    min-height: 100px;
}

.selected-ingredient {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
    border-radius: 5px;
}

.selected-ingredient-name {
    font-weight: 500;
}

.remove-ingredient {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 2rem 0;
}

.clear-all {
    text-align: center;
    margin-bottom: 1.5rem;
}

.clear-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
}

.clear-btn:hover {
    background: #c82333;
}

.nutrition-summary h4 {
    color: #333;
    margin-bottom: 1rem;
}

.total-nutrition {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.total-nutrition .nutrition-item {
    background: #f0f8f4;
    border: 1px solid #c3e6cb;
}

.total-nutrition .nutrition-value {
    color: #00873b;
    font-size: 1.1rem;
    font-weight: 700;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sandwich-builder {
        flex-direction: column;
    }
    
    .builder-right {
        position: static;
    }
    
    .ingredient-options {
        grid-template-columns: 1fr;
    }
    
    /* Modal responsive styles */
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-nutrition-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.75rem;
    }
    
    .modal-nutrition-item {
        padding: 0.75rem;
    }
    
    .modal-nutrition-value {
        font-size: 1.25rem;
    }
    
    .info-btn {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }
    
}