// Placeholder screen for upcoming modules
const MODULE_INFO = {
  docs: {
    icon: "Book",
    title: { en: "Docs", es: "Documentación" },
    tag: { en: "Like Notion, built into Vildez", es: "Como Notion, dentro de Vildez" },
    desc: {
      en: "A flexible workspace for your team's knowledge — runbooks, specs, meeting notes, all in one place. Linked to your invoices, clients and tasks.",
      es: "Un espacio flexible para el conocimiento de tu equipo — manuales, specs, notas de reunión, todo en un sitio. Conectado a tus facturas, clientes y tareas."
    },
    feats: [
      { icon: "Edit", t: { en: "Block editor", es: "Editor por bloques" }, d: { en: "Markdown, mentions, embeds and slash commands.", es: "Markdown, menciones, embeds y comandos slash." } },
      { icon: "Users", t: { en: "Real-time", es: "Tiempo real" }, d: { en: "Collaborate with your team without conflicts.", es: "Colabora con tu equipo sin conflictos." } },
      { icon: "Folder", t: { en: "Spaces", es: "Espacios" }, d: { en: "Organize per project, team or company.", es: "Organiza por proyecto, equipo o empresa." } },
    ]
  },
  servers: {
    icon: "Server",
    title: { en: "Servers", es: "Servidores" },
    tag: { en: "Like Vercel, native to Vildez", es: "Como Vercel, nativo en Vildez" },
    desc: {
      en: "Deploy and host your apps directly from your codebase. Custom domains, environments, logs — billed inside your normal Vildez subscription.",
      es: "Despliega y aloja tus apps directamente desde tu código. Dominios, entornos, logs — facturado dentro de tu suscripción Vildez."
    },
    feats: [
      { icon: "Zap", t: { en: "Edge-first", es: "Edge-first" }, d: { en: "Fast by default, on a global edge network.", es: "Rápido por defecto, en una red edge global." } },
      { icon: "Globe", t: { en: "Custom domains", es: "Dominios propios" }, d: { en: "Bring your own domain with auto-SSL.", es: "Trae tu dominio con SSL automático." } },
      { icon: "Eye", t: { en: "Live logs", es: "Logs en vivo" }, d: { en: "Stream and search runtime logs in real time.", es: "Stream y búsqueda de logs en tiempo real." } },
    ]
  },
  tasks: {
    icon: "Kanban",
    title: { en: "Tasks", es: "Tareas" },
    tag: { en: "Like Jira, simpler and faster", es: "Como Jira, más simple y rápido" },
    desc: {
      en: "Boards, sprints, backlogs — built for shipping software. Linked to your team, your docs and your invoices.",
      es: "Tableros, sprints, backlogs — pensado para envíos de producto. Conectado a tu equipo, tus docs y tus facturas."
    },
    feats: [
      { icon: "Kanban", t: { en: "Boards & sprints", es: "Tableros y sprints" }, d: { en: "Run agile workflows without the bloat.", es: "Workflows ágiles sin sobrecarga." } },
      { icon: "Plug", t: { en: "Git-aware", es: "Conoce Git" }, d: { en: "Auto-link issues to commits and PRs.", es: "Vincula issues con commits y PRs." } },
      { icon: "Sparkles", t: { en: "Effort billing", es: "Facturación por esfuerzo" }, d: { en: "Turn closed tickets into client invoices.", es: "Convierte tickets cerrados en facturas." } },
    ]
  },
  chat: {
    icon: "Chat",
    title: { en: "Comms", es: "Comunicación" },
    tag: { en: "Like Teams, focused on work", es: "Como Teams, enfocado al trabajo" },
    desc: {
      en: "Channels, DMs and calls — purpose-built for distributed startups. Threads stay tied to projects and clients.",
      es: "Canales, mensajes directos y llamadas — pensado para startups distribuidas. Los hilos viven junto a proyectos y clientes."
    },
    feats: [
      { icon: "Chat", t: { en: "Channels", es: "Canales" }, d: { en: "Topic, project or client-scoped chats.", es: "Chats por tema, proyecto o cliente." } },
      { icon: "Mail", t: { en: "Inline tasks", es: "Tareas inline" }, d: { en: "Convert any message into a tracked task.", es: "Convierte un mensaje en tarea seguida." } },
      { icon: "Users", t: { en: "Calls & rooms", es: "Llamadas y salas" }, d: { en: "Hop into a room without a calendar invite.", es: "Entra en una sala sin invitación previa." } },
    ]
  },
  automations: {
    icon: "Brain",
    title: { en: "Automations", es: "Automatizaciones" },
    tag: { en: "Like Zapier, native to Vildez", es: "Como Zapier, nativo en Vildez" },
    desc: {
      en: "Wire any module together with no-code flows. Trigger on an invoice, a new client, a task moving column — run AI, send messages, write to other apps.",
      es: "Conecta cualquier módulo con flujos no-code. Dispara con una factura, un cliente nuevo, una tarea que cambia de columna — ejecuta IA, envía mensajes, escribe en otras apps."
    },
    feats: [
      { icon: "Zap", t: { en: "Triggers everywhere", es: "Disparadores en todo" }, d: { en: "Anything that happens in Vildez can start a flow.", es: "Cualquier evento en Vildez puede arrancar un flujo." } },
      { icon: "Sparkles", t: { en: "AI steps", es: "Pasos con IA" }, d: { en: "Drop an LLM block to summarize, classify or draft.", es: "Suelta un bloque LLM para resumir, clasificar o redactar." } },
      { icon: "Plug", t: { en: "Outbound integrations", es: "Integraciones salientes" }, d: { en: "Slack, email, webhooks, Google, Notion — all included.", es: "Slack, email, webhooks, Google, Notion — todo incluido." } },
    ]
  },
  social: {
    icon: "Megaphone",
    title: { en: "Social", es: "RRSS" },
    tag: { en: "Plan, schedule and ship", es: "Planifica, programa y publica" },
    desc: {
      en: "Manage every social channel from one calendar. Draft, approve, schedule and analyze — all linked to your brand kit.",
      es: "Gestiona todos tus canales sociales desde un calendario. Redacta, aprueba, programa y analiza — vinculado a tu kit de marca."
    },
    feats: [
      { icon: "Megaphone", t: { en: "Multi-channel", es: "Multicanal" }, d: { en: "X, LinkedIn, Instagram, TikTok and more.", es: "X, LinkedIn, Instagram, TikTok y más." } },
      { icon: "Clock", t: { en: "Smart scheduling", es: "Programación inteligente" }, d: { en: "Send when your audience is awake.", es: "Publica cuando tu audiencia está activa." } },
      { icon: "TrendUp", t: { en: "Analytics", es: "Analíticas" }, d: { en: "Reach, engagement and conversion in one view.", es: "Alcance, engagement y conversión en una vista." } },
    ]
  },
};

window.PlaceholderScreen = function PlaceholderScreen({ moduleId, t, lang, subTab }) {
  const info = MODULE_INFO[moduleId];
  const Icons = window.Icons;
  const toast = window.useToast();
  if (!info) return <div className="page">Module not found</div>;
  const Icon = Icons[info.icon];
  const onNotify = () => toast(lang === "es" ? "Te avisaremos cuando esté listo." : "We'll notify you when it's ready.", "success");
  const onLearn = () => toast(lang === "es" ? "Próximamente: hoja de ruta detallada." : "Coming soon: detailed roadmap.", "info");

  // Map subnav sections to readable titles per locale
  const subnav = (window.SUBNAVS && window.SUBNAVS[moduleId]) || null;
  const currentSection = subnav?.items.find(it => it.id === subTab) || subnav?.items[0];
  const sectionLabel = currentSection ? (currentSection.label[lang] || currentSection.label.en) : null;
  // Only the first sub-item shows the marketing hero; others show a focused empty-state
  const isDefault = !subTab || subnav?.items[0]?.id === subTab;

  if (!isDefault) {
    return (
      <div className="page">
        <window.PageHeader
          title={`${info.title[lang] || info.title.en} · ${sectionLabel}`}
          subtitle={info.tag[lang] || info.tag.en}
        />
        <div className="empty" style={{ marginTop: 12, padding: "60px 24px" }}>
          <div className="empty-icon"><Icon /></div>
          <h3>{lang === "es" ? `${sectionLabel} llegará pronto` : `${sectionLabel} is coming soon`}</h3>
          <p>{t("soon_desc")}</p>
          <div style={{ display: "flex", gap: 8, marginTop: 12 }}>
            <window.Btn variant="brand" icon={Icons.Bell} onClick={onNotify}>{t("notify_me")}</window.Btn>
          </div>
        </div>
      </div>
    );
  }

  return (
    <div className="page">
      <div className="module-hero stag" style={{ animation: "stagIn 280ms cubic-bezier(0.2,0,0,1) 20ms forwards", opacity: 0 }}>
        <div>
          <div style={{ display: "flex", alignItems: "center", gap: 10, marginBottom: 16 }}>
            <div style={{ width: 40, height: 40, borderRadius: 8, background: "var(--bg-sunken)", border: "1px solid var(--border)", display: "flex", alignItems: "center", justifyContent: "center" }}>
              <Icon style={{ width: 20, height: 20 }} />
            </div>
            <span className="soon-tag">{t("coming_soon")}</span>
          </div>
          <h1>{info.title[lang] || info.title.en}</h1>
          <div style={{ fontSize: 13, color: "var(--text-muted)", fontFamily: "var(--font-mono)", marginBottom: 12 }}>{info.tag[lang] || info.tag.en}</div>
          <p>{info.desc[lang] || info.desc.en}</p>
          <div style={{ display: "flex", gap: 8 }}>
            <window.Btn variant="brand" icon={Icons.Bell} onClick={onNotify}>{t("notify_me")}</window.Btn>
            <window.Btn variant="ghost" icon={Icons.ArrowRight} onClick={onLearn}>{t("learn_more")}</window.Btn>
          </div>
        </div>
        <div className="hero-art">
          {/* abstract preview lines */}
          <svg width="100%" height="100%" viewBox="0 0 220 160" preserveAspectRatio="none">
            <defs>
              <pattern id={`g-${moduleId}`} x="0" y="0" width="8" height="8" patternUnits="userSpaceOnUse">
                <line x1="0" y1="0" x2="0" y2="8" stroke="var(--border)" strokeWidth="0.5" />
              </pattern>
            </defs>
            <rect width="220" height="160" fill={`url(#g-${moduleId})`} />
            <rect x="20" y="22" width="100" height="10" rx="2" fill="var(--border)" />
            <rect x="20" y="40" width="160" height="6" rx="2" fill="var(--border)" opacity="0.6" />
            <rect x="20" y="52" width="140" height="6" rx="2" fill="var(--border)" opacity="0.4" />
            <rect x="20" y="80" width="56" height="56" rx="6" fill="var(--bg-elev)" stroke="var(--border)" />
            <rect x="86" y="80" width="56" height="56" rx="6" fill="var(--bg-elev)" stroke="var(--border)" />
            <rect x="152" y="80" width="48" height="56" rx="6" fill="var(--brand-soft)" stroke="var(--brand-border)" />
          </svg>
        </div>
      </div>

      <div className="feat-grid stag">
        {info.feats.map((f, i) => {
          const FI = Icons[f.icon];
          return (
            <div key={i} className="feat">
              <div className="feat-icon"><FI /></div>
              <h4>{f.t[lang] || f.t.en}</h4>
              <p>{f.d[lang] || f.d.en}</p>
            </div>
          );
        })}
      </div>

      <div className="empty" style={{ marginTop: 32 }}>
        <div className="empty-icon"><Icons.Sparkles /></div>
        <h3>{t("coming_soon")}</h3>
        <p>{t("soon_desc")}</p>
      </div>
    </div>
  );
};

Object.assign(window, { PlaceholderScreen: window.PlaceholderScreen, MODULE_INFO });
