"""Corridor management component.

Provides:
- Upload corridor from CSV file
- List active corridors with toggle visibility
- Corridor pass/fail indicator
"""

from __future__ import annotations

from typing import Any

import dash_bootstrap_components as dbc
from dash import dcc, html


def build_corridor_panel() -> dbc.Card:
    """Build the corridor management panel."""
    return dbc.Card(
        [
            dbc.CardHeader("Corridors", className="fw-bold py-2"),
            dbc.CardBody(
                [
                    dbc.Label("Load Corridor CSV", size="sm", className="mb-1"),
                    html.Div(
                        [
                            html.Span(
                                "Format: time, lower, upper (one header row)",
                                className="text-muted",
                                style={"fontSize": "10px"},
                            ),
                        ],
                        className="mb-1",
                    ),
                    dcc.Upload(
                        id="corridor-upload",
                        children=dbc.Button(
                            "Upload CSV",
                            color="outline-primary",
                            size="sm",
                            className="w-100",
                            style={"fontSize": "11px"},
                        ),
                        multiple=False,
                        accept=".csv,.txt",
                        className="mb-2",
                    ),
                    dbc.Input(
                        id="corridor-name-input",
                        placeholder="Corridor name",
                        size="sm",
                        className="mb-2",
                        style={"fontSize": "12px"},
                    ),
                    html.Hr(style={"margin": "8px 0"}),
                    # Active corridors list
                    dbc.Label("Active Corridors", size="sm", className="mb-1"),
                    html.Div(
                        id="active-corridors-list",
                        children=[
                            html.Div(
                                "No corridors loaded",
                                className="text-muted",
                                style={"fontSize": "10px"},
                            ),
                        ],
                    ),
                    html.Div(id="corridor-status", className="mt-2"),
                    # Hidden store for corridor data
                    dcc.Store(id="corridors-store", data=[]),
                ],
                className="py-2",
            ),
        ],
        className="mb-2",
    )
