import React from "react";
import { Box, Stack, Typography, Chip, Button, Divider } from "@mui/material";
import PsychologyIcon from "@mui/icons-material/Psychology";
import RefreshIcon from "@mui/icons-material/Refresh";
import EditIcon from "@mui/icons-material/Edit";
import SaveIcon from "@mui/icons-material/Save";
import CloseIcon from "@mui/icons-material/Close";
import MicIcon from "@mui/icons-material/Mic";
import { GlassyCard, glassyCardSx, SecondaryButton } from "../ui";
import { useAnalysisPanel, TabId } from "./AnalysisPanelContext";
import { PodcastEstimate } from "../types";
interface TabConfig {
id: TabId;
label: string;
icon: React.ReactNode;
}
const tabButtonStyles = (isActive: boolean) => ({
background: isActive
? "linear-gradient(135deg, #667eea 0%, #764ba2 100%)"
: "#f8fafc",
color: isActive ? "#fff" : "#475569",
border: isActive
? "none"
: "1px solid #e2e8f0",
borderRadius: 2.5,
px: 2.5,
py: 1.25,
fontSize: "0.8rem",
fontWeight: 600,
textTransform: "none" as const,
transition: "all 0.25s ease",
boxShadow: isActive
? "0 4px 12px rgba(102, 126, 234, 0.3)"
: "0 1px 2px rgba(0, 0, 0, 0.05)",
"&:hover": {
background: isActive
? "linear-gradient(135deg, #764ba2 0%, #667eea 100%)"
: "#e2e8f0",
transform: isActive ? "translateY(-1px)" : "none",
boxShadow: isActive
? "0 6px 16px rgba(102, 126, 234, 0.35)"
: "0 2px 4px rgba(0, 0, 0, 0.08)",
},
"&:active": {
transform: "translateY(0)",
},
});
export const AnalysisPanelLayout: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const {
activeTab,
setActiveTab,
isEditing,
setIsEditing,
editedAnalysis,
setEditedAnalysis,
analysis,
estimate,
onRegenerate,
onUpdateAnalysis,
} = useAnalysisPanel();
const tabs: TabConfig[] = [
{ id: "inputs", label: "Your Inputs", icon: 📥 },
{ id: "audience", label: "Audience & Keywords", icon: 👥 },
{ id: "outline", label: "Outline", icon: 📋 },
{ id: "details", label: "Titles, Hook & CTA", icon: 📄 },
{ id: "takeaways", label: "Takeaways", icon: 💡 },
{ id: "guest", label: "Guest Talking Points", icon: 👤 },
];
const handleSave = () => {
if (editedAnalysis && onUpdateAnalysis) {
onUpdateAnalysis(JSON.parse(JSON.stringify(editedAnalysis)));
}
setIsEditing(false);
};
const handleCancel = () => {
setIsEditing(false);
setEditedAnalysis(JSON.parse(JSON.stringify(analysis)));
};
return (
{/* Header Section */}
Personalize Your Podcast
{/* Estimate Display */}
{estimate && (
Est. Cost: ${estimate.total.toFixed(2)}
{estimate.voiceName && (
}
label={estimate.voiceName}
size="small"
variant="outlined"
sx={{
height: 20,
fontSize: '0.7rem',
color: estimate.isCustomVoice ? "#10b981" : "#6366f1",
borderColor: estimate.isCustomVoice ? "rgba(16, 185, 129, 0.3)" : "rgba(99, 102, 241, 0.2)",
bgcolor: estimate.isCustomVoice ? "rgba(16, 185, 129, 0.05)" : "rgba(99, 102, 241, 0.05)",
'& .MuiChip-icon': { color: estimate.isCustomVoice ? "#10b981" : "#6366f1" }
}}
/>
)}
)}
{/* Regenerate Button */}
}
onClick={onRegenerate}
sx={{
background: "#fff",
border: "1px solid #e2e8f0",
color: "#475569",
fontWeight: 600,
fontSize: "0.8rem",
px: 2,
py: 0.75,
"&:hover": {
background: "#f8fafc",
borderColor: "#cbd5e1",
},
}}
>
Regenerate
{/* Edit/Save/Cancel Buttons */}
{isEditing ? (
}
onClick={handleCancel}
sx={{
color: "#64748b",
fontWeight: 600,
fontSize: "0.8rem",
px: 1.5,
}}
>
Cancel
}
variant="contained"
onClick={handleSave}
sx={{
background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
fontWeight: 600,
fontSize: "0.8rem",
px: 2,
}}
>
Save
) : (
}
onClick={() => setIsEditing(true)}
sx={{
color: "#667eea",
fontWeight: 600,
fontSize: "0.8rem",
px: 1.5,
}}
>
Edit
)}
{/* Tab Navigation */}
{tabs.map((tab) => (
setActiveTab(tab.id)}
sx={tabButtonStyles(activeTab === tab.id)}
>
{tab.icon}
{tab.label}
))}
{/* Content Area - Render children (tab content) */}
{children}
);
};