/* Meal Builder Widget Styles */
* {
    box-sizing: border-box;
}

.meal-builder-widget {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}

.meal-builder-header {
    text-align: center;
    margin-bottom: 30px;
}

.meal-builder-header h2 {
    color: #2d3748;
    font-size: 2.25rem;
    font-weight: 700;
    margin: 0 0 10px 0;
}

.meal-builder-header p {
    color: #718096;
    font-size: 1.1rem;
    margin: 0;
}

/* Meal Type Selector */
.meal-type-selector {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 30px;
}

.meal-type-btn {
    padding: 12px 24px;
    border: 2px solid #e2e8f0;
    background: #ffffff;
    color: #4a5568;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.meal-type-btn:hover {
    border-color: #4299e1 !important;
    color: #3182ce !important;
    transform: translateY(-2px) !important;
    background: #ebf8ff !important;
}

.meal-type-btn.active {
    background: #4299e1;
    border-color: #4299e1;
    color: white;
    box-shadow: 0 4px 12px rgba(66, 153, 225, 0.3);
}

/* Main Content Layout */
.meal-builder-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    align-items: start;
}

/* Food Categories */
.food-categories {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.category-section h3 {
    color: #2d3748;
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.food-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

/* Food Item Cards */
.food-item {
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.food-item:hover {
    border-color: #4299e1;
    background: #ebf8ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(66, 153, 225, 0.15);
}

.food-item.selected {
    border-color: #48bb78;
    background: #f0fff4;
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.2);
}

.food-item-name {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 6px;
    font-size: 1rem;
}

.food-item-portion {
    color: #718096;
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.food-item-nutrition {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    font-size: 0.75rem;
    color: #4a5568;
}

.nutrition-detail {
    display: flex;
    justify-content: space-between;
}

.food-item-notes {
    font-size: 0.75rem;
    color: #718096;
    margin-top: 8px;
    font-style: italic;
}

/* Selection indicator */
.food-item.selected::after {
    content: "✓";
    position: absolute;
    top: 8px;
    right: 12px;
    color: #48bb78;
    font-weight: bold;
    font-size: 1.2rem;
}

/* Nutrition Panel */
.nutrition-panel {
    position: sticky;
    top: 20px;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.nutrition-panel h3 {
    color: #2d3748;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 16px 0;
}

/* Selected Items */
.selected-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.selected-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f7fafc;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.875rem;
}

.selected-item-name {
    font-weight: 500;
    color: #2d3748;
}

.remove-item {
    background: #fed7d7;
    color: #e53e3e;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    max-width: 20px;
    max-height: 20px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
    font-weight: normal;
    font-family: Arial, sans-serif;
    padding: 0;
    margin: 0;
    transition: all 0.2s ease;
    position: relative;
}

.remove-item:hover {
    background: #feb2b2 !important;
    color: #c53030 !important;
    transform: scale(1.1) !important;
}

.empty-state {
    color: #a0aec0;
    font-style: italic;
    text-align: center;
    padding: 20px;
    margin: 0;
}

.clear-btn {
    width: 100%;
    padding: 8px;
    background: #fed7d7;
    color: #e53e3e;
    border: 1px solid #feb2b2;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.clear-btn:hover {
    background: #feb2b2 !important;
    border-color: #fc8181 !important;
    color: #c53030 !important;
    transform: translateY(-1px) !important;
}

.clear-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Nutrition Summary */
.nutrition-summary {
    margin-top: 24px;
}

.nutrition-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.nutrition-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f7fafc;
    border-radius: 8px;
    border-left: 4px solid #4299e1;
}

.nutrition-label {
    font-weight: 500;
    color: #4a5568;
}

.nutrition-value {
    font-weight: 700;
    color: #2d3748;
    font-size: 1.1rem;
}

.nutrition-unit {
    font-size: 0.875rem;
    color: #718096;
}

/* Calorie Distribution */
.calorie-distribution h4 {
    color: #2d3748;
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 12px 0;
}

.distribution-item {
    margin-bottom: 8px;
}

.distribution-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.protein-bar {
    background: #48bb78;
}

.fat-bar {
    background: #ed8936;
}

.carbs-bar {
    background: #4299e1;
}

.distribution-label {
    font-size: 0.875rem;
    color: #4a5568;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
    .meal-builder-widget {
        padding: 16px;
        border-radius: 0;
        box-shadow: none;
    }

    .meal-builder-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .nutrition-panel {
        position: relative;
        top: 0;
    }

    .food-items {
        grid-template-columns: 1fr;
    }

    .meal-type-selector {
        flex-direction: column;
        align-items: center;
    }

    .meal-type-btn {
        width: 200px;
    }

    .meal-builder-header h2 {
        font-size: 1.8rem;
    }
}

@media (max-width: 480px) {
    .meal-builder-widget {
        padding: 12px;
    }

    .food-item {
        padding: 12px;
    }

    .nutrition-panel {
        padding: 16px;
    }
}

/* High Specificity Override Styles for Theme Conflicts */
.meal-builder-widget .meal-type-selector .meal-type-btn:hover {
    border-color: #4299e1 !important;
    color: #3182ce !important;
    background: #ebf8ff !important;
    background-image: none !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 2px 8px rgba(66, 153, 225, 0.2) !important;
}

.meal-builder-widget .nutrition-panel .clear-btn:hover {
    background: #feb2b2 !important;
    background-image: none !important;
    border-color: #fc8181 !important;
    color: #c53030 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.meal-builder-widget .selected-item .remove-item:hover {
    background: #feb2b2 !important;
    background-image: none !important;
    color: #c53030 !important;
    transform: scale(1.1) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* Override CSS custom properties for theme conflicts */
.meal-builder-widget .meal-type-btn {
    --cs-color-button-hover: none !important;
    --cs-light-button-hover-background-start: transparent !important;
    --cs-light-button-hover-background-end: transparent !important;
}

.meal-builder-widget .clear-btn {
    --cs-color-button-hover: none !important;
    --cs-light-button-hover-background-start: transparent !important;
    --cs-light-button-hover-background-end: transparent !important;
}

.meal-builder-widget .remove-item {
    --cs-color-button-hover: none !important;
    --cs-light-button-hover-background-start: transparent !important;
    --cs-light-button-hover-background-end: transparent !important;
}

/* Ultra-specific selectors to override theme */
.meal-builder-widget .meal-type-selector .meal-type-btn:hover,
.meal-builder-widget .meal-type-selector .meal-type-btn:focus,
.meal-builder-widget .meal-type-selector .meal-type-btn:active {
    background: #ebf8ff !important;
    background-image: none !important;
    background-color: #ebf8ff !important;
    border-color: #4299e1 !important;
    color: #3182ce !important;
}

.meal-builder-widget .nutrition-panel .clear-btn:hover,
.meal-builder-widget .nutrition-panel .clear-btn:focus,
.meal-builder-widget .nutrition-panel .clear-btn:active {
    background: #feb2b2 !important;
    background-image: none !important;
    background-color: #feb2b2 !important;
    border-color: #fc8181 !important;
    color: #c53030 !important;
}

.meal-builder-widget .selected-item .remove-item:hover,
.meal-builder-widget .selected-item .remove-item:focus,
.meal-builder-widget .selected-item .remove-item:active {
    background: #feb2b2 !important;
    background-image: none !important;
    background-color: #feb2b2 !important;
    color: #c53030 !important;
}

/* Ensure perfect circle for remove buttons */
.meal-builder-widget .remove-item {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    aspect-ratio: 1 !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: Arial, sans-serif !important;
    font-size: 14px !important;
    line-height: 1 !important;
    font-weight: normal !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}

/* Additional theme override protection */
.meal-builder-widget button:hover {
    text-decoration: none !important;
    outline: none !important;
}

.meal-builder-widget .meal-type-btn,
.meal-builder-widget .clear-btn,
.meal-builder-widget .remove-item {
    box-sizing: border-box !important;
    font-family: inherit !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

/* FINAL OVERRIDE - Maximum specificity for stubborn themes */
html body .meal-builder-widget .meal-type-btn:hover,
html body .meal-builder-widget .meal-type-btn:focus {
    background: #ebf8ff !important;
    background-image: none !important;
    background-color: #ebf8ff !important;
    border-color: #4299e1 !important;
    color: #3182ce !important;
    --cs-color-button-hover: none !important;
}

html body .meal-builder-widget .clear-btn:hover,
html body .meal-builder-widget .clear-btn:focus {
    background: #feb2b2 !important;
    background-image: none !important;
    background-color: #feb2b2 !important;
    border-color: #fc8181 !important;
    color: #c53030 !important;
    --cs-color-button-hover: none !important;
}

html body .meal-builder-widget .remove-item:hover,
html body .meal-builder-widget .remove-item:focus {
    background: #feb2b2 !important;
    background-image: none !important;
    background-color: #feb2b2 !important;
    color: #c53030 !important;
    --cs-color-button-hover: none !important;
}
