/* ——— Shared icon set (line, brass-stroke) ——— */
const Icon = {
  Metro: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <rect x="5" y="3" width="14" height="14" rx="3" />
      <path d="M5 12h14" /><circle cx="9" cy="14.5" r="0.8" fill="currentColor" /><circle cx="15" cy="14.5" r="0.8" fill="currentColor" />
      <path d="M8 17l-2 4M16 17l2 4" />
    </svg>
  ),
  Shuttle: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M2 17h2l1-9c.2-1.5 1.4-2.5 2.9-2.5H17c1.7 0 3 1.3 3 3v8.5h2" />
      <circle cx="7" cy="17" r="2" /><circle cx="17" cy="17" r="2" />
      <path d="M5 10h13" />
    </svg>
  ),
  Halal: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M12 3l1.8 4 4.4.4-3.3 3 1 4.3L12 12.7 8.1 14.7l1-4.3-3.3-3L10.2 7 12 3z" />
    </svg>
  ),
  Pool: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M3 17c1.5-1 3-1 4.5 0s3 1 4.5 0 3-1 4.5 0 3 1 4.5 0" />
      <path d="M3 20c1.5-1 3-1 4.5 0s3 1 4.5 0 3-1 4.5 0 3 1 4.5 0" />
      <path d="M8 14V6a2 2 0 0 1 4 0M12 14V6a2 2 0 0 1 4 0" />
    </svg>
  ),
  Gym: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M6 9v6M3 11v2M9 6v12M15 6v12M21 11v2M18 9v6" />
      <path d="M9 12h6" />
    </svg>
  ),
  Sauna: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M5 21V8l7-5 7 5v13" /><path d="M5 13h14M5 17h14" />
      <path d="M10 6c.5 1-.5 1.5 0 2.5M12.5 5.5c.5 1-.5 1.5 0 2.5M15 6c.5 1-.5 1.5 0 2.5" />
    </svg>
  ),
  Spa: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M12 14c-4-4-7-3-7-3s0 4 3 5c-1 1-1 3-1 3M12 14c4-4 7-3 7-3s0 4-3 5c1 1 1 3 1 3" />
      <path d="M9 22h6" />
    </svg>
  ),
  Banquet: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M3 21h18M5 21V11a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v10M9 9V5a3 3 0 0 1 6 0v4M12 13v4" />
    </svg>
  ),
  Conference: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <rect x="3" y="6" width="18" height="12" rx="2" /><path d="M7 11h6M7 14h4M16 13l3 0M16 11l3 0" />
    </svg>
  ),
  Wifi: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M2 9c5.5-5 14.5-5 20 0M5 12.5c3.5-3 10.5-3 14 0M8 16c2-1.5 6-1.5 8 0" />
      <circle cx="12" cy="19.5" r="1.2" fill="currentColor" stroke="none" />
    </svg>
  ),
  Bed: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M3 18V8M3 14h18v4M21 14v-2a3 3 0 0 0-3-3h-7v5" /><circle cx="7" cy="11.5" r="1.5" />
    </svg>
  ),
  User: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <circle cx="12" cy="8" r="3.5" /><path d="M5 20c0-3.5 3-6 7-6s7 2.5 7 6" />
    </svg>
  ),
  Square: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <rect x="4" y="4" width="16" height="16" /><path d="M8 4v4M4 8h4M16 20v-4M20 16h-4" />
    </svg>
  ),
  Phone: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A15 15 0 0 1 3 6a2 2 0 0 1 2-2z" />
    </svg>
  ),
  Mail: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <rect x="3" y="5" width="18" height="14" rx="2" /><path d="M3 7l9 6 9-6" />
    </svg>
  ),
  Pin: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M12 22s7-7 7-12a7 7 0 0 0-14 0c0 5 7 12 7 12z" /><circle cx="12" cy="10" r="2.5" />
    </svg>
  ),
  Star: (p) => (
    <svg viewBox="0 0 24 24" fill="currentColor" {...p}>
      <path d="M12 2l2.9 6.6 7.1.6-5.4 4.8 1.7 7L12 17.3 5.7 21l1.7-7L2 9.2l7.1-.6L12 2z" />
    </svg>
  ),
  Arrow: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M5 12h14M13 6l6 6-6 6" />
    </svg>
  ),
  Check: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" {...p}>
      <path d="M5 12l5 5 9-10" />
    </svg>
  ),
  X: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M6 6l12 12M18 6L6 18" />
    </svg>
  ),
  Menu: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M4 7h16M4 12h16M4 17h16" />
    </svg>
  ),
  Calendar: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <rect x="3" y="5" width="18" height="16" rx="2" /><path d="M3 10h18M8 3v4M16 3v4" />
    </svg>
  ),
  Minus: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" {...p}><path d="M5 12h14" /></svg>,
  Plus: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" {...p}><path d="M12 5v14M5 12h14" /></svg>,
  Globe: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <circle cx="12" cy="12" r="9" /><path d="M3 12h18M12 3a13 13 0 0 1 0 18M12 3a13 13 0 0 0 0 18" />
    </svg>
  ),
};

/* ——— Wordmark ——— */
function Wordmark({ tone = 'cream', size = 'md' }) {
  const color = tone === 'cream' ? 'var(--cream)' : 'var(--ink)';
  const accent = 'var(--brass)';
  const fs = size === 'lg' ? 22 : size === 'sm' ? 14 : 17;
  return (
    <div style={{ display: 'flex', alignItems: 'center', gap: 10, color }}>
      <div style={{ width: 36, height: 36, border: `1px solid ${accent}`, display: 'grid', placeItems: 'center', position: 'relative' }}>
        <span className="font-display" style={{ color: accent, fontSize: 20, lineHeight: 1, fontWeight: 600 }}>L</span>
        <span style={{ position: 'absolute', right: 3, bottom: 3, width: 4, height: 4, background: accent }} />
      </div>
      <div style={{ display: 'flex', flexDirection: 'column', lineHeight: 1 }}>
        <span className="font-display" style={{ fontSize: fs, letterSpacing: '0.04em', fontWeight: 500 }}>LANDMARK</span>
        <span className="font-mono" style={{ fontSize: fs * 0.5, letterSpacing: '0.3em', color: accent, marginTop: 3 }}>GRAND · DEIRA</span>
      </div>
    </div>
  );
}

/* ——— Aggregated Review Badge ——— */
function ReviewBadge({ tone = 'cream', compact = false }) {
  const fg = tone === 'cream' ? 'var(--cream)' : 'var(--ink)';
  const muted = tone === 'cream' ? 'rgba(244,236,220,0.65)' : 'rgba(26,26,26,0.55)';
  const line = tone === 'cream' ? 'var(--line-cream)' : 'var(--line)';
  const rows = [
    { src: 'Agoda', score: '7.9', max: '/ 10', count: '6,322' },
    { src: 'Booking', score: '—', max: '', count: '2,820' },
    { src: 'Tripadvisor', score: '4.0', max: '/ 5', count: '1,127' },
    { src: 'Facebook', score: '68%', max: 'rec.', count: '1,511' },
  ];
  if (compact) {
    return (
      <div style={{ display: 'inline-flex', alignItems: 'center', gap: 12, padding: '10px 16px', border: `1px solid ${line}`, borderRadius: 999, color: fg, fontSize: 13 }}>
        <Icon.Star width="14" height="14" style={{ color: 'var(--brass)' }} />
        <strong style={{ fontWeight: 600 }}>7.9 · 4.0 · 68%</strong>
        <span style={{ color: muted }}>11,780 verified reviews</span>
      </div>
    );
  }
  return (
    <div style={{ border: `1px solid ${line}`, padding: '16px 20px', display: 'flex', gap: 28, color: fg, flexWrap: 'wrap', background: tone === 'cream' ? 'rgba(244,236,220,0.04)' : 'rgba(255,255,255,0.5)' }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 8, paddingRight: 20, borderRight: `1px solid ${line}` }}>
        <Icon.Star width="16" height="16" style={{ color: 'var(--brass)' }} />
        <span className="font-mono" style={{ fontSize: 11, letterSpacing: '0.2em', color: muted }}>VERIFIED · 11,780 REVIEWS</span>
      </div>
      {rows.map((r) => (
        <div key={r.src} style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
          <span className="font-mono" style={{ fontSize: 10, letterSpacing: '0.2em', color: muted, textTransform: 'uppercase' }}>{r.src}</span>
          <span style={{ display: 'flex', alignItems: 'baseline', gap: 4 }}>
            <span className="font-display" style={{ fontSize: 22, fontWeight: 600 }}>{r.score}</span>
            <span style={{ fontSize: 11, color: muted }}>{r.max}</span>
            <span style={{ fontSize: 11, color: muted, marginLeft: 6 }}>· {r.count}</span>
          </span>
        </div>
      ))}
    </div>
  );
}

/* ——— Halal + Shuttle pill badges ——— */
function FeatureBadge({ icon: I, label, sub, tone = 'cream' }) {
  const fg = tone === 'cream' ? 'var(--cream)' : 'var(--ink)';
  const muted = tone === 'cream' ? 'rgba(244,236,220,0.7)' : 'rgba(26,26,26,0.6)';
  const line = tone === 'cream' ? 'var(--line-cream)' : 'var(--line)';
  return (
    <div style={{ display: 'inline-flex', alignItems: 'center', gap: 12, padding: '10px 16px', border: `1px solid ${line}`, borderRadius: 999, color: fg }}>
      <I width="18" height="18" style={{ color: 'var(--brass)' }} />
      <div style={{ display: 'flex', flexDirection: 'column', lineHeight: 1.15 }}>
        <span style={{ fontSize: 13, fontWeight: 500 }}>{label}</span>
        {sub && <span style={{ fontSize: 11, color: muted, marginTop: 2 }}>{sub}</span>}
      </div>
    </div>
  );
}

/* ——— Price-from chip ——— */
function PriceChip({ tone = 'cream' }) {
  const fg = tone === 'cream' ? 'var(--cream)' : 'var(--ink)';
  const muted = tone === 'cream' ? 'rgba(244,236,220,0.7)' : 'rgba(26,26,26,0.6)';
  return (
    <div style={{ display: 'inline-flex', alignItems: 'center', gap: 14, color: fg, padding: '10px 18px', background: 'var(--brass)', color: 'var(--teal-deep)', borderRadius: 4 }}>
      <span className="font-mono" style={{ fontSize: 10, letterSpacing: '0.24em', textTransform: 'uppercase' }}>From</span>
      <div style={{ display: 'flex', alignItems: 'baseline', gap: 6 }}>
        <span className="font-display" style={{ fontSize: 24, fontWeight: 600, lineHeight: 1 }}>AED 115</span>
        <span style={{ fontSize: 11, opacity: 0.75 }}>· USD 25 / night</span>
      </div>
    </div>
  );
}

/* ——— Page-section heading ——— */
function SectionLabel({ eyebrow, title, kicker, tone = 'ink', align = 'left' }) {
  const fg = tone === 'cream' ? 'var(--cream)' : 'var(--ink)';
  const muted = tone === 'cream' ? 'rgba(244,236,220,0.7)' : 'rgba(26,26,26,0.55)';
  return (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 14, textAlign: align, alignItems: align === 'center' ? 'center' : 'flex-start', color: fg }}>
      {eyebrow && (
        <div style={{ display: 'flex', alignItems: 'center', gap: 10, color: 'var(--brass)' }}>
          <span style={{ width: 24, height: 1, background: 'var(--brass)' }} />
          <span className="font-mono" style={{ fontSize: 11, letterSpacing: '0.28em', textTransform: 'uppercase' }}>{eyebrow}</span>
        </div>
      )}
      <h2 className="font-display" style={{ margin: 0, fontSize: 'clamp(28px, 4vw, 46px)', lineHeight: 1.05, fontWeight: 500, maxWidth: 720, textWrap: 'balance' }}>{title}</h2>
      {kicker && <p style={{ margin: 0, fontSize: 15, color: muted, maxWidth: 600, lineHeight: 1.55 }}>{kicker}</p>}
    </div>
  );
}

/* ——— Room Card ——— */
function RoomCard({ room, onCheck }) {
  const sqmMissing = !room.sqm;
  return (
    <article style={{
      background: 'var(--cream-2)', border: '1px solid var(--line)',
      display: 'flex', flexDirection: 'column', overflow: 'hidden',
      transition: 'transform 220ms ease, box-shadow 220ms ease',
    }}
    onMouseEnter={(e) => { e.currentTarget.style.transform = 'translateY(-2px)'; e.currentTarget.style.boxShadow = '0 8px 24px rgba(14,59,58,0.10)'; }}
    onMouseLeave={(e) => { e.currentTarget.style.transform = 'translateY(0)'; e.currentTarget.style.boxShadow = 'none'; }}
    >
      <div style={{ position: 'relative', aspectRatio: '4/3', overflow: 'hidden', background: 'var(--mist)' }}>
        <img src={room.img} alt={room.name} loading="eager" style={{ width: '100%', height: '100%', objectFit: 'cover', filter: 'saturate(0.92)' }} />
        <div style={{ position: 'absolute', top: 12, left: 12, padding: '5px 10px', background: 'var(--teal)', color: 'var(--cream)', fontSize: 11, fontFamily: 'JetBrains Mono', letterSpacing: '0.18em' }}>
          {room.tag}
        </div>
        {room.count != null && (
          <div style={{ position: 'absolute', top: 12, right: 12, padding: '5px 10px', background: 'rgba(255,255,255,0.92)', color: 'var(--ink)', fontSize: 11, fontFamily: 'JetBrains Mono' }}>
            {room.count} keys
          </div>
        )}
      </div>
      <div style={{ padding: 22, display: 'flex', flexDirection: 'column', gap: 16, flex: 1 }}>
        <header style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', gap: 16 }}>
          <div>
            <h3 className="font-display" style={{ margin: 0, fontSize: 26, fontWeight: 500 }}>{room.name}</h3>
            <p style={{ margin: '4px 0 0', fontSize: 13, color: 'rgba(26,26,26,0.6)' }}>{room.tagline}</p>
          </div>
          <div style={{ textAlign: 'right' }}>
            <div className="font-mono" style={{ fontSize: 9, letterSpacing: '0.2em', color: 'rgba(26,26,26,0.5)' }}>FROM</div>
            <div className="font-display" style={{ fontSize: 22, fontWeight: 600, lineHeight: 1, color: 'var(--teal)' }}>{room.priceFrom}</div>
            <div style={{ fontSize: 11, color: 'rgba(26,26,26,0.55)' }}>{room.priceUsd}</div>
          </div>
        </header>

        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3,1fr)', gap: 1, background: 'var(--line)', border: '1px solid var(--line)' }}>
          {/* sqm */}
          <div data-needs-sqm={sqmMissing} className="has-tip" style={{ padding: '10px 8px', background: 'var(--cream-2)', display: 'flex', flexDirection: 'column', gap: 4, alignItems: 'center', cursor: sqmMissing ? 'help' : 'default' }}>
            <Icon.Square width="14" height="14" style={{ color: 'var(--brass)' }} />
            <div className="font-mono" style={{ fontSize: 10, letterSpacing: '0.16em', color: 'rgba(26,26,26,0.55)' }}>SIZE</div>
            <div style={{ fontSize: 13, fontWeight: 500 }}>{room.sqm || <span style={{ color: 'var(--rose)' }}>on request</span>}</div>
            {sqmMissing && <span className="tip">Spec pending from property</span>}
          </div>
          <div style={{ padding: '10px 8px', background: 'var(--cream-2)', display: 'flex', flexDirection: 'column', gap: 4, alignItems: 'center' }}>
            <Icon.User width="14" height="14" style={{ color: 'var(--brass)' }} />
            <div className="font-mono" style={{ fontSize: 10, letterSpacing: '0.16em', color: 'rgba(26,26,26,0.55)' }}>SLEEPS</div>
            <div style={{ fontSize: 13, fontWeight: 500 }}>{room.occupancy}</div>
          </div>
          <div style={{ padding: '10px 8px', background: 'var(--cream-2)', display: 'flex', flexDirection: 'column', gap: 4, alignItems: 'center' }}>
            <Icon.Bed width="14" height="14" style={{ color: 'var(--brass)' }} />
            <div className="font-mono" style={{ fontSize: 10, letterSpacing: '0.16em', color: 'rgba(26,26,26,0.55)' }}>BED</div>
            <div style={{ fontSize: 13, fontWeight: 500, textAlign: 'center' }}>{room.bed}</div>
          </div>
        </div>

        <ul style={{ listStyle: 'none', margin: 0, padding: 0, display: 'flex', flexDirection: 'column', gap: 6 }}>
          {room.amenities.map((a) => (
            <li key={a} style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 13, color: 'rgba(26,26,26,0.75)' }}>
              <Icon.Check width="13" height="13" style={{ color: 'var(--brass)', flexShrink: 0 }} /> {a}
            </li>
          ))}
        </ul>

        <div style={{ marginTop: 'auto', display: 'flex', gap: 10 }}>
          <button onClick={onCheck} className="btn btn-dark btn-sm room-cta" style={{ flex: 1 }}>
            Check rates <Icon.Arrow className="arrow" width="14" height="14" style={{ transition: 'transform 200ms' }} />
          </button>
          <button className="btn btn-ghost btn-sm">Details</button>
        </div>
      </div>
    </article>
  );
}

/* ——— Booking widget (sticky bar) ——— */
function BookingBar({ onSubmit, compact = false }) {
  const [checkIn, setCheckIn] = React.useState('2026-06-12');
  const [checkOut, setCheckOut] = React.useState('2026-06-14');
  const [adults, setAdults] = React.useState(2);
  const [children, setChildren] = React.useState(0);
  const [rooms, setRooms] = React.useState(1);

  const fieldStyle = {
    display: 'flex', flexDirection: 'column', gap: 4, padding: '14px 18px',
    borderRight: '1px solid var(--line-cream)', minWidth: 0, flex: 1,
  };
  const labelStyle = { fontFamily: 'JetBrains Mono', fontSize: 10, letterSpacing: '0.22em', color: 'rgba(244,236,220,0.6)', textTransform: 'uppercase' };
  const inputStyle = {
    background: 'transparent', border: 'none', color: 'var(--cream)', fontFamily: 'inherit', fontSize: 14, outline: 'none', padding: 0,
    fontWeight: 500,
  };

  const Stepper = ({ v, set, min = 0 }) => (
    <div style={{ display: 'inline-flex', alignItems: 'center', gap: 10 }}>
      <button onClick={() => set(Math.max(min, v - 1))} style={{ width: 22, height: 22, border: '1px solid var(--line-cream)', background: 'transparent', color: 'var(--cream)', borderRadius: 999, cursor: 'pointer', display: 'grid', placeItems: 'center' }}><Icon.Minus width="11" height="11" /></button>
      <span style={{ minWidth: 14, textAlign: 'center', fontWeight: 500 }}>{v}</span>
      <button onClick={() => set(v + 1)} style={{ width: 22, height: 22, border: '1px solid var(--line-cream)', background: 'transparent', color: 'var(--cream)', borderRadius: 999, cursor: 'pointer', display: 'grid', placeItems: 'center' }}><Icon.Plus width="11" height="11" /></button>
    </div>
  );

  return (
    <div style={{ background: 'var(--teal-deep)', color: 'var(--cream)', display: 'flex', flexWrap: 'wrap', alignItems: 'stretch', border: '1px solid var(--line-cream)' }}>
      <div style={fieldStyle}>
        <span style={labelStyle}>Check-in</span>
        <input type="date" value={checkIn} onChange={(e) => setCheckIn(e.target.value)} style={inputStyle} />
      </div>
      <div style={fieldStyle}>
        <span style={labelStyle}>Check-out</span>
        <input type="date" value={checkOut} onChange={(e) => setCheckOut(e.target.value)} style={inputStyle} />
      </div>
      <div style={fieldStyle}>
        <span style={labelStyle}>Guests</span>
        <div style={{ display: 'flex', gap: 18, alignItems: 'center', fontSize: 13 }}>
          <span style={{ display: 'flex', alignItems: 'center', gap: 6 }}>Adults <Stepper v={adults} set={setAdults} min={1} /></span>
          <span style={{ display: 'flex', alignItems: 'center', gap: 6, color: 'rgba(244,236,220,0.7)' }}>Children <Stepper v={children} set={setChildren} /></span>
        </div>
      </div>
      <div style={{ ...fieldStyle, borderRight: 'none' }}>
        <span style={labelStyle}>Rooms</span>
        <Stepper v={rooms} set={setRooms} min={1} />
      </div>
      <button onClick={onSubmit} className="btn btn-primary" style={{ borderRadius: 0, padding: '0 32px', minHeight: 78, fontSize: 14, letterSpacing: '0.05em' }}>
        Check rates <Icon.Arrow width="16" height="16" />
      </button>
    </div>
  );
}

/* ——— Booking modal (BE iframe stand-in) ——— */
function BookingModal({ open, onClose }) {
  React.useEffect(() => {
    if (!open) return;
    const onKey = (e) => e.key === 'Escape' && onClose();
    document.addEventListener('keydown', onKey);
    document.body.style.overflow = 'hidden';
    return () => { document.removeEventListener('keydown', onKey); document.body.style.overflow = ''; };
  }, [open, onClose]);

  if (!open) return null;
  return (
    <div role="dialog" aria-modal="true" style={{
      position: 'fixed', inset: 0, background: 'rgba(8,38,36,0.78)', backdropFilter: 'blur(6px)',
      zIndex: 200, display: 'grid', placeItems: 'center', padding: 24,
    }} onClick={onClose}>
      <div onClick={(e) => e.stopPropagation()} style={{
        background: 'var(--cream-2)', width: 'min(960px, 100%)', maxHeight: '92vh', overflow: 'auto',
        animation: 'fadeIn 280ms ease both',
      }}>
        <header style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '20px 28px', borderBottom: '1px solid var(--line)' }}>
          <div>
            <div className="font-mono" style={{ fontSize: 10, letterSpacing: '0.22em', color: 'rgba(26,26,26,0.5)' }}>BOOKING ENGINE</div>
            <h3 className="font-display" style={{ margin: '4px 0 0', fontSize: 24 }}>Reserve direct — Best Rate Guarantee</h3>
          </div>
          <button onClick={onClose} aria-label="Close" style={{ background: 'transparent', border: '1px solid var(--line)', width: 40, height: 40, cursor: 'pointer', display: 'grid', placeItems: 'center' }}><Icon.X width="16" height="16" /></button>
        </header>

        <div style={{ padding: 28, display: 'grid', gridTemplateColumns: '1.2fr 1fr', gap: 24 }}>
          <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
            <div style={{ background: 'var(--teal-deep)', color: 'var(--cream)' }}>
              <BookingBar onSubmit={() => {}} />
            </div>

            <div style={{ border: '1px dashed var(--line)', padding: 20, background: 'rgba(184,137,74,0.08)' }}>
              <div className="font-mono" style={{ fontSize: 10, letterSpacing: '0.22em', color: 'rgba(26,26,26,0.55)', marginBottom: 8 }}>IFRAME EMBED</div>
              <p style={{ margin: 0, fontSize: 13, color: 'rgba(26,26,26,0.65)', lineHeight: 1.6 }}>
                Third-party booking engine (D-EDGE / SiteMinder / Synxis) opens here with date and occupancy pre-filled.
                Marketing shell keeps PCI/PII scope at zero. Direct-only 5–10% discount applied automatically.
              </p>
            </div>

            <ul style={{ listStyle: 'none', margin: 0, padding: 0, display: 'grid', gap: 10 }}>
              {['Best Rate Guarantee — we match any OTA price', '24-hour free cancellation before check-in', 'Direct-only 5–10% discount auto-applied', 'Free airport shuttle on direct rates'].map((p) => (
                <li key={p} style={{ display: 'flex', gap: 10, fontSize: 13 }}>
                  <Icon.Check width="14" height="14" style={{ color: 'var(--brass)', flexShrink: 0, marginTop: 3 }} /> {p}
                </li>
              ))}
            </ul>
          </div>

          <aside style={{ background: 'var(--teal)', color: 'var(--cream)', padding: 24, display: 'flex', flexDirection: 'column', gap: 16 }}>
            <div className="font-mono" style={{ fontSize: 10, letterSpacing: '0.22em', color: 'rgba(244,236,220,0.6)' }}>OR CALL THE PROPERTY</div>
            <a href="tel:+97142740000" className="font-display" style={{ fontSize: 28, color: 'var(--cream)', textDecoration: 'none', fontWeight: 500 }}>+971 4 274 0000</a>
            <div style={{ height: 1, background: 'var(--line-cream)' }} />
            <div className="font-mono" style={{ fontSize: 10, letterSpacing: '0.22em', color: 'rgba(244,236,220,0.6)' }}>OR EMAIL</div>
            <a href="mailto:grand@landmarkhotels.com" style={{ color: 'var(--cream)', textDecoration: 'none', fontSize: 15 }}>grand@landmarkhotels.com</a>
            <div style={{ height: 1, background: 'var(--line-cream)' }} />
            <ReviewBadge compact />
          </aside>
        </div>
      </div>
    </div>
  );
}

/* ——— Top Nav ——— */
function Nav({ page, setPage, onBook }) {
  const [scrolled, setScrolled] = React.useState(false);
  const [open, setOpen] = React.useState(false);
  React.useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 24);
    window.addEventListener('scroll', onScroll, { passive: true });
    return () => window.removeEventListener('scroll', onScroll);
  }, []);

  const links = [
    { id: 'home', label: 'Stay' },
    { id: 'rooms', label: 'Rooms' },
    { id: 'dining', label: 'Dining' },
    { id: 'facilities', label: 'Facilities' },
    { id: 'offers', label: 'Offers' },
    { id: 'location', label: 'Location' },
  ];

  return (
    <header style={{
      position: 'sticky', top: 0, zIndex: 60,
      background: scrolled ? 'rgba(8,38,36,0.92)' : 'transparent',
      backdropFilter: scrolled ? 'blur(12px)' : 'none',
      borderBottom: scrolled ? '1px solid var(--line-cream)' : '1px solid transparent',
      transition: 'background 220ms ease, border-color 220ms ease',
      color: 'var(--cream)',
    }}>
      <div style={{
        maxWidth: 1400, margin: '0 auto', padding: '18px 32px',
        display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 32,
      }}>
        <button onClick={() => setPage('home')} style={{ background: 'transparent', border: 'none', padding: 0, cursor: 'pointer' }}>
          <Wordmark />
        </button>

        <nav style={{ display: 'flex', gap: 28, alignItems: 'center', fontSize: 14 }} className="desktop-nav">
          {links.map((l) => (
            <button
              key={l.id}
              onClick={() => setPage(l.id)}
              data-active={page === l.id}
              className="nav-link"
              style={{ background: 'transparent', border: 'none', color: page === l.id ? 'var(--brass)' : 'inherit', cursor: 'pointer', fontSize: 14, fontWeight: 500 }}
            >{l.label}</button>
          ))}
        </nav>

        <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
          <a href="tel:+97142740000" style={{ color: 'inherit', textDecoration: 'none', display: 'flex', alignItems: 'center', gap: 8, fontSize: 13 }} className="hide-on-mobile">
            <Icon.Phone width="14" height="14" /> +971 4 274 0000
          </a>
          <button onClick={onBook} className="btn btn-primary btn-sm">Book direct</button>
        </div>
      </div>
    </header>
  );
}

/* ——— Footer ——— */
function Footer({ setPage }) {
  return (
    <footer style={{ background: 'var(--teal-deep)', color: 'var(--cream)', padding: '64px 32px 32px' }}>
      <div style={{ maxWidth: 1400, margin: '0 auto', display: 'grid', gridTemplateColumns: '1.4fr 1fr 1fr 1fr', gap: 48 }}>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
          <Wordmark size="lg" />
          <p style={{ fontSize: 14, lineHeight: 1.65, color: 'rgba(244,236,220,0.7)', maxWidth: 320, margin: 0 }}>
            A 4-star hotel in Deira, 100 metres from Union Metro and directly opposite Al Ghurair Centre. 175 rooms and suites, an outdoor pool, a sauna and a gym — and rooms from AED 115 a night.
          </p>
          <ReviewBadge compact />
        </div>
        {[
          { title: 'Stay', items: ['Rooms & Suites', 'Offers', 'Direct-book benefits', 'Free airport shuttle'] },
          { title: 'The hotel', items: ['Dining', 'Facilities', 'Banquet hall', 'Conference rooms'] },
          { title: 'Contact', items: ['+971 4 274 0000', 'grand@landmarkhotels.com', 'Al Riqqa Street, Deira', 'PO Box 42222, Dubai'] },
        ].map((col) => (
          <div key={col.title} style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
            <h4 className="font-mono" style={{ margin: 0, fontSize: 11, letterSpacing: '0.24em', color: 'var(--brass)', textTransform: 'uppercase' }}>{col.title}</h4>
            <ul style={{ listStyle: 'none', margin: 0, padding: 0, display: 'flex', flexDirection: 'column', gap: 10 }}>
              {col.items.map((i) => (
                <li key={i} style={{ fontSize: 13, color: 'rgba(244,236,220,0.85)' }}>{i}</li>
              ))}
            </ul>
          </div>
        ))}
      </div>

      <div style={{ maxWidth: 1400, margin: '48px auto 0', padding: '24px 0 0', borderTop: '1px solid var(--line-cream)', display: 'flex', justifyContent: 'space-between', flexWrap: 'wrap', gap: 16 }}>
        <span style={{ fontSize: 12, color: 'rgba(244,236,220,0.5)' }} className="font-mono">© 2026 Landmark Hotels &amp; Suites · Landmark Zenath Group</span>
        <details style={{ fontSize: 12, color: 'rgba(244,236,220,0.5)' }}>
          <summary style={{ cursor: 'pointer' }} className="font-mono">More Landmark hotels in Deira</summary>
          <div style={{ display: 'flex', gap: 16, marginTop: 12, flexWrap: 'wrap' }}>
            {['Landmark Riqqa', 'Landmark Premier', 'Landmark Summit', 'Landmark Baniyas', 'Landmark Plaza'].map((p) => (
              <span key={p} style={{ color: 'rgba(244,236,220,0.7)' }}>{p}</span>
            ))}
          </div>
        </details>
      </div>
    </footer>
  );
}

/* ——— Sticky mobile CTA bar ——— */
function MobileBar({ onBook }) {
  return (
    <div style={{
      position: 'fixed', bottom: 0, left: 0, right: 0, zIndex: 50,
      background: 'rgba(8,38,36,0.96)', backdropFilter: 'blur(10px)', borderTop: '1px solid var(--line-cream)',
      display: 'none', gap: 8, padding: 10,
    }} className="mobile-bar">
      <a href="tel:+97142740000" className="btn btn-secondary btn-sm" style={{ flex: 1 }}><Icon.Phone width="14" height="14" /> Call</a>
      <button className="btn btn-secondary btn-sm" style={{ flex: 1 }}><Icon.Shuttle width="14" height="14" /> Shuttle</button>
      <button onClick={onBook} className="btn btn-primary btn-sm" style={{ flex: 1.4 }}>Book direct</button>
    </div>
  );
}

/* Export to window */
Object.assign(window, { Icon, Wordmark, ReviewBadge, FeatureBadge, PriceChip, SectionLabel, RoomCard, BookingBar, BookingModal, Nav, Footer, MobileBar });
