import { AppShell } from "@/components/app-shell"
import { DashboardHero, DashboardQueueInsights } from "@/components/dashboard/dashboard-hero"
import { DashboardAlertsPanel } from "@/components/dashboard/dashboard-alerts-panel"
import { SiteHeader } from "@/components/site-header"
import { RecentTicketsPanel } from "@/components/tickets/recent-tickets-panel"
import { TicketQueueSummaryCards } from "@/components/tickets/ticket-queue-summary"
import { MyTicketsPanel } from "@/components/tickets/my-tickets-panel"
import { ChartOpenedResolved } from "@/components/charts/chart-opened-resolved"
import { ChartOpenByPriority } from "@/components/charts/chart-open-priority"
import { requireAuthenticatedSession } from "@/lib/auth-server"
import { DashboardSlaRiskPanel } from "@/components/dashboard/dashboard-sla-risk-panel"

export default async function Dashboard() {
  // Garante redirecionamento para /login quando sem sessão (aba anônima, etc.)
  await requireAuthenticatedSession()
  return (
    <AppShell
      header={
        <SiteHeader title="Central de operações" lead="Monitoramento em tempo real" />
      }
    >
      <DashboardHero />
      <div className="grid gap-6 px-4 lg:grid-cols-[minmax(0,1.1fr)_minmax(0,0.9fr)] lg:px-6 lg:[&>*]:min-w-0">
        <div className="flex flex-col gap-6">
          <ChartOpenedResolved />
          <ChartOpenByPriority />
        </div>
        <div className="flex flex-col gap-6">
          <MyTicketsPanel />
          <div className="hidden" aria-hidden="true">
            <RecentTicketsPanel />
          </div>
          <div className="hidden" aria-hidden="true">
            <DashboardAlertsPanel />
          </div>
          <DashboardSlaRiskPanel />
        </div>
      </div>
      <div className="px-4 lg:px-6">
        <TicketQueueSummaryCards />
      </div>
      <DashboardQueueInsights />
    </AppShell>
  )
}

