// Shared data + helpers for 7 Seven Cleaning landing variants
// All three variants pull from the same source of truth.

const SEVEN = {
  brand: '7 Seven Cleaning',
  logo: 'uploads/seven-cleaning-logo.png',
  phone: '+1 (360) 904-4542',
  phoneHref: 'tel:+13609044542',
  location: 'Vancouver, WA · Portland, OR · Across Washington State',
  rating: 4.9,
  reviewCount: 312,
  hourlyRate: 60,
  cities: ['Vancouver', 'Portland', 'Camas', 'Battle Ground', 'Ridgefield', 'Beaverton', 'Hillsboro', 'Tigard', 'Lake Oswego'],

  selling: [
    { icon: 'bolt', title: 'Next-day booking', body: 'Most jobs scheduled within 48 hours. We show up on time, every time.' },
    { icon: 'leaf', title: 'Eco-friendly products', body: 'Plant-based, pet- and kid-safe cleaning supplies — no harsh chemical residue.' },
    { icon: 'shield', title: 'Insured & vetted team', body: 'Licensed, bonded, and background-checked. The same trusted faces every visit.' },
    { icon: 'star', title: '4.9★ on Google', body: '300+ five-star reviews from Vancouver, Portland & beyond. We earn each one.' },
  ],

  services: [
    {
      key: 'deep',
      name: 'Deep Cleaning',
      tagline: 'For when "clean" needs to mean spotless.',
      from: 360,
      img: 'https://images.unsplash.com/photo-1581578731548-c64695cc6952?w=1200&q=80&auto=format&fit=crop',
      bullets: ['Baseboards, vents, blinds', 'Inside oven, fridge & cabinets', 'Detail bathrooms & kitchen'],
    },
    {
      key: 'apartment',
      name: 'Apartment Cleaning',
      tagline: 'Weekly, biweekly or one-time refresh.',
      from: 240,
      img: 'https://images.unsplash.com/photo-1556909114-f6e7ad7d3136?w=1200&q=80&auto=format&fit=crop',
      bullets: ['All living areas dusted & vacuumed', 'Bathrooms scrubbed & sanitized', 'Kitchen surfaces & floors'],
    },
    {
      key: 'moveout',
      name: 'Move-In / Move-Out',
      tagline: 'Get your deposit back. Start fresh.',
      from: 480,
      img: 'https://images.unsplash.com/photo-1600585154340-be6161a56a0c?w=1200&q=80&auto=format&fit=crop',
      bullets: ['Top-to-bottom empty-home clean', 'Inside all cabinets & appliances', 'Walk-through guarantee'],
    },
    {
      key: 'commercial',
      name: 'Commercial / Office',
      tagline: 'After-hours service, fully insured.',
      from: 360,
      img: 'https://images.unsplash.com/photo-1497366216548-37526070297c?w=1200&q=80&auto=format&fit=crop',
      bullets: ['Offices, retail, post-renovation', 'Flexible recurring schedules', 'COI provided on request'],
    },
  ],

  steps: [
    { n: 1, title: 'Tell us about your space', body: 'Pick a service, size, and date. Takes about 60 seconds.' },
    { n: 2, title: 'Get an upfront quote', body: 'We text you a fixed-price estimate. No hidden fees, ever.' },
    { n: 3, title: 'Relax — we handle it', body: 'Our team arrives with everything. You come home to spotless.' },
  ],

  reviews: [
    {
      name: 'Zach Smith',
      city: 'Vancouver, WA',
      avatar: 'https://7sevencleaning.com/wp-content/uploads/2023/12/zach-копия.png',
      body: 'We have had probably 10 different cleaners over the years and have NEVER been as pleased as we are with 7 Seven. They arrived with all their equipment and immediately got to work with an efficient system that left our house spotless.',
      stars: 5,
    },
    {
      name: 'Katie',
      city: 'Portland, OR',
      avatar: 'https://7sevencleaning.com/wp-content/uploads/2023/12/k.png',
      body: 'They arrived less than 48 hours after I contacted them, deep cleaned the entire house in three hours, and left me with a spotless, great smelling home. I\'m kicking myself for not having called them sooner.',
      stars: 5,
    },
    {
      name: 'Brynn Cunningham',
      city: 'Camas, WA',
      avatar: 'https://7sevencleaning.com/wp-content/uploads/2023/12/b.png',
      body: 'Outstanding job cleaning our new home before we moved in. Yana found a time that worked perfectly with our hectic schedule. Don\'t waste your time trying other cleaners — go ahead with 7 Seven.',
      stars: 5,
    },
    {
      name: 'David Zilban',
      city: 'Vancouver, WA',
      avatar: 'https://7sevencleaning.com/wp-content/uploads/2023/12/david-копия.png',
      body: 'Quick to respond to my call, booked a cleaning next day, and the cleaners were friendly, fast, and very thorough. My apartment is spotless.',
      stars: 5,
    },
    {
      name: 'Whitney Morse',
      city: 'Portland, OR',
      avatar: 'https://7sevencleaning.com/wp-content/uploads/2023/12/w.png',
      body: 'So easy to schedule and Yana was incredibly responsive. She sent me a reminder a few days beforehand. The team was kind, up front about timing, and worked around our schedule perfectly.',
      stars: 5,
    },
    {
      name: 'Isam Rashied',
      city: 'Beaverton, OR',
      avatar: 'https://7sevencleaning.com/wp-content/uploads/2023/12/i-150x145.png',
      body: 'Outstanding job on my move-out cleaning. They cleaned everything! Extremely professional, punctual, and thorough. The place looked so good, it made me regret moving out a little.',
      stars: 5,
    },
  ],

  faqs: [
    { q: 'How quickly can you come?', a: 'Most jobs are scheduled within 48 hours. Same-day service is often available — call us and we\'ll do everything we can to fit you in.' },
    { q: 'Do I need to provide supplies?', a: 'No — our team arrives with all eco-friendly cleaning supplies and equipment included. If you prefer we use your products, just let us know.' },
    { q: 'How much does a cleaning cost?', a: 'Most homes run $60/hr per cleaner. A typical 2-bed apartment deep clean is around 3 hours with 2 cleaners. We\'ll give you a fixed quote upfront — no surprises.' },
    { q: 'Are you insured and bonded?', a: 'Yes. We\'re fully licensed, bonded, and insured. Every team member is background-checked and trained in our 7-Seven quality standard.' },
    { q: 'What if I\'m not satisfied?', a: 'We offer a 24-hour re-clean guarantee. If anything isn\'t up to standard, let us know within a day and we\'ll come back at no charge.' },
    { q: 'Do you offer recurring service?', a: 'Yes — weekly, biweekly, and monthly schedules. Recurring clients get 10% off after the first visit.' },
  ],

  badges: ['Licensed & Insured', 'Bonded Cleaners', 'Eco-Friendly', 'Pet-Safe', '24h Guarantee'],
};

// Tiny icon set — used across all variants for consistency.
// strokeWidth/size set via props or defaults.
function Icon({ name, size = 24, stroke = 'currentColor', sw = 1.6, fill = 'none', style }) {
  const p = { width: size, height: size, viewBox: '0 0 24 24', fill, stroke, strokeWidth: sw, strokeLinecap: 'round', strokeLinejoin: 'round', style };
  switch (name) {
    case 'bolt': return <svg {...p}><path d="M13 2 4 14h7l-1 8 9-12h-7l1-8Z"/></svg>;
    case 'leaf': return <svg {...p}><path d="M21 3c0 9-5 14-13 14-3 0-5-1-5-1s1-9 8-12c4-2 10-1 10-1Z"/><path d="M3 21c4-7 7-10 14-13"/></svg>;
    case 'shield': return <svg {...p}><path d="M12 3 4 6v6c0 5 3.5 8.5 8 9 4.5-.5 8-4 8-9V6l-8-3Z"/><path d="m9 12 2 2 4-4"/></svg>;
    case 'star': return <svg {...p} fill={stroke}><path d="m12 2 3.1 6.3 6.9 1-5 4.9 1.2 6.8L12 17.8l-6.2 3.3L7 14.2 2 9.3l6.9-1L12 2Z"/></svg>;
    case 'star-outline': return <svg {...p}><path d="m12 2 3.1 6.3 6.9 1-5 4.9 1.2 6.8L12 17.8l-6.2 3.3L7 14.2 2 9.3l6.9-1L12 2Z"/></svg>;
    case 'check': return <svg {...p}><path d="m5 12 5 5L20 7"/></svg>;
    case 'check-circle': return <svg {...p}><circle cx="12" cy="12" r="10"/><path d="m8 12 3 3 5-6"/></svg>;
    case 'phone': return <svg {...p}><path d="M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3 19.5 19.5 0 0 1-6-6 19.8 19.8 0 0 1-3-8.7A2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1.9.3 1.8.6 2.7a2 2 0 0 1-.4 2.1L8 9.8a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.5 2.7.6a2 2 0 0 1 1.9 2.1Z"/></svg>;
    case 'arrow-right': return <svg {...p}><path d="M5 12h14M13 6l6 6-6 6"/></svg>;
    case 'arrow-up-right': return <svg {...p}><path d="M7 17 17 7M8 7h9v9"/></svg>;
    case 'sparkle': return <svg {...p}><path d="M12 3v4M12 17v4M3 12h4M17 12h4M5.6 5.6l2.8 2.8M15.6 15.6l2.8 2.8M5.6 18.4l2.8-2.8M15.6 8.4l2.8-2.8"/></svg>;
    case 'sparkles': return <svg {...p}><path d="m9 3 1.5 4.5L15 9l-4.5 1.5L9 15l-1.5-4.5L3 9l4.5-1.5L9 3Z"/><path d="M18 13.5 18.9 16l2.5.9-2.5.9L18 20.5l-.9-2.6-2.6-.9 2.6-.9L18 13.5Z"/></svg>;
    case 'home': return <svg {...p}><path d="m3 11 9-8 9 8v10a1 1 0 0 1-1 1h-5v-7H9v7H4a1 1 0 0 1-1-1V11Z"/></svg>;
    case 'building': return <svg {...p}><path d="M4 21V5a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v16"/><path d="M2 21h20M9 7h.01M15 7h.01M9 11h.01M15 11h.01M9 15h.01M15 15h.01"/></svg>;
    case 'truck': return <svg {...p}><path d="M3 6h12v10H3zM15 10h4l3 3v3h-7"/><circle cx="7" cy="18" r="2"/><circle cx="18" cy="18" r="2"/></svg>;
    case 'spray': return <svg {...p}><path d="M9 4h6v4H9zM7 8h10l1 14H6L7 8Z"/><path d="M12 2v2M17 4h2M17 7h3"/></svg>;
    case 'clock': return <svg {...p}><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg>;
    case 'pin': return <svg {...p}><path d="M12 22s8-6.5 8-13a8 8 0 0 0-16 0c0 6.5 8 13 8 13Z"/><circle cx="12" cy="9" r="3"/></svg>;
    case 'calendar': return <svg {...p}><rect x="3" y="5" width="18" height="16" rx="2"/><path d="M3 9h18M8 3v4M16 3v4"/></svg>;
    case 'chevron-down': return <svg {...p}><path d="m6 9 6 6 6-6"/></svg>;
    case 'plus': return <svg {...p}><path d="M12 5v14M5 12h14"/></svg>;
    case 'minus': return <svg {...p}><path d="M5 12h14"/></svg>;
    case 'google': return (
      <svg width={size} height={size} viewBox="0 0 24 24">
        <path fill="#4285F4" d="M22.5 12.3c0-.8-.1-1.6-.2-2.3H12v4.4h5.9a5 5 0 0 1-2.2 3.3v2.7h3.5a10.5 10.5 0 0 0 3.3-8.1Z"/>
        <path fill="#34A853" d="M12 23c3 0 5.5-1 7.3-2.6l-3.5-2.7c-1 .6-2.2 1-3.7 1a6.5 6.5 0 0 1-6.1-4.5H2.3v2.8A11 11 0 0 0 12 23Z"/>
        <path fill="#FBBC04" d="M5.9 14.2A6.5 6.5 0 0 1 5.5 12c0-.8.1-1.5.4-2.2V7H2.3a11 11 0 0 0 0 10l3.6-2.8Z"/>
        <path fill="#EA4335" d="M12 5.5c1.6 0 3 .6 4.2 1.7l3.1-3.1A11 11 0 0 0 12 1a11 11 0 0 0-9.7 6l3.6 2.8A6.5 6.5 0 0 1 12 5.5Z"/>
      </svg>
    );
    default: return null;
  }
}

// Star rating bar
function Stars({ n = 5, size = 14, color = '#F5B400' }) {
  return (
    <span style={{ display: 'inline-flex', gap: 2 }}>
      {Array.from({ length: n }).map((_, i) => (
        <Icon key={i} name="star" size={size} stroke={color} />
      ))}
    </span>
  );
}

const ROLLOVER_TRANSITION = 'transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease, color .18s ease, opacity .18s ease';

function rollover(hoverStyle, restStyle) {
  return {
    onMouseEnter: (e) => Object.assign(e.currentTarget.style, hoverStyle),
    onMouseLeave: (e) => Object.assign(e.currentTarget.style, restStyle),
  };
}

// ─────────────────────────────────────────────────────────────────────────────
// Brand palette system
// Variants drive their primary/accent slots through CSS variables on their root
// wrapper. When a brand palette is provided via BrandContext, those vars are set;
// otherwise each variant's hex fallback (declared at its root) applies.

// Curated palette presets. Each gives primary + accent (+ slightly darker variants).
// "7 Seven Brand" is the cleaning company's site palette: a vivid cyan-teal + sunshine yellow
// — close to 7sevencleaning.com hero / header treatment.
const BRAND_PALETTES = {
  default:        null, // means: let each variant use its native palette
  '7seven':       { label: '7 Seven Bright', primary: '#7EC138', primaryDark: '#5C9226', accent: '#FCEA06', accentDeep: '#D6C800' },
  '7seven-soft':  { label: '7 Seven Soft',   primary: '#97CD5C', primaryDark: '#6FA53A', accent: '#FCEA06', accentDeep: '#D6C800' },
  '7seven-sage':  { label: '7 Seven Sage',   primary: '#86B86E', primaryDark: '#5E8E4C', accent: '#F4DC4A', accentDeep: '#C9B400' },
  navy:           { label: '7 Seven Navy',   primary: '#0E3A6B', primaryDark: '#08254A', accent: '#FCEA06', accentDeep: '#D6C800' },
  forest:         { label: 'Forest Pine',    primary: '#1F6B3A', primaryDark: '#0F4A24', accent: '#E8A93C', accentDeep: '#B8801F' },
  rose:           { label: 'Rose & Plum',    primary: '#9B2C5C', primaryDark: '#6E1A40', accent: '#F4B860', accentDeep: '#C8841A' },
};

const BrandContext = React.createContext(null);
function useBrand() { return React.useContext(BrandContext); }

// Lighten/darken a hex by a percentage (-1..1, negative = darker, positive = lighter)
function shiftHex(hex, pct) {
  if (!hex || hex[0] !== '#') return hex;
  const h = hex.replace('#', '');
  const num = parseInt(h.length === 3 ? h.split('').map(c => c + c).join('') : h, 16);
  let r = (num >> 16) & 0xff;
  let g = (num >> 8) & 0xff;
  let b = num & 0xff;
  const f = pct < 0 ? 1 + pct : 1;
  const add = pct > 0 ? Math.round(255 * pct) : 0;
  r = Math.max(0, Math.min(255, Math.round(r * f) + add));
  g = Math.max(0, Math.min(255, Math.round(g * f) + add));
  b = Math.max(0, Math.min(255, Math.round(b * f) + add));
  return '#' + [r, g, b].map(v => v.toString(16).padStart(2, '0')).join('');
}

// Resolve the active brand object from tweaks state.
//   tweaks.palette = key of BRAND_PALETTES, or 'custom'
//   tweaks.primary / tweaks.accent = used when 'custom'
function resolveBrand(tweaks) {
  if (!tweaks) return null;
  if (tweaks.palette === 'custom') {
    const p = tweaks.primary || '#7EC138';
    const a = tweaks.accent || '#FCEA06';
    return { primary: p, primaryDark: shiftHex(p, -0.3), accent: a, accentDeep: shiftHex(a, -0.25) };
  }
  return BRAND_PALETTES[tweaks.palette] || null;
}

// Build the `--p7-*` CSS var style object, falling back to per-variant defaults.
function brandVars(brand, defaults) {
  const b = brand || {};
  return {
    '--p7-primary':       b.primary       || defaults.primary,
    '--p7-primary-dark':  b.primaryDark   || defaults.primaryDark   || defaults.primary,
    '--p7-accent':        b.accent        || defaults.accent,
    '--p7-accent-deep':   b.accentDeep    || defaults.accentDeep    || defaults.accent,
  };
}

// Expose globals (Babel scripts don't share scope)
Object.assign(window, {
  SEVEN, Icon, Stars,
  ROLLOVER_TRANSITION, rollover,
  BRAND_PALETTES, BrandContext, useBrand, resolveBrand, brandVars, shiftHex,
});
