From 83b0f88d6e0c9be715fa51a97162f3240cb08b25 Mon Sep 17 00:00:00 2001 From: Mohammad Sajad Pourajam Date: Sat, 21 Feb 2026 22:21:31 +0330 Subject: [PATCH] Enhance dashboard components with theme integration and UI improvements - Updated FarmAiAssistantChat, PlantPestDetection, SmartFertilizationRecommendation, and SmartIrrigationRecommendation components to utilize theme-based styling for better consistency and visual appeal. - Refactored background gradients, box shadows, and hover effects to align with the primary color palette. - Improved layout classes for better responsiveness and user experience across various dashboard sections. - Added new button styles and loading indicators to enhance interactivity and feedback during user actions. --- .../farmAiAssistant/FarmAiAssistantChat.tsx | 135 +++++++----- .../farm/pestDetection/PlantPestDetection.tsx | 43 ++-- .../SmartFertilizationRecommendation.tsx | 194 +++++++++--------- .../SmartIrrigationRecommendation.tsx | 143 +++++++------ 4 files changed, 276 insertions(+), 239 deletions(-) diff --git a/src/views/dashboards/farm/farmAiAssistant/FarmAiAssistantChat.tsx b/src/views/dashboards/farm/farmAiAssistant/FarmAiAssistantChat.tsx index 40513ad..72efb1a 100644 --- a/src/views/dashboards/farm/farmAiAssistant/FarmAiAssistantChat.tsx +++ b/src/views/dashboards/farm/farmAiAssistant/FarmAiAssistantChat.tsx @@ -8,7 +8,13 @@ import Card from '@mui/material/Card' import IconButton from '@mui/material/IconButton' import TextField from '@mui/material/TextField' import Collapse from '@mui/material/Collapse' +import { useTheme } from '@mui/material/styles' +import { alpha } from '@mui/material/styles' import classnames from 'classnames' + +// Util Imports +import { commonLayoutClasses } from '@layouts/utils/layoutClasses' + import type { FarmContext, FarmAIMessage, AIResponseSection } from './farmAiAssistantTypes' // ─── Constants ───────────────────────────────────────────────────────────── @@ -62,6 +68,7 @@ const DEMO_AI_RESPONSE_SECTIONS: AIResponseSection[] = [ export default function FarmAiAssistantChat() { const t = useTranslations('farmAiAssistant') + const theme = useTheme() const [messages, setMessages] = useState([]) const [inputValue, setInputValue] = useState('') const [isContextExpanded, setIsContextExpanded] = useState(true) @@ -71,6 +78,7 @@ export default function FarmAiAssistantChat() { const scrollRef = useRef(null) const farmContext = DEFAULT_FARM_CONTEXT + const { primary, info, warning } = theme.palette // Scroll to bottom on new messages useEffect(() => { @@ -127,35 +135,36 @@ export default function FarmAiAssistantChat() { return ( {/* 1) Smart Header */} - + setIsContextExpanded(!isContextExpanded)} className='w-full flex items-center justify-between px-4 py-3 text-start' sx={{ - '&:hover': { bgcolor: 'rgba(34, 197, 94, 0.04)' }, + '&:hover': { bgcolor: alpha(primary.main, 0.04) }, transition: 'background 0.2s' }} > @@ -193,9 +202,10 @@ export default function FarmAiAssistantChat() { {t('context.title')} @@ -225,10 +235,10 @@ export default function FarmAiAssistantChat() { - + {t('emptyState.title')} @@ -255,17 +265,18 @@ export default function FarmAiAssistantChat() { - + @@ -290,14 +301,12 @@ export default function FarmAiAssistantChat() { sx={{ background: selectedChip === chip.id - ? 'linear-gradient(135deg, #22c55e 0%, #16a34a 100%)' - : 'linear-gradient(145deg, #ffffff 0%, rgba(34, 197, 94, 0.08) 100%)', - color: selectedChip === chip.id ? '#ffffff' : 'text.primary', - border: selectedChip === chip.id ? 'none' : '1px solid rgba(34, 197, 94, 0.2)', + ? `linear-gradient(135deg, ${primary.main} 0%, ${primary.dark} 100%)` + : `linear-gradient(145deg, ${theme.palette.background.paper} 0%, ${alpha(primary.main, 0.08)} 100%)`, + color: selectedChip === chip.id ? 'primary.contrastText' : 'text.primary', + border: selectedChip === chip.id ? 'none' : `1px solid ${alpha(primary.main, 0.2)}`, boxShadow: - selectedChip === chip.id - ? '0 4px 12px rgba(34, 197, 94, 0.35)' - : '0 2px 8px rgba(0,0,0,0.04)' + selectedChip === chip.id ? `0 4px 12px ${alpha(primary.main, 0.35)}` : theme.shadows[1] }} > {t(chip.labelKey)} @@ -310,17 +319,17 @@ export default function FarmAiAssistantChat() { @@ -331,7 +340,7 @@ export default function FarmAiAssistantChat() { className='shrink-0' sx={{ color: 'text.secondary', - '&:hover': { color: '#22c55e', bgcolor: 'rgba(34, 197, 94, 0.08)' } + '&:hover': { color: 'primary.main', bgcolor: 'primary.lighterOpacity' } }} > @@ -342,7 +351,7 @@ export default function FarmAiAssistantChat() { className='shrink-0' sx={{ color: 'text.secondary', - '&:hover': { color: '#0ea5e9', bgcolor: 'rgba(14, 165, 233, 0.08)' } + '&:hover': { color: 'info.main', bgcolor: 'info.lighterOpacity' } }} > @@ -377,13 +386,13 @@ export default function FarmAiAssistantChat() { className='shrink-0' sx={{ background: inputValue.trim() - ? 'linear-gradient(135deg, #22c55e 0%, #16a34a 100%)' + ? `linear-gradient(135deg, ${primary.main} 0%, ${primary.dark} 100%)` : 'action.disabledBackground', - color: inputValue.trim() ? '#ffffff' : 'action.disabled', + color: inputValue.trim() ? 'primary.contrastText' : 'action.disabled', '&:hover': inputValue.trim() ? { - background: 'linear-gradient(135deg, #16a34a 0%, #15803d 100%)', - boxShadow: '0 4px 12px rgba(34, 197, 94, 0.4)' + background: `linear-gradient(135deg, ${primary.dark} 0%, ${primary.dark} 100%)`, + boxShadow: `0 4px 12px ${alpha(primary.main, 0.4)}` } : {}, '&.Mui-disabled': { background: 'action.disabledBackground', color: 'action.disabled' } @@ -410,15 +419,18 @@ function ContextBadge({ value: string colSpan?: number }) { + const theme = useTheme() + const primary = theme.palette.primary + return ( - + {label} @@ -442,6 +454,8 @@ function MessageBubble({ onToggleExplanation: (id: string) => void t: (key: string) => string }) { + const theme = useTheme() + const { primary, info } = theme.palette const isUser = message.role === 'user' if (isUser) { @@ -450,8 +464,8 @@ function MessageBubble({ @@ -468,10 +482,11 @@ function MessageBubble({ - + {message.sections?.map((section, idx) => ( @@ -505,6 +520,8 @@ function AISectionCard({ idx: number t: (key: string) => string }) { + const theme = useTheme() + const { primary, warning: warningPalette } = theme.palette const expId = `${messageId}-exp-${idx}` const iconMap = { @@ -523,14 +540,14 @@ function AISectionCard({ className='overflow-hidden' sx={{ borderRadius: '20px', - background: 'linear-gradient(160deg, #ffffff 0%, rgba(34, 197, 94, 0.06) 100%)', - border: '1px solid rgba(34, 197, 94, 0.2)', - boxShadow: '0 4px 20px rgba(34, 197, 94, 0.12)' + background: `linear-gradient(160deg, ${theme.palette.background.paper} 0%, ${alpha(primary.main, 0.06)} 100%)`, + border: `1px solid ${alpha(primary.main, 0.2)}`, + boxShadow: `0 4px 20px ${alpha(primary.main, 0.12)}` }} > - + {section.title} @@ -574,7 +591,7 @@ function AISectionCard({ type='button' onClick={() => onToggleExplanation(expId)} className='flex items-center gap-1 text-sm font-medium' - sx={{ color: '#22c55e', '&:hover': { color: '#16a34a' } }} + sx={{ color: 'primary.main', '&:hover': { color: 'primary.dark' } }} > {t('recommendation.whyThis')} - + {section.title && ( @@ -626,13 +646,13 @@ function AISectionCard({ {section.title && ( - + {section.title} @@ -660,8 +680,9 @@ function TypingIndicator() { {[0, 1, 2].map(i => ( diff --git a/src/views/dashboards/farm/pestDetection/PlantPestDetection.tsx b/src/views/dashboards/farm/pestDetection/PlantPestDetection.tsx index f82db01..5ba340e 100644 --- a/src/views/dashboards/farm/pestDetection/PlantPestDetection.tsx +++ b/src/views/dashboards/farm/pestDetection/PlantPestDetection.tsx @@ -9,6 +9,13 @@ import Typography from '@mui/material/Typography' import Button from '@mui/material/Button' import CircularProgress from '@mui/material/CircularProgress' import Collapse from '@mui/material/Collapse' +import { useTheme } from '@mui/material/styles' +import { alpha } from '@mui/material/styles' +import classnames from 'classnames' + +// Util Imports +import { commonLayoutClasses } from '@layouts/utils/layoutClasses' + import UploadBox from './components/UploadBox' import ResultCard from './components/ResultCard' import type { UploadedFile } from './components/UploadBox' @@ -16,6 +23,8 @@ import type { PestResult } from './components/ResultCard' export default function PlantPestDetection() { const t = useTranslations('pestDetection') + const theme = useTheme() + const primary = theme.palette.primary const [file, setFile] = useState(null) const [result, setResult] = useState(null) const [loading, setLoading] = useState(false) @@ -58,19 +67,17 @@ export default function PlantPestDetection() { return ( - + {/* Header */} @@ -111,18 +118,18 @@ export default function PlantPestDetection() { onClick={handleAnalyze} startIcon={ loading ? ( - + ) : ( ) } className="rounded-xl py-3 px-8 font-semibold shadow-md transition-all duration-300 hover:shadow-lg hover:scale-[1.02] active:scale-[0.98]" sx={{ - background: 'linear-gradient(135deg, #22c55e 0%, #16a34a 50%, #15803d 100%)', - boxShadow: '0 4px 20px rgba(34, 197, 94, 0.35)', + background: `linear-gradient(135deg, ${primary.main} 0%, ${primary.dark} 50%, ${primary.dark} 100%)`, + boxShadow: `0 4px 20px ${alpha(primary.main, 0.35)}`, '&:hover': { - background: 'linear-gradient(135deg, #4ade80 0%, #22c55e 50%, #16a34a 100%)', - boxShadow: '0 6px 24px rgba(34, 197, 94, 0.45)', + background: `linear-gradient(135deg, ${primary.light} 0%, ${primary.main} 50%, ${primary.dark} 100%)`, + boxShadow: `0 6px 24px ${alpha(primary.main, 0.45)}`, }, '&:disabled': { background: 'action.disabledBackground', @@ -162,13 +169,13 @@ export default function PlantPestDetection() { className="mb-6" sx={{ borderRadius: '24px', - background: 'linear-gradient(160deg, #ffffff 0%, #f0fdf4 100%)', - boxShadow: '0 8px 32px rgba(34, 197, 94, 0.1)', - border: '1px solid rgba(34, 197, 94, 0.12)', + background: `linear-gradient(160deg, ${theme.palette.background.paper} 0%, ${alpha(primary.main, 0.06)} 100%)`, + boxShadow: `0 8px 32px ${alpha(primary.main, 0.1)}`, + border: `1px solid ${alpha(primary.main, 0.12)}`, }} > - + {t('analyzing')} diff --git a/src/views/dashboards/farm/smartFertilization/SmartFertilizationRecommendation.tsx b/src/views/dashboards/farm/smartFertilization/SmartFertilizationRecommendation.tsx index 053a4d8..7604923 100644 --- a/src/views/dashboards/farm/smartFertilization/SmartFertilizationRecommendation.tsx +++ b/src/views/dashboards/farm/smartFertilization/SmartFertilizationRecommendation.tsx @@ -8,6 +8,7 @@ import CardContent from '@mui/material/CardContent' import Typography from '@mui/material/Typography' import Button from '@mui/material/Button' import Collapse from '@mui/material/Collapse' +import { useTheme, alpha } from '@mui/material/styles' // Types interface FarmData { @@ -77,6 +78,11 @@ function generateFertilizationPlan( export default function SmartFertilizationRecommendation() { const t = useTranslations('fertilization') + const theme = useTheme() + const primaryMain = theme.palette.primary.main + const primaryLight = theme.palette.primary.light + const primaryDark = theme.palette.primary.dark + const paperBg = theme.palette.background.paper const [farmData] = useState(DEFAULT_FARM_DATA) const [growthStage, setGrowthStage] = useState(GROWTH_STAGES[0].id) const [selectedCrop, setSelectedCrop] = useState(null) @@ -101,10 +107,10 @@ export default function SmartFertilizationRecommendation() { return ( + `linear-gradient(165deg, ${alpha(th.palette.primary.main, 0.08)} 0%, ${alpha(th.palette.primary.main, 0.05)} 25%, ${alpha(th.palette.primary.main, 0.03)} 60%, ${th.palette.background.default} 100%)`, minHeight: '100vh' }} > @@ -115,8 +121,7 @@ export default function SmartFertilizationRecommendation() { variant='h4' className='font-bold tracking-tight' sx={{ - background: - 'linear-gradient(135deg, #16a34a 0%, #22c55e 40%, #7c3aed 100%)', + background: `linear-gradient(135deg, ${primaryDark} 0%, ${primaryMain} 40%, ${primaryLight} 100%)`, backgroundClip: 'text', WebkitBackgroundClip: 'text', color: 'transparent', @@ -140,11 +145,9 @@ export default function SmartFertilizationRecommendation() { className='mb-6 overflow-hidden transition-all duration-300 hover:shadow-lg animate-fade-in' sx={{ borderRadius: '28px', - background: - 'linear-gradient(145deg, #ffffff 0%, #faf5ff 50%, #f0fdf4 100%)', - boxShadow: - '0 4px 24px rgba(34, 197, 94, 0.08), 0 4px 12px rgba(124, 58, 237, 0.04), 0 1px 3px rgba(0,0,0,0.04)', - border: '1px solid rgba(34, 197, 94, 0.12)' + background: `linear-gradient(145deg, ${paperBg} 0%, ${alpha(primaryMain, 0.06)} 50%, ${alpha(primaryMain, 0.04)} 100%)`, + boxShadow: `0 4px 24px ${alpha(primaryMain, 0.08)}, 0 4px 12px ${alpha(primaryMain, 0.04)}, 0 1px 3px rgba(0,0,0,0.04)`, + border: `1px solid ${alpha(primaryMain, 0.12)}` }} > @@ -155,10 +158,9 @@ export default function SmartFertilizationRecommendation() { `linear-gradient(135deg, ${th.palette.success.main} 0%, ${th.palette.success.dark} 100%)`, color: 'white', - boxShadow: '0 2px 8px rgba(34, 197, 94, 0.3)' + boxShadow: (th) => `0 2px 8px ${alpha(th.palette.success.main, 0.3)}` }} > @@ -193,18 +195,18 @@ export default function SmartFertilizationRecommendation() { onClick={() => setGrowthStage(stage.id)} className='flex flex-col items-center gap-1.5 px-4 py-3 rounded-2xl shrink-0 transition-all duration-300 ease-out border-2 cursor-pointer min-w-[72px]' sx={{ - borderColor: isSelected ? '#22c55e' : 'transparent', + borderColor: isSelected ? primaryMain : 'transparent', background: isSelected - ? 'linear-gradient(145deg, rgba(34, 197, 94, 0.15) 0%, rgba(124, 58, 237, 0.06) 100%)' - : 'linear-gradient(145deg, #ffffff 0%, #faf5ff 100%)', + ? `linear-gradient(145deg, ${alpha(primaryMain, 0.15)} 0%, ${alpha(primaryMain, 0.06)} 100%)` + : `linear-gradient(145deg, ${paperBg} 0%, ${alpha(primaryMain, 0.04)} 100%)`, boxShadow: isSelected - ? '0 4px 20px rgba(34, 197, 94, 0.2), inset 0 1px 0 rgba(255,255,255,0.8)' + ? `0 4px 20px ${alpha(primaryMain, 0.2)}, inset 0 1px 0 rgba(255,255,255,0.8)` : '0 2px 8px rgba(0,0,0,0.04)', '&:hover': { transform: 'translateY(-2px)', boxShadow: isSelected - ? '0 6px 24px rgba(34, 197, 94, 0.25)' - : '0 4px 16px rgba(124, 58, 237, 0.1)' + ? `0 6px 24px ${alpha(primaryMain, 0.25)}` + : `0 4px 16px ${alpha(primaryMain, 0.1)}` } }} > @@ -212,23 +214,22 @@ export default function SmartFertilizationRecommendation() { className='w-10 h-10 rounded-xl flex items-center justify-center transition-all duration-300' sx={{ background: isSelected - ? 'linear-gradient(135deg, #22c55e 0%, #16a34a 100%)' + ? `linear-gradient(135deg, ${primaryMain} 0%, ${primaryDark} 100%)` : isPast - ? 'linear-gradient(145deg, rgba(34, 197, 94, 0.2) 0%, rgba(34, 197, 94, 0.1) 100%)' - : 'rgba(124, 58, 237, 0.08)' + ? `linear-gradient(145deg, ${alpha(primaryMain, 0.2)} 0%, ${alpha(primaryMain, 0.1)} 100%)` + : alpha(primaryMain, 0.08) }} > {t('plantSelection.title')} - + {CROP_OPTIONS.map(crop => ( + {/* 5) Primary CTA Button - End of form */} + + + + {/* 6) Result Section - Prescription style */} {plan && ( @@ -265,17 +293,15 @@ export default function SmartFertilizationRecommendation() { elevation={0} sx={{ borderRadius: '28px', - background: - 'linear-gradient(160deg, #ffffff 0%, #faf5ff 40%, #f0fdf4 100%)', - boxShadow: - '0 8px 32px rgba(34, 197, 94, 0.12), 0 4px 16px rgba(124, 58, 237, 0.06), 0 2px 8px rgba(0,0,0,0.04)', - border: '1px solid rgba(34, 197, 94, 0.15)', + background: `linear-gradient(160deg, ${paperBg} 0%, ${alpha(primaryMain, 0.06)} 40%, ${alpha(primaryMain, 0.04)} 100%)`, + boxShadow: `0 8px 32px ${alpha(primaryMain, 0.12)}, 0 4px 16px ${alpha(primaryMain, 0.06)}, 0 2px 8px rgba(0,0,0,0.04)`, + border: `1px solid ${alpha(primaryMain, 0.15)}`, overflow: 'visible' }} > - + {t('result.title')} @@ -308,8 +334,8 @@ export default function SmartFertilizationRecommendation() { setReasoningExpanded(!reasoningExpanded)} className='w-full flex items-center justify-between px-4 py-3 text-start cursor-pointer' - sx={{ '&:hover': { bgcolor: 'rgba(34, 197, 94, 0.06)' } }} + sx={{ '&:hover': { bgcolor: alpha(primaryMain, 0.06) } }} > - + {t('result.whyRecommendation')} @@ -355,21 +382,19 @@ export default function SmartFertilizationRecommendation() { className='mb-6 animate-fade-in' sx={{ borderRadius: '28px', - background: - 'linear-gradient(160deg, #ffffff 0%, #f0fdf4 100%)', - boxShadow: '0 8px 32px rgba(34, 197, 94, 0.1)', - border: '1px solid rgba(34, 197, 94, 0.12)' + background: `linear-gradient(160deg, ${paperBg} 0%, ${alpha(primaryMain, 0.06)} 100%)`, + boxShadow: `0 8px 32px ${alpha(primaryMain, 0.1)}`, + border: `1px solid ${alpha(primaryMain, 0.12)}` }} > - + {t('generating')} @@ -378,41 +403,6 @@ export default function SmartFertilizationRecommendation() { )} - - {/* 5) Primary CTA Button - Sticky */} - - - ) } @@ -428,17 +418,18 @@ function FarmBadge({ label: string value: string }) { + const theme = useTheme() + const primaryMain = theme.palette.primary.main return ( - + {label} @@ -462,6 +453,10 @@ function CropCard({ selected: boolean onClick: () => void }) { + const theme = useTheme() + const primaryMain = theme.palette.primary.main + const primaryDark = theme.palette.primary.dark + const paperBg = theme.palette.background.paper return ( @@ -489,23 +484,24 @@ function CropCard({ className='w-11 h-11 rounded-xl flex items-center justify-center shrink-0 transition-all duration-300' sx={{ background: selected - ? 'linear-gradient(135deg, #22c55e 0%, #16a34a 100%)' - : 'linear-gradient(145deg, rgba(34, 197, 94, 0.1) 0%, rgba(124, 58, 237, 0.05) 100%)' + ? `linear-gradient(135deg, ${primaryMain} 0%, ${primaryDark} 100%)` + : `linear-gradient(145deg, ${alpha(primaryMain, 0.1)} 0%, ${alpha(primaryMain, 0.05)} 100%)` }} > {label} {selected && ( - + )} ) @@ -520,15 +516,17 @@ function PrescriptionRow({ label: string value: string }) { + const theme = useTheme() + const primaryMain = theme.palette.primary.main return ( - + {label} diff --git a/src/views/dashboards/farm/smartIrrigation/SmartIrrigationRecommendation.tsx b/src/views/dashboards/farm/smartIrrigation/SmartIrrigationRecommendation.tsx index 826eed7..993f7e3 100644 --- a/src/views/dashboards/farm/smartIrrigation/SmartIrrigationRecommendation.tsx +++ b/src/views/dashboards/farm/smartIrrigation/SmartIrrigationRecommendation.tsx @@ -9,6 +9,7 @@ import Typography from '@mui/material/Typography' import Button from '@mui/material/Button' import IconButton from '@mui/material/IconButton' import CircularProgress from '@mui/material/CircularProgress' +import { useTheme, alpha } from '@mui/material/styles' // Types interface FarmInfo { @@ -60,10 +61,16 @@ function generateIrrigationPlan(_cropId: string, _farmInfo: FarmInfo): Irrigatio export default function SmartIrrigationRecommendation() { const t = useTranslations('irrigation') + const theme = useTheme() const [farmInfo] = useState(DEFAULT_FARM_INFO) const [selectedCrop, setSelectedCrop] = useState(null) const [plan, setPlan] = useState(null) const [loading, setLoading] = useState(false) + const primaryMain = theme.palette.primary.main + const primaryLight = theme.palette.primary.light + const primaryDark = theme.palette.primary.dark + const bgDefault = theme.palette.background.default + const paperBg = theme.palette.background.paper const handleGenerate = () => { if (!selectedCrop) return @@ -78,9 +85,10 @@ export default function SmartIrrigationRecommendation() { return ( + `linear-gradient(165deg, ${alpha(theme.palette.primary.main, 0.08)} 0%, ${alpha(theme.palette.primary.main, 0.04)} 35%, ${alpha(theme.palette.primary.main, 0.02)} 70%, ${theme.palette.background.default} 100%)`, minHeight: '100vh' }} > @@ -91,7 +99,7 @@ export default function SmartIrrigationRecommendation() { variant='h4' className='font-bold tracking-tight' sx={{ - background: 'linear-gradient(135deg, #0ea5e9 0%, #0284c7 50%, #0369a1 100%)', + background: `linear-gradient(135deg, ${primaryLight} 0%, ${primaryMain} 50%, ${primaryDark} 100%)`, backgroundClip: 'text', WebkitBackgroundClip: 'text', color: 'transparent', @@ -111,9 +119,9 @@ export default function SmartIrrigationRecommendation() { className='mb-6 overflow-hidden transition-all duration-300 hover:shadow-lg' sx={{ borderRadius: '24px', - background: 'linear-gradient(145deg, #ffffff 0%, #f8fcff 100%)', - boxShadow: '0 4px 24px rgba(14, 165, 233, 0.08), 0 1px 3px rgba(0,0,0,0.04)', - border: '1px solid rgba(14, 165, 233, 0.12)' + background: `linear-gradient(145deg, ${paperBg} 0%, ${alpha(primaryMain, 0.04)} 100%)`, + boxShadow: `0 4px 24px ${alpha(primaryMain, 0.08)}, 0 1px 3px rgba(0,0,0,0.04)`, + border: `1px solid ${alpha(primaryMain, 0.12)}` }} > @@ -125,7 +133,7 @@ export default function SmartIrrigationRecommendation() { `linear-gradient(135deg, ${t.palette.success.main} 0%, ${t.palette.success.dark} 100%)`, color: 'white', display: 'flex', alignItems: 'center', @@ -152,7 +160,7 @@ export default function SmartIrrigationRecommendation() { {t('plantSelection.title')} - + {CROP_OPTIONS.map(crop => ( + {/* 4) Primary CTA Button - End of form */} + + + + {/* 5) Result Card (after click) */} {plan && ( @@ -171,9 +206,9 @@ export default function SmartIrrigationRecommendation() { elevation={0} sx={{ borderRadius: '24px', - background: 'linear-gradient(160deg, #ffffff 0%, #f0f9ff 100%)', - boxShadow: '0 8px 32px rgba(14, 165, 233, 0.15), 0 2px 8px rgba(0,0,0,0.06)', - border: '1px solid rgba(14, 165, 233, 0.18)', + background: `linear-gradient(160deg, ${paperBg} 0%, ${alpha(primaryMain, 0.06)} 100%)`, + boxShadow: `0 8px 32px ${alpha(primaryMain, 0.15)}, 0 2px 8px rgba(0,0,0,0.06)`, + border: `1px solid ${alpha(primaryMain, 0.18)}`, overflow: 'visible' }} > @@ -187,7 +222,7 @@ export default function SmartIrrigationRecommendation() { cy={60} r={52} fill='none' - stroke='rgba(14, 165, 233, 0.12)' + stroke={alpha(primaryMain, 0.12)} strokeWidth={10} /> - - + + @@ -212,7 +247,7 @@ export default function SmartIrrigationRecommendation() { className='absolute inset-0 flex flex-col items-center justify-center' sx={{ top: 0, left: 0, right: 0, bottom: 0 }} > - + {plan.moistureLevel}% @@ -274,13 +309,13 @@ export default function SmartIrrigationRecommendation() { className='mb-6' sx={{ borderRadius: '24px', - background: 'linear-gradient(160deg, #ffffff 0%, #f0f9ff 100%)', - boxShadow: '0 8px 32px rgba(14, 165, 233, 0.1)', - border: '1px solid rgba(14, 165, 233, 0.12)' + background: `linear-gradient(160deg, ${paperBg} 0%, ${alpha(primaryMain, 0.06)} 100%)`, + boxShadow: `0 8px 32px ${alpha(primaryMain, 0.1)}`, + border: `1px solid ${alpha(primaryMain, 0.12)}` }} > - + {t('generating')} @@ -288,38 +323,6 @@ export default function SmartIrrigationRecommendation() { )} - - {/* 4) Primary CTA Button - Sticky */} - - - ) } @@ -335,16 +338,18 @@ function FarmBadge({ label: string value: string }) { + const theme = useTheme() + const primaryMain = theme.palette.primary.main return ( - + {label} @@ -368,6 +373,10 @@ function CropCard({ selected: boolean onClick: () => void }) { + const theme = useTheme() + const primaryMain = theme.palette.primary.main + const primaryDark = theme.palette.primary.dark + const paperBg = theme.palette.background.paper return ( @@ -395,17 +404,17 @@ function CropCard({ className='w-11 h-11 rounded-xl flex items-center justify-center shrink-0' sx={{ background: selected - ? 'linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%)' - : 'linear-gradient(145deg, rgba(14, 165, 233, 0.1) 0%, rgba(14, 165, 233, 0.05) 100%)' + ? `linear-gradient(135deg, ${primaryMain} 0%, ${primaryDark} 100%)` + : `linear-gradient(145deg, ${alpha(primaryMain, 0.1)} 0%, ${alpha(primaryMain, 0.05)} 100%)` }} > - + {label} {selected && ( - + )} ) @@ -420,9 +429,11 @@ function ResultRow({ label: string value: string }) { + const theme = useTheme() + const primaryMain = theme.palette.primary.main return ( - - + + {label}