import React, { useState } from "react";
import { SystemPromptsSettings } from "./settings/SystemPromptsSettings";
import { GitSettings } from "./settings/GitSettings";
import { ModelSettings } from "./settings/ModelSettings";

type SettingsSection = "model" | "system-prompts" | "git";

interface SettingsPageProps {
  onClose: () => void;
}

export function SettingsPage({ onClose }: SettingsPageProps) {
  const [activeSection, setActiveSection] =
    useState<SettingsSection>("model");

  return (
    <div className="settings-overlay">
      {/* Header — matches the main app header height/style */}
      <div className="settings-header">
        <div className="settings-header-left">
          <span className="settings-title">{'⚙'} Settings</span>
        </div>
        <button
          className="settings-close"
          onClick={onClose}
          title="Close settings"
        >
          {'×'}
        </button>
      </div>

      <div className="settings-body">
        {/* Side nav */}
        <nav className="settings-nav">
          <button
            className={`settings-nav-item${
              activeSection === "model" ? " active" : ""
            }`}
            onClick={() => setActiveSection("model")}
          >
            Model
          </button>
          <button
            className={`settings-nav-item${
              activeSection === "system-prompts" ? " active" : ""
            }`}
            onClick={() => setActiveSection("system-prompts")}
          >
            System Prompts
          </button>
          <button
            className={`settings-nav-item${
              activeSection === "git" ? " active" : ""
            }`}
            onClick={() => setActiveSection("git")}
          >
            Git
          </button>
        </nav>

        {/* Content */}
        <div className="settings-content">
          {activeSection === "model" && <ModelSettings />}
          {activeSection === "system-prompts" && <SystemPromptsSettings />}
          {activeSection === "git" && <GitSettings />}
        </div>
      </div>
    </div>
  );
}
