/* Compact Meal Builder Widget Styles - Light Theme */
.compact-meal-builder {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
    font-size: 14px;
    line-height: 1.4;
    background: #ffffff;
    border-radius: 8px;
    color: #1f2937 !important;
}

/* Ensure all elements use proper box-sizing */
.compact-meal-builder *,
.compact-meal-builder *::before,
.compact-meal-builder *::after {
    box-sizing: border-box !important;
}

/* Header Section */
.cmb-header .cmb-meal-type {
    width: 100% !important;
    margin-bottom: 12px !important;
    padding: 10px 12px !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 6px !important;
    background: #ffffff !important;
    font-size: 14px !important;
    font-family: inherit !important;
    color: #2d3748 !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
    background-size: 16px !important;
    padding-right: 32px !important;
}

.cmb-header .cmb-meal-type:focus {
    outline: none !important;
    border-color: #4299e1 !important;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1) !important;
}

.cmb-header .cmb-meal-type:hover {
    border-color: #cbd5e0 !important;
}

/* Categories Section */
.cmb-categories .cmb-food-select {
    width: 100% !important;
    margin-bottom: 12px !important;
    padding: 10px 12px !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 6px !important;
    background: #ffffff !important;
    font-size: 14px !important;
    font-family: inherit !important;
    color: #2d3748 !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
    background-size: 16px !important;
    padding-right: 32px !important;
}

.cmb-categories .cmb-food-select:focus {
    outline: none !important;
    border-color: #4299e1 !important;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1) !important;
}

.cmb-categories .cmb-food-select:hover {
    border-color: #cbd5e0 !important;
}

.cmb-categories .cmb-add-btn {
    width: 100% !important;
    margin-bottom: 12px !important;
    padding: 10px 16px !important;
    background: #4299e1 !important;
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: 1.4 !important;
    box-shadow: 0 2px 4px rgba(66, 153, 225, 0.2) !important;
}

.cmb-categories .cmb-add-btn:hover {
    background: #3182ce !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(66, 153, 225, 0.3) !important;
}

.cmb-categories .cmb-add-btn:active {
    background: #2c5282 !important;
    transform: translateY(0) !important;
    box-shadow: 0 2px 4px rgba(66, 153, 225, 0.2) !important;
}

.cmb-categories .cmb-add-btn:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.4) !important;
}

/* Selected Items Section */
.cmb-selected {
    max-height: 160px !important;
    overflow-y: auto !important;
    margin-bottom: 15px !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 6px !important;
    background: #f8fafc !important;
    padding: 8px !important;
    min-height: 60px !important;
}

.cmb-selected::-webkit-scrollbar {
    width: 4px;
}

.cmb-selected::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 2px;
}

.cmb-selected::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.cmb-selected::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.cmb-selected:empty::before {
    content: "No items selected";
    display: block;
    font-style: italic;
    color: #9ca3af !important;
    text-align: center;
    padding: 15px 10px !important;
    font-size: 13px !important;
}

.cmb-empty {
    font-style: italic !important;
    color: #9ca3af !important;
    text-align: center !important;
    margin: 0 !important;
    padding: 15px 10px !important;
    font-size: 13px !important;
}

/* Selected Item Styling */
.cmb-selected-item {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 8px 10px !important;
    background: #374151 !important;
    color: #ffffff !important;
    margin-bottom: 4px !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    border: 1px solid #4b5563 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    transition: all 0.2s ease !important;
}

.cmb-selected-item:last-child {
    margin-bottom: 0 !important;
}

.cmb-selected-item:hover {
    background: #4b5563 !important;
    border-color: #6b7280 !important;
    color: #ffffff !important;
}

.cmb-remove-btn {
    background: #ef4444 !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    cursor: pointer !important;
    font-size: 11px !important;
    line-height: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: inherit !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    box-shadow: 0 1px 3px rgba(239, 68, 68, 0.3) !important;
}

.cmb-remove-btn:hover {
    background: #dc2626 !important;
    transform: scale(1.1) !important;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4) !important;
}

.cmb-remove-btn:active {
    background: #b91c1c !important;
    transform: scale(0.95) !important;
}

.cmb-remove-btn:focus {
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.4) !important;
}

/* Nutrition Section */
.cmb-nutrition {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
    padding: 15px !important;
    border-radius: 8px !important;
    border: 2px solid #e2e8f0 !important;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    margin-bottom: 15px !important;
}

.cmb-nutrition-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 8px !important;
    font-size: 13px !important;
    padding: 4px 0 !important;
}

.cmb-nutrition-row:last-child {
    margin-bottom: 0 !important;
}

.cmb-nutrition-label {
    font-weight: 600 !important;
    color: #374151 !important;
    font-size: 13px !important;
}

.cmb-nutrition-value {
    font-weight: 700 !important;
    color: #1f2937 !important;
    font-size: 14px !important;
    background: #ffffff !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
    border: 1px solid #e5e7eb !important;
    min-width: 45px !important;
    text-align: center !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

/* CTA Link */
.cmb-full-link {
    display: block !important;
    text-align: center !important;
    margin-top: 0 !important;
    padding: 12px 16px !important;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%) !important;
    color: #374151 !important;
    text-decoration: none !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    font-family: inherit !important;
    transition: all 0.2s ease !important;
    border: 2px solid #d1d5db !important;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1) !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: 1.4 !important;
}

.cmb-full-link:hover {
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%) !important;
    color: #1f2937 !important;
    text-decoration: none !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15) !important;
    border-color: #9ca3af !important;
}

.cmb-full-link:active {
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%) !important;
    transform: translateY(0) !important;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1) !important;
    color: #111827 !important;
}

.cmb-full-link:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.4) !important;
}

/* Responsive adjustments for very narrow sidebars */
@media (max-width: 250px) {
    .compact-meal-builder {
        font-size: 12px;
    }

    .cmb-header .cmb-meal-type,
    .cmb-categories .cmb-food-select,
    .cmb-categories .cmb-add-btn {
        padding: 6px;
        font-size: 12px;
    }

    .cmb-selected-item {
        font-size: 11px;
    }

    .cmb-remove-btn {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }
}

/* WordPress widget specific overrides */
.widget .compact-meal-builder {
    margin: 0;
}

.widget .compact-meal-builder * {
    box-sizing: border-box;
}

/* Ensure proper spacing in widget areas */
.widget .compact-meal-builder > * {
    margin-left: 0;
    margin-right: 0;
}

/* Theme compatibility - override common theme conflicts */
.compact-meal-builder select,
.compact-meal-builder button,
.compact-meal-builder input {
    font-family: inherit !important;
    line-height: normal !important;
    margin: 0 !important;
    box-shadow: none;
    text-transform: none !important;
    letter-spacing: normal !important;
    border-radius: inherit !important;
    background-image: none;
    background-color: inherit;
}

.compact-meal-builder button:focus {
    outline: 2px solid #4299e1 !important;
    outline-offset: 2px !important;
}

/* Strong overrides for theme button interference */
.compact-meal-builder .cmb-add-btn,
.compact-meal-builder .cmb-remove-btn,
.compact-meal-builder .cmb-full-link {
    background-image: none !important;
    background-clip: padding-box !important;
    border-image: none !important;
    text-shadow: none !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Override WordPress/theme button styles specifically */
.widget .compact-meal-builder button,
.sidebar .compact-meal-builder button,
.compact-meal-builder button.cmb-add-btn,
.compact-meal-builder button.cmb-remove-btn {
    background: initial !important;
    border: initial !important;
    color: initial !important;
    padding: initial !important;
    margin: initial !important;
    font-size: initial !important;
    font-weight: initial !important;
    line-height: initial !important;
    text-decoration: none !important;
    border-radius: initial !important;
    box-shadow: initial !important;
    transition: initial !important;
}

/* Re-apply our specific styles with high specificity */
.compact-meal-builder button.cmb-add-btn {
    width: 100% !important;
    margin-bottom: 12px !important;
    padding: 10px 16px !important;
    background: #4299e1 !important;
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: 1.4 !important;
    box-shadow: 0 2px 4px rgba(66, 153, 225, 0.2) !important;
}

.compact-meal-builder button.cmb-add-btn:hover {
    background: #3182ce !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(66, 153, 225, 0.3) !important;
}

.compact-meal-builder button.cmb-remove-btn {
    background: #ef4444 !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    cursor: pointer !important;
    font-size: 11px !important;
    line-height: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: inherit !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    box-shadow: 0 1px 3px rgba(239, 68, 68, 0.3) !important;
}

.compact-meal-builder button.cmb-remove-btn:hover {
    background: #dc2626 !important;
    transform: scale(1.1) !important;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4) !important;
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .cmb-nutrition {
        background: #2d3748;
        border-color: #4a5568;
    }

    .cmb-selected {
        background: #2d3748;
        border-color: #4a5568;
    }

    .cmb-selected-item {
        background: #1a202c;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .cmb-nutrition-label {
        color: #a0aec0;
    }

    .cmb-nutrition-value {
        color: #e2e8f0;
    }

    .cmb-empty {
        color: #a0aec0;
    }
}
