//! Container widget demos

use crate::example::Example;
use crate::theme_colors;
use revue::prelude::*;
use revue::widget::{Accordion, AccordionSection, Card, Collapsible};

pub fn examples() -> Vec<Example> {
    let (primary, _success, warning, error, _info, muted, text, _) = theme_colors();

    vec![
        Example::new(
            "Card",
            "Grouped content with header, body, and footer",
            Border::rounded().title(" Card ").child(
                vstack()
                    .gap(1)
                    .child(Card::new()
                        .title("Card Title")
                        .body(Text::new("Card body content goes here. Cards are useful for grouping related content."))
                        .footer(Text::new("Footer").fg(muted)))
                    .child(Text::new(""))
                    .child(Text::new("• Header + body + footer").fg(muted))
                    .child(Text::new("• Grouped content").fg(muted))
                    .child(Text::new("• Shadow/border options").fg(muted)),
            ),
        ),
        Example::new(
            "Collapsible",
            "Expandable and collapsible content sections",
            Border::rounded().title(" Collapsible ").child(
                vstack()
                    .gap(1)
                    .child(Collapsible::new("Section 1")
                        .expanded(true)
                        .content("This section is expanded by default."))
                    .child(Collapsible::new("Section 2")
                        .expanded(false)
                        .content("This section is collapsed."))
                    .child(Collapsible::new("Section 3")
                        .expanded(false)
                        .content("Another collapsed section."))
                    .child(Text::new(""))
                    .child(Text::new("• Expand/collapse").fg(muted))
                    .child(Text::new("• Toggle visibility").fg(muted))
                    .child(Text::new("• Animated transition").fg(muted)),
            ),
        ),
        Example::new(
            "Accordion",
            "Single-expansion accordion for FAQ-style content",
            Border::rounded().title(" Accordion ").child(
                vstack()
                    .gap(1)
                    .child(Accordion::new()
                        .section(
                            AccordionSection::new("FAQ 1: What is Revue?")
                                .content("A Rust TUI framework with 92+ widgets.")
                        )
                        .section(
                            AccordionSection::new("FAQ 2: How many widgets?")
                                .content("92+ widgets available!")
                        )
                        .section(
                            AccordionSection::new("FAQ 3: Is it fast?")
                                .content("Yes, extremely fast!")
                        )
                        .section(
                            AccordionSection::new("FAQ 4: Async support?")
                                .content("Full async/await support.")
                        ))
                    .child(Text::new(""))
                    .child(Text::new("• Single expansion").fg(muted))
                    .child(Text::new("• FAQ pattern").fg(muted))
                    .child(Text::new("• Keyboard navigation").fg(muted)),
            ),
        ),
        Example::new(
            "ScrollView",
            "Scrollable content area for large content",
            Border::rounded().title(" ScrollView ").child(
                vstack()
                    .gap(1)
                    .child(Text::new("Scrollable content:").fg(primary))
                    .child(Text::new("Line 1 - Scroll down").fg(text))
                    .child(Text::new("Line 2").fg(text))
                    .child(Text::new("Line 3").fg(text))
                    .child(Text::new("Line 4").fg(text))
                    .child(Text::new("Line 5").fg(text))
                    .child(Text::new("...more content...").fg(muted))
                    .child(Text::new(""))
                    .child(Text::new("• Virtual scrolling").fg(muted))
                    .child(Text::new("• Large content").fg(muted))
                    .child(Text::new("• Keyboard/mouse").fg(muted)),
            ),
        ),
        Example::new(
            "Container",
            "Generic container with padding and alignment options",
            Border::rounded().title(" Container ").child(
                vstack()
                    .gap(1)
                    .child(Text::new("Generic container:").fg(primary))
                    .child(Border::rounded().child(Text::new("Padded content inside container.")))
                    .child(Text::new(""))
                    .child(Text::new("Centered:").fg(primary))
                    .child(Border::rounded().child(Text::new("Centered content")))
                    .child(Text::new(""))
                    .child(Text::new("• Padding/margin").fg(muted))
                    .child(Text::new("• Alignment options").fg(muted))
                    .child(Text::new("• Border toggle").fg(muted)),
            ),
        ),
        Example::new(
            "Panel",
            "Styled panels with color variants for status display",
            Border::rounded().title(" Panel ").child(
                vstack()
                    .gap(1)
                    .child(Border::rounded().title("Info Panel").child(Text::new("This is an informational panel.")))
                    .child(Border::rounded().title("Warning Panel").fg(warning).child(Text::new("This is a warning panel.")))
                    .child(Border::rounded().title("Error Panel").fg(error).child(Text::new("This is an error panel.")))
                    .child(Text::new(""))
                    .child(Text::new("• Color variants").fg(muted))
                    .child(Text::new("• Status display").fg(muted))
                    .child(Text::new("• Styled containers").fg(muted)),
            ),
        ),
        Example::new(
            "Size Constraints",
            "Cards and collapsibles with min/max sizing",
            Border::rounded().title(" Size Constraints ").child(
                vstack()
                    .gap(1)
                    .child(Text::new("Min/Max sizing:").fg(primary))
                    .child(Card::new()
                        .title("Min 20x3")
                        .body(Text::new("Fixed minimum"))
                        .min_width(20)
                        .min_height(3))
                    .child(Collapsible::new("Constrained")
                        .content("Min 15 width, max 40 width")
                        .min_width(15)
                        .max_width(40))
                    .child(Text::new(""))
                    .child(Text::new("• min_width() / min_height()").fg(muted))
                    .child(Text::new("• max_width() / max_height()").fg(muted))
                    .child(Text::new("• constrain() for all at once").fg(muted)),
            ),
        ),
        Example::new(
            "Constrained Accordion",
            "Accordion with size constraints for overflow handling",
            Border::rounded().title(" Constrained Accordion ").child(
                vstack()
                    .gap(1)
                    .child(Text::new("Size-limited accordion:").fg(primary))
                    .child(Accordion::new()
                        .min_width(25)
                        .max_height(10)
                        .section(
                            AccordionSection::new("Section A")
                                .content("Content for section A with size constraints.")
                        )
                        .section(
                            AccordionSection::new("Section B")
                                .content("Content for section B.")
                        ))
                    .child(Text::new(""))
                    .child(Text::new("• Minimum dimensions").fg(muted))
                    .child(Text::new("• Maximum dimensions").fg(muted))
                    .child(Text::new("• Overflow handling").fg(muted)),
            ),
        ),
        Example::new(
            "Responsive Card",
            "Card with all size constraints set via constrain()",
            Border::rounded().title(" Responsive Card ").child(
                vstack()
                    .gap(1)
                    .child(Text::new("Responsive sizing:").fg(primary))
                    .child(Card::new()
                        .title("Flexible Card")
                        .body(Text::new("Constrained: min 15w, max 30w, min 2h, max 6h"))
                        .constrain(15, 2, 30, 6))
                    .child(Text::new(""))
                    .child(Text::new("• Constrain all at once").fg(muted))
                    .child(Text::new("• Responsive to terminal").fg(muted))
                    .child(Text::new("• Prevent overflow").fg(muted)),
            ),
        ),
    ]
}
