defmodule CentralcloudMy.Layouts do
  use Phoenix.Component

  def render("root.html", assigns) do
    ~H"""
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <meta name="csrf-token" content={Phoenix.Controller.get_csrf_token()}/>
        <title>CentralCloud</title>
        <style>
          * { box-sizing: border-box; margin: 0; padding: 0; }
          body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
                 background: #0f172a; color: #e2e8f0; min-height: 100vh; }
          nav { background: #1e293b; padding: 1rem 2rem; display: flex;
                align-items: center; justify-content: space-between; border-bottom: 1px solid #334155; }
          nav .brand { font-weight: 700; font-size: 1.1rem; color: #38bdf8; }
          nav a { color: #94a3b8; text-decoration: none; margin-left: 1.5rem; font-size: 0.9rem; }
          nav a:hover { color: #e2e8f0; }
          main { padding: 2rem; max-width: 1200px; margin: 0 auto; }
          .flash { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
          .flash-info { background: #1d4ed8; }
          .flash-error { background: #dc2626; }
        </style>
        <.live_title suffix=" — CentralCloud">
          {assigns[:page_title] || "My CentralCloud"}
        </.live_title>
      </head>
      <body>
        <nav>
          <span class="brand">⚡ CentralCloud</span>
          <div>
            <a href="/">Dashboard</a>
            <a href="/dr">DR Status</a>
            <a href="/billing">Billing</a>
            <a href="/support">Support</a>
            <a href="/logout" data-method="delete">Sign out</a>
          </div>
        </nav>
        <main>
          <p :if={msg = Phoenix.Flash.get(@flash, :info)} class="flash flash-info">{msg}</p>
          <p :if={msg = Phoenix.Flash.get(@flash, :error)} class="flash flash-error">{msg}</p>
          {@inner_content}
        </main>
      </body>
    </html>
    """
  end

  def render("app.html", assigns) do
    ~H"""
    {@inner_content}
    """
  end
end
