﻿// Shared UI components — nav, ticker, placeholders, icons

const Placeholder = ({ tone = 'sage', label, img, children, style = {} }) => (
  <div className={`ph ph-${tone}`} style={{ width: '100%', height: '100%', backgroundImage: img ? `url(${img})` : undefined, backgroundSize: 'cover', backgroundPosition: 'center', ...style }}>
    {children}
    {label && !img && <span className="ph-label">{label}</span>}
  </div>
);

const Icon = ({ name, size = 16, stroke = 1.6, color = 'currentColor' }) => {
  const paths = {
    search: <><circle cx="11" cy="11" r="7" /><path d="M20 20l-3.5-3.5" /></>,
    calendar: <><rect x="3" y="5" width="18" height="16" rx="1" /><path d="M3 10h18M8 3v4M16 3v4" /></>,
    user: <><circle cx="12" cy="8" r="4" /><path d="M4 21c0-4.4 3.6-8 8-8s8 3.6 8 8" /></>,
    arrow: <path d="M5 12h14M13 5l7 7-7 7" />,
    arrowLeft: <path d="M19 12H5M11 5l-7 7 7 7" />,
    arrowDown: <path d="M12 5v14M5 13l7 7 7-7" />,
    plus: <path d="M12 5v14M5 12h14" />,
    minus: <path d="M5 12h14" />,
    check: <path d="M5 12l5 5L20 7" />,
    close: <path d="M6 6l12 12M18 6L6 18" />,
    star: <path d="M12 3l2.6 5.6 6.2.7-4.6 4.3 1.2 6.1L12 17l-5.4 2.7 1.2-6.1L3.2 9.3l6.2-.7L12 3z" />,
    heart: <path d="M12 21s-8-4.5-8-11a5 5 0 019-3 5 5 0 019 3c0 6.5-8 11-8 11z" />,
    map: <><path d="M9 4l-6 2v14l6-2 6 2 6-2V4l-6 2-6-2zM9 4v14M15 6v14" /></>,
    clock: <><circle cx="12" cy="12" r="9" /><path d="M12 7v5l3 2" /></>,
    pin: <><path d="M12 21s-7-6.5-7-12a7 7 0 0114 0c0 5.5-7 12-7 12z" /><circle cx="12" cy="9" r="2.5" /></>,
    users: <><circle cx="9" cy="8" r="3.5" /><path d="M2 20c0-3.5 3-6 7-6s7 2.5 7 6" /><path d="M15 5.5a3.5 3.5 0 010 5M22 20c0-2.5-2-4.5-4.5-5" /></>,
    compass: <><circle cx="12" cy="12" r="9" /><path d="M15 9l-1.5 4.5L9 15l1.5-4.5L15 9z" /></>,
    bed: <><path d="M3 18V8M3 13h18v5M21 18v-5c0-1.5-1-2.5-2.5-2.5H11v4.5M8 12.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z" /></>,
    car: <><path d="M5 17v2M19 17v2M4 12l2-5h12l2 5M2 17h20v-5H2v5zM6 14.5a.5.5 0 110-1 .5.5 0 010 1zM18 14.5a.5.5 0 110-1 .5.5 0 010 1z" /></>,
    food: <><path d="M4 3v8a3 3 0 003 3v7M7 3v5M20 3s-3 2-3 6c0 3 1.5 3.5 1.5 3.5V21M4 3h3" /></>,
    camera: <><rect x="3" y="6" width="18" height="14" rx="1" /><path d="M8 6l2-2h4l2 2" /><circle cx="12" cy="13" r="3.5" /></>,
    sun: <><circle cx="12" cy="12" r="4" /><path d="M12 2v2M12 20v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M2 12h2M20 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4" /></>,
    mountain: <path d="M3 20l5-9 4 6 3-4 6 7H3z" />,
    waves: <path d="M2 8c3 0 3 2 6 2s3-2 6-2 3 2 6 2M2 14c3 0 3 2 6 2s3-2 6-2 3 2 6 2" />,
  };
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth={stroke} strokeLinecap="round" strokeLinejoin="round">
      {paths[name]}
    </svg>
  );
};

const Nav = ({ page, setPage, cart = 0 }) => {
  const [drawerOpen, setDrawerOpen] = React.useState(false);
  const [showAuth, setShowAuth] = React.useState(false);
  const [authTab, setAuthTab] = React.useState('signin');
  const [user, setUser] = React.useState(() => { try { return JSON.parse(localStorage.getItem('yt_cuser')); } catch { return null; } });
  const [authForm, setAuthForm] = React.useState({ name: '', email: '', phone: '', password: '' });
  const [authError, setAuthError] = React.useState('');
  const [authLoading, setAuthLoading] = React.useState(false);
  const [showUserMenu, setShowUserMenu] = React.useState(false);
  const [navSs, setNavSs] = React.useState(window.SITE_SETTINGS || {});

  React.useEffect(() => {
    fetch('/api/settings').then(r => r.json()).then(s => { window.SITE_SETTINGS = s; setNavSs(s); }).catch(() => {});
  }, []);

  React.useEffect(() => {
    document.body.style.overflow = (drawerOpen || showAuth) ? 'hidden' : '';
    return () => { document.body.style.overflow = ''; };
  }, [drawerOpen, showAuth]);

  const openAuth = (tab = 'signin') => { setAuthTab(tab); setAuthError(''); setAuthForm({ name: '', email: '', phone: '', password: '' }); setShowAuth(true); };

  const handleAuth = async (e) => {
    e.preventDefault();
    setAuthLoading(true); setAuthError('');
    try {
      const url = authTab === 'signin' ? '/api/customer/login' : '/api/customer/register';
      const body = authTab === 'signin'
        ? { email: authForm.email, password: authForm.password }
        : { name: authForm.name, email: authForm.email, phone: authForm.phone, password: authForm.password };
      const r = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
      const data = await r.json();
      if (!r.ok) { setAuthError(data.error || 'Something went wrong'); setAuthLoading(false); return; }
      localStorage.setItem('yt_ctoken', data.token);
      localStorage.setItem('yt_cuser', JSON.stringify(data.customer));
      setUser(data.customer);
      setShowAuth(false);
    } catch { setAuthError('Network error. Please try again.'); }
    setAuthLoading(false);
  };

  const signOut = () => {
    localStorage.removeItem('yt_ctoken'); localStorage.removeItem('yt_cuser');
    setUser(null); setShowUserMenu(false);
  };

  const navItems = [
    { id: 'home',    label: 'Discover'     },
    { id: 'listing', label: 'All Tours'    },
    { id: 'inquiry', label: 'Tour Inquiry' },
    { id: 'about',   label: 'About'        },
    { id: 'contact', label: 'Contact Us'   },
  ];

  const goTo = (id) => { setPage({ name: id === 'home' ? 'home' : id }); setDrawerOpen(false); };

  const LogoSvg = ({ size = 26 }) => (
    <svg width={size} height={size} viewBox="0 0 40 40" fill="none">
      <circle cx="20" cy="20" r="18" stroke="var(--ink)" strokeWidth="1.5" />
      <path d="M8 20c0-6 6-12 12-12s12 6 12 12" stroke="var(--clay)" strokeWidth="1.5" strokeLinecap="round" fill="none" strokeDasharray="2 3" />
      <circle cx="20" cy="20" r="3" fill="var(--clay)" />
    </svg>
  );

  return (
    <>
      {/* Overlay */}
      <div
        onClick={() => setDrawerOpen(false)}
        style={{
          position: 'fixed', inset: 0, background: 'rgba(26,29,26,0.5)', zIndex: 298,
          opacity: drawerOpen ? 1 : 0,
          pointerEvents: drawerOpen ? 'auto' : 'none',
          transition: 'opacity 0.3s',
        }}
      />

      {/* Left-side mobile drawer */}
      <div style={{
        position: 'fixed', top: 0, left: 0, height: '100vh', width: 280,
        background: 'var(--white)', zIndex: 299, padding: '24px 20px',
        transform: drawerOpen ? 'translateX(0)' : 'translateX(-100%)',
        transition: 'transform 0.3s ease',
        boxShadow: '4px 0 32px rgba(26,29,26,0.18)',
        overflowY: 'auto',
      }}>
        {/* Drawer header */}
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 32 }}>
          <button onClick={() => goTo('home')} style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
            <LogoSvg size={24} />
            <span className="serif" style={{ fontSize: 20, fontWeight: 500, letterSpacing: '-0.02em' }}>
              Roamlly<span style={{ color: 'var(--clay)' }}>.</span>
            </span>
          </button>
          <button onClick={() => setDrawerOpen(false)} style={{ fontSize: 20, color: 'var(--ink)', lineHeight: 1, padding: 4 }}>✕</button>
        </div>

        {/* Nav items */}
        <div style={{ display: 'flex', flexDirection: 'column', gap: 4, marginBottom: 32 }}>
          {navItems.map((item) => (
            <button
              key={item.id}
              onClick={() => goTo(item.id)}
              style={{
                padding: '12px 16px', borderRadius: 8, textAlign: 'left', width: '100%',
                fontSize: 15, fontWeight: page.name === item.id ? 600 : 400,
                color: page.name === item.id ? 'var(--white)' : 'var(--ink)',
                background: page.name === item.id ? 'var(--ink)' : 'transparent',
              }}>
              {item.label}
            </button>
          ))}
        </div>

        {/* Contact */}
        {navSs.contact_phone ? (
          <div style={{ paddingTop: 24, borderTop: '1px solid var(--line)', display: 'flex', flexDirection: 'column', gap: 14, marginBottom: 24 }}>
            <a href={`tel:${navSs.contact_phone}`} style={{ color: 'var(--ink-soft)', fontSize: 13, display: 'flex', alignItems: 'center', gap: 10 }}>
              <Icon name="users" size={13} /> {navSs.contact_phone}
            </a>
            <a href={`https://wa.me/${navSs.contact_phone.replace(/\D/g, '')}`} style={{ color: 'var(--ink-soft)', fontSize: 13, display: 'flex', alignItems: 'center', gap: 10 }}>
              <Icon name="compass" size={13} /> WhatsApp Us
            </a>
          </div>
        ) : null}

        {user ? (
          <div>
            <div style={{ fontSize: 13, fontWeight: 600, marginBottom: 8 }}>{user.name}</div>
            <div style={{ fontSize: 12, color: 'var(--muted)', marginBottom: 12 }}>{user.email}</div>
            <a href="/profile" className="btn btn-ghost" style={{ width: '100%', justifyContent: 'center', marginBottom: 8 }}>My Profile</a>
            <button className="btn btn-ghost" style={{ width: '100%', justifyContent: 'center', color: 'var(--clay)' }} onClick={signOut}>Sign Out</button>
          </div>
        ) : (
          <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
            <button className="btn btn-dark" style={{ width: '100%', justifyContent: 'center' }} onClick={() => { setDrawerOpen(false); openAuth('signup'); }}>
              <Icon name="user" size={14} /> Sign up
            </button>
            <button className="btn btn-ghost" style={{ width: '100%', justifyContent: 'center' }} onClick={() => { setDrawerOpen(false); openAuth('signin'); }}>
              Sign in
            </button>
          </div>
        )}
      </div>

      {/* Auth Modal */}
      {showAuth && (
        <div onClick={(e) => { if (e.target === e.currentTarget) setShowAuth(false); }}
          style={{ position: 'fixed', inset: 0, background: 'rgba(26,29,26,0.6)', zIndex: 400, display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 20 }}>
          <div style={{ background: 'var(--white)', width: '100%', maxWidth: 440, borderRadius: 4, overflow: 'hidden' }}>
            {/* Modal header */}
            <div style={{ display: 'flex', borderBottom: '1px solid var(--line)' }}>
              {[{ id: 'signin', label: 'Sign In' }, { id: 'signup', label: 'Create Account' }].map(t => (
                <button key={t.id} onClick={() => { setAuthTab(t.id); setAuthError(''); }}
                  style={{ flex: 1, padding: '18px 20px', fontSize: 14, fontWeight: authTab === t.id ? 600 : 400, color: authTab === t.id ? 'var(--ink)' : 'var(--muted)', borderBottom: authTab === t.id ? '2px solid var(--ink)' : '2px solid transparent', marginBottom: -1 }}>
                  {t.label}
                </button>
              ))}
              <button onClick={() => setShowAuth(false)} style={{ padding: '18px 20px', color: 'var(--muted)', fontSize: 18 }}>✕</button>
            </div>
            {/* Form */}
            <form onSubmit={handleAuth} style={{ padding: 32 }}>
              {authTab === 'signup' && (
                <label style={{ display: 'block', marginBottom: 16 }}>
                  <span className="mono" style={{ fontSize: 10, letterSpacing: '0.14em', color: 'var(--muted)', textTransform: 'uppercase' }}>Full Name *</span>
                  <input type="text" required value={authForm.name} onChange={e => setAuthForm({ ...authForm, name: e.target.value })} placeholder="Your full name"
                    style={{ width: '100%', marginTop: 6, padding: '10px 12px', border: '1px solid var(--line)', borderRadius: 2, fontSize: 14 }} />
                </label>
              )}
              <label style={{ display: 'block', marginBottom: 16 }}>
                <span className="mono" style={{ fontSize: 10, letterSpacing: '0.14em', color: 'var(--muted)', textTransform: 'uppercase' }}>Email Address *</span>
                <input type="email" required value={authForm.email} onChange={e => setAuthForm({ ...authForm, email: e.target.value })} placeholder="you@email.com"
                  style={{ width: '100%', marginTop: 6, padding: '10px 12px', border: '1px solid var(--line)', borderRadius: 2, fontSize: 14 }} />
              </label>
              {authTab === 'signup' && (
                <label style={{ display: 'block', marginBottom: 16 }}>
                  <span className="mono" style={{ fontSize: 10, letterSpacing: '0.14em', color: 'var(--muted)', textTransform: 'uppercase' }}>Phone Number *</span>
                  <input type="tel" required value={authForm.phone} onChange={e => setAuthForm({ ...authForm, phone: e.target.value })} placeholder="+91 XXXXX XXXXX"
                    style={{ width: '100%', marginTop: 6, padding: '10px 12px', border: '1px solid var(--line)', borderRadius: 2, fontSize: 14 }} />
                </label>
              )}
              <label style={{ display: 'block', marginBottom: 20 }}>
                <span className="mono" style={{ fontSize: 10, letterSpacing: '0.14em', color: 'var(--muted)', textTransform: 'uppercase' }}>Password *</span>
                <input type="password" required minLength={6} value={authForm.password} onChange={e => setAuthForm({ ...authForm, password: e.target.value })} placeholder="Min 6 characters"
                  style={{ width: '100%', marginTop: 6, padding: '10px 12px', border: '1px solid var(--line)', borderRadius: 2, fontSize: 14 }} />
              </label>
              {authError && <div style={{ fontSize: 13, color: 'var(--clay)', marginBottom: 16, padding: '10px 14px', background: '#fff5f5', border: '1px solid #fecaca', borderRadius: 2 }}>{authError}</div>}
              <button type="submit" className="btn btn-dark" style={{ width: '100%', justifyContent: 'center', padding: 14, fontSize: 15 }} disabled={authLoading}>
                {authLoading ? 'Please wait…' : authTab === 'signin' ? 'Sign In' : 'Create Account'}
              </button>
              <div style={{ marginTop: 16, textAlign: 'center', fontSize: 13, color: 'var(--muted)' }}>
                {authTab === 'signin' ? (
                  <>No account? <button type="button" onClick={() => { setAuthTab('signup'); setAuthError(''); }} style={{ color: 'var(--ink)', fontWeight: 600, textDecoration: 'underline' }}>Create one free</button></>
                ) : (
                  <>Already have an account? <button type="button" onClick={() => { setAuthTab('signin'); setAuthError(''); }} style={{ color: 'var(--ink)', fontWeight: 600, textDecoration: 'underline' }}>Sign in</button></>
                )}
              </div>
            </form>
          </div>
        </div>
      )}

      {/* Main nav bar */}
      <nav style={{
        display: 'flex', alignItems: 'center', justifyContent: 'space-between',
        padding: '18px 36px', borderBottom: '1px solid var(--line)',
        background: 'var(--bg)', position: 'sticky', top: 0, zIndex: 20,
      }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 40 }}>
          <button onClick={() => setPage({ name: 'home' })} style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
            <LogoSvg size={26} />
            <span className="serif" style={{ fontSize: 22, fontWeight: 500, letterSpacing: '-0.02em' }}>
              Roamlly<span style={{ color: 'var(--clay)' }}>.</span>
            </span>
          </button>
          <div className="nav-links-desktop" style={{ display: 'flex', gap: 4 }}>
            {navItems.map((item) => (
              <button key={item.id}
                onClick={() => setPage({ name: item.id === 'home' ? 'home' : item.id })}
                style={{
                  padding: '8px 14px', fontSize: 14,
                  color: (page.name === item.id || (item.id === 'home' && page.name === 'home')) ? 'var(--ink)' : 'var(--muted)',
                  fontWeight: page.name === item.id ? 500 : 400,
                  borderBottom: page.name === item.id ? '1px solid var(--ink)' : '1px solid transparent',
                  borderRadius: 0,
                }}>
                {item.label}
              </button>
            ))}
          </div>
        </div>

        <div className="nav-actions" style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
          <button className="btn btn-ghost" onClick={() => setPage({ name: 'listing' })}>
            <Icon name="search" size={15} /> Where to?
          </button>
          <div className="vhairline" style={{ height: 20, margin: '0 6px' }} />
          <button className="btn btn-ghost" style={{ position: 'relative' }} onClick={() => setPage({ name: 'saved' })}>
            <Icon name="heart" size={15} /> Saved
            {cart > 0 && (
              <span style={{
                position: 'absolute', top: 4, right: 4,
                background: 'var(--clay)', color: 'white',
                fontSize: 10, width: 16, height: 16, borderRadius: 8,
                display: 'flex', alignItems: 'center', justifyContent: 'center',
              }}>{cart}</span>
            )}
          </button>
          {user ? (
            <div style={{ position: 'relative' }}>
              <button
                onClick={() => setShowUserMenu(v => !v)}
                style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '7px 14px', border: '1px solid var(--line)', borderRadius: 2, background: 'var(--bg)', fontSize: 14 }}>
                <span style={{ width: 26, height: 26, borderRadius: '50%', background: 'var(--ink)', color: 'var(--white)', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 11, fontWeight: 600 }}>
                  {(user.name || 'U')[0].toUpperCase()}
                </span>
                {user.name.split(' ')[0]}
              </button>
              {showUserMenu && (
                <div style={{ position: 'absolute', top: '110%', right: 0, background: 'var(--white)', border: '1px solid var(--line)', borderRadius: 4, minWidth: 160, boxShadow: '0 8px 24px rgba(0,0,0,0.1)', zIndex: 100 }}>
                  <a href="/profile" style={{ display: 'block', padding: '12px 16px', fontSize: 14, color: 'var(--ink)', borderBottom: '1px solid var(--line)' }}>My Profile</a>
                  <button onClick={signOut} style={{ display: 'block', width: '100%', textAlign: 'left', padding: '12px 16px', fontSize: 14, color: 'var(--clay)' }}>Sign Out</button>
                </div>
              )}
            </div>
          ) : (
            <button className="btn btn-dark" onClick={() => openAuth('signup')}><Icon name="user" size={14} /> Sign up</button>
          )}

          {/* Hamburger — hidden on desktop, shown on mobile via CSS */}
          <button
            className="nav-hamburger"
            onClick={() => setDrawerOpen(true)}
            style={{ display: 'none', flexDirection: 'column', gap: 5, padding: '4px 2px' }}>
            <span style={{ display: 'block', width: 22, height: 2, background: 'var(--ink)', borderRadius: 1 }} />
            <span style={{ display: 'block', width: 22, height: 2, background: 'var(--ink)', borderRadius: 1 }} />
            <span style={{ display: 'block', width: 17, height: 2, background: 'var(--ink)', borderRadius: 1 }} />
          </button>
        </div>
      </nav>
    </>
  );
};

const Ticker = ({ items }) => {
  const content = (
    <>
      {items.map((t, i) => (
        <span key={i} style={{ display: 'inline-flex', alignItems: 'center', gap: 48 }}>
          {t}<span className="ticker-dot">✶</span>
        </span>
      ))}
    </>
  );
  return (
    <div className="ticker-wrap">
      <div className="ticker">
        {content}{content}
      </div>
    </div>
  );
};

const Footer = () => {
  const [ss, setSs] = React.useState(window.SITE_SETTINGS || {});
  React.useEffect(() => {
    fetch('/api/settings').then(r => r.json()).then(s => { window.SITE_SETTINGS = s; setSs(s); }).catch(() => {});
  }, []);

  const colHd = { fontSize: 11, textTransform: 'uppercase', letterSpacing: '0.12em', color: 'rgba(255,255,255,0.45)', marginBottom: 18, fontWeight: 600 };
  const colLink = { fontSize: 14, color: 'rgba(255,255,255,0.8)', lineHeight: 1.4 };

  return (
  <footer style={{ background: 'var(--ink)', color: 'var(--bg)', padding: '80px 36px 32px' }}>
    <div style={{ display: 'grid', gridTemplateColumns: '1.6fr 1fr 1fr 1.4fr', gap: 48, marginBottom: 64 }}>

      {/* 1 — Tagline */}
      <div>
        <div className="serif" style={{ fontSize: 44, fontWeight: 300, lineHeight: 1, marginBottom: 16, letterSpacing: '-0.03em' }}>
          Go somewhere<br /><em style={{ fontStyle: 'italic', color: 'var(--butter)' }}>unhurried.</em>
        </div>
        <div style={{ fontSize: 14, color: 'rgba(255,255,255,0.6)', maxWidth: 300, lineHeight: 1.6 }}>
          Small-group tours across India, from a single afternoon to a full week. Curated by people who actually go.
        </div>
      </div>

      {/* 2 — Useful Links */}
      <div>
        <div className="mono" style={colHd}>Useful Links</div>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
          {[
            { label: 'Privacy Policy',        href: '/privacy' },
            { label: 'Terms & Conditions',    href: '/terms' },
            { label: 'Refund & Cancellation', href: '/cancellation' },
            { label: 'FAQs',                  href: '/faqs' },
          ].map(({ label, href }) => (
            <a key={label} href={href} style={colLink}>{label}</a>
          ))}
        </div>
      </div>

      {/* 3 — Explore */}
      <div>
        <div className="mono" style={colHd}>Explore</div>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
          {[
            { label: 'Home',         page: 'home' },
            { label: 'All Tours',    page: 'listing' },
            { label: 'Tour Inquiry', page: 'inquiry' },
            { label: 'About Us',     page: 'about' },
            { label: 'Contact Us',   page: 'contact' },
          ].map(({ label, page }) => (
            <a key={label} href="#" style={colLink}
              onClick={(e) => { e.preventDefault(); window.__roamllyNav && window.__roamllyNav({ name: page }); window.scrollTo({ top: 0, behavior: 'instant' }); }}>
              {label}
            </a>
          ))}
        </div>
      </div>

      {/* 4 — Company Info */}
      <div>
        <div className="mono" style={colHd}>Company</div>
        <div style={{ fontSize: 13, fontWeight: 700, color: 'rgba(255,255,255,0.9)', marginBottom: 14, lineHeight: 1.4, letterSpacing: '0.01em' }}>
          SCANEX TECHNO MEDIA<br />PRIVATE LIMITED
        </div>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
          {ss.contact_phone && (
            <a href={`tel:${ss.contact_phone}`} style={{ fontSize: 13, color: 'rgba(255,255,255,0.7)', display: 'flex', alignItems: 'flex-start', gap: 8 }}>
              <span style={{ marginTop: 1, opacity: 0.6, flexShrink: 0 }}>✆</span> {ss.contact_phone}
            </a>
          )}
          {ss.contact_email && (
            <a href={`mailto:${ss.contact_email}`} style={{ fontSize: 13, color: 'rgba(255,255,255,0.7)', display: 'flex', alignItems: 'flex-start', gap: 8 }}>
              <span style={{ marginTop: 1, opacity: 0.6, flexShrink: 0 }}>✉</span> {ss.contact_email}
            </a>
          )}
          {ss.contact_address && ss.contact_address.split('\n').filter(Boolean).map((line, i) => (
            <div key={i} style={{ fontSize: 13, color: 'rgba(255,255,255,0.55)', paddingLeft: 20, lineHeight: 1.5 }}>{line}</div>
          ))}
        </div>
      </div>

    </div>

    <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', borderTop: '1px solid rgba(255,255,255,0.12)', paddingTop: 24, flexWrap: 'wrap', gap: 12 }}>
      <div className="mono" style={{ fontSize: 11, color: 'rgba(255,255,255,0.4)', letterSpacing: '0.08em' }}>
        © 2026 Scanex Techno Media Pvt. Ltd. · All rights reserved
      </div>
      <div style={{ display: 'flex', gap: 20 }}>
        {[
          { label: 'Privacy Policy', href: '/privacy' },
          { label: 'Terms', href: '/terms' },
          { label: 'Cancellation', href: '/cancellation' },
        ].map(({ label, href }) => (
          <a key={label} href={href} className="mono" style={{ fontSize: 11, color: 'rgba(255,255,255,0.4)', letterSpacing: '0.08em' }}>{label}</a>
        ))}
      </div>
    </div>
  </footer>
  );
};

Object.assign(window, { Placeholder, Icon, Nav, Ticker, Footer });
