// ContactoV5 — Página de contacto interactiva con estado en vivo y generador de WhatsApp
 
const ContactoV5 = ({ setPage }) => {
  const [sent, setSent] = React.useState(false);
  const [form, setForm] = React.useState({ name: '', email: '', phone: '', msg: '' });
  const [focused, setFocused] = React.useState(null);
  
  // WhatsApp message customizer state
  const [waMessage, setWaMessage] = React.useState('¡Hola Fran! Me gustaría hacer una consulta sobre los tratamientos de belleza...');
 
  const presets = [
    { label: '🌿 Consulta de Tratamientos', text: '¡Hola Fran! Tengo dudas sobre qué tratamiento facial o masaje es el más adecuado para mí. ¿Me podrías asesorar?' },
    { label: '📅 Consultar Horas', text: '¡Hola Fran! Me gustaría saber qué horas disponibles tienes para esta semana para agendar una sesión.' },
    { label: '🎁 Regalar Gift Card', text: '¡Hola Fran! Me interesa regalar una Gift Card de belleza personalizada. ¿Cómo es el proceso de compra?' }
  ];
 
  // Live open status calculation
  const getOpenStatus = () => {
    const now = new Date();
    const day = now.getDay(); // 0: Sun, 1: Mon, ..., 6: Sat
    const hour = now.getHours();
    const minute = now.getMinutes();
    const totalMinutes = hour * 60 + minute;
 
    // Mon, Wed, Fri: 16:00 - 20:00 (960 to 1200 mins)
    if (day === 1 || day === 3 || day === 5) {
      if (totalMinutes >= 960 && totalMinutes < 1200) return true;
    }
    // Tue, Thu: 08:00 - 20:00 (480 to 1200 mins)
    if (day === 2 || day === 4) {
      if (totalMinutes >= 480 && totalMinutes < 1200) return true;
    }
    // Sat: 09:00 - 15:00 (540 to 900 mins)
    if (day === 6) {
      if (totalMinutes >= 540 && totalMinutes < 900) return true;
    }
    return false; // Sunday or closed hours
  };
 
  const isOpen = getOpenStatus();
 
  const fields = [
    { key: 'name', label: 'Nombre completo', type: 'text', placeholder: 'Ej: María González' },
    { key: 'email', label: 'Correo electrónico', type: 'email', placeholder: 'Ej: maria@gmail.com' },
    { key: 'phone', label: 'Teléfono / WhatsApp', type: 'tel', placeholder: 'Ej: +56 9 1234 5678' },
  ];
 
  const IconWhatsApp = () => (
    <svg width="20" height="20" viewBox="0 0 28 28" fill="none" style={{ display: 'inline-block', verticalAlign: 'middle' }}>
      <path d="M14 2C7.37 2 2 7.37 2 14c0 2.12.56 4.1 1.52 5.82L2 26l6.35-1.5C9.9 25.45 11.9 26 14 26c6.63 0 12-5.37 12-12S20.63 2 14 2z" fill="#fff"/>
      <path d="M20 17.5c-.3-.15-1.77-.87-2.04-.97-.28-.1-.48-.15-.68.15-.2.3-.77.97-.94 1.17-.17.2-.35.22-.65.07-.3-.15-1.26-.46-2.4-1.48-.89-.79-1.49-1.77-1.66-2.07-.17-.3-.02-.46.13-.61.13-.13.3-.35.45-.52.15-.17.2-.3.3-.5.1-.2.05-.37-.02-.52-.08-.15-.68-1.63-.93-2.24-.24-.58-.49-.5-.68-.5-.17 0-.37-.03-.57-.03-.2 0-.52.07-.8.37-.27.3-1.04 1.02-1.04 2.47 0 1.46 1.07 2.87 1.22 3.07.15.2 2.1 3.2 5.08 4.49.71.3 1.26.49 1.69.62.71.22 1.36.19 1.87.12.57-.08 1.77-.72 2.02-1.42.25-.7.25-1.3.17-1.42-.07-.12-.27-.2-.57-.35z" fill="#25D366"/>
    </svg>
  );
 
  return (
    <div style={{ minHeight: '100vh', background: '#FAFAF8', paddingTop: 88, paddingBottom: 120 }}>
      <style>{`
        @import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;1,300;1,400&family=Outfit:wght@300;400;500;600&display=swap');
        @keyframes svcFadeUp { from { opacity:0; transform:translateY(40px); } to { opacity:1; transform:translateY(0); } }
        @keyframes pulseDot { 
          0% { transform: scale(0.95); opacity: 0.5; }
          50% { transform: scale(1.1); opacity: 1; }
          100% { transform: scale(0.95); opacity: 0.5; }
        }
        
        .contact5-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 80px; align-items: start; }
        
        .btn-primary-mint {
          background: linear-gradient(135deg, #88C9C1, #6bb5ac) !important;
          color: #fff !important;
          border: none !important;
          padding: 16px 32px !important;
          border-radius: 50px !important;
          font-family: 'Outfit', sans-serif !important;
          font-size: 13px !important;
          font-weight: 600 !important;
          letter-spacing: 2px !important;
          text-transform: uppercase !important;
          cursor: pointer !important;
          transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1) !important;
          box-shadow: 0 4px 15px rgba(136, 201, 193, 0.25) !important;
          display: inline-flex !important;
          align-items: center !important;
          justify-content: center;
          text-decoration: none !important;
        }
        .btn-primary-mint:hover {
          transform: translateY(-2px) !important;
          box-shadow: 0 8px 24px rgba(136, 201, 193, 0.45) !important;
          filter: brightness(1.05) !important;
        }
        
        .btn-wa {
          background: #25D366 !important;
          color: #fff !important;
          border: none !important;
          padding: 16px 32px !important;
          border-radius: 50px !important;
          font-family: 'Outfit', sans-serif !important;
          font-size: 13px !important;
          font-weight: 600 !important;
          letter-spacing: 1.5px !important;
          text-transform: uppercase !important;
          cursor: pointer !important;
          transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1) !important;
          box-shadow: 0 4px 20px rgba(37,211,102,0.3) !important;
          display: inline-flex !important;
          align-items: center !important;
          justify-content: center;
          gap: 10px;
          text-decoration: none !important;
        }
        .btn-wa:hover {
          transform: translateY(-2px) !important;
          box-shadow: 0 8px 24px rgba(37,211,102,0.5) !important;
        }
        
        .input-mint {
          width: 100% !important;
          padding: 16px 20px !important;
          border-radius: 12px !important;
          border: 1px solid rgba(136, 201, 193, 0.3) !important;
          font-family: 'Outfit', sans-serif !important;
          font-size: 15px !important;
          color: #1a1a1a !important;
          background: #fff !important;
          outline: none !important;
          box-sizing: border-box !important;
          transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1) !important;
        }
        .input-mint:focus {
          border-color: #88C9C1 !important;
          box-shadow: 0 0 0 4px rgba(136, 201, 193, 0.15) !important;
        }
        
        .wa-preset-btn {
          background: transparent;
          border: 1px solid rgba(136, 201, 193, 0.4);
          color: #2d6a61;
          padding: 8px 16px;
          border-radius: 30px;
          font-family: 'Outfit', sans-serif;
          font-size: 12px;
          cursor: pointer;
          transition: all 0.25s ease;
        }
        .wa-preset-btn:hover {
          background: rgba(136, 201, 193, 0.1);
          border-color: #88C9C1;
        }
        
        @media(max-width:820px){
          .contact5-grid { grid-template-columns: 1fr !important; gap: 56px !important; }
        }
      `}</style>
 
      {/* ─── Hero Header ─────────────────────────────────────── */}
      <div style={{
        background: 'linear-gradient(135deg, #E8F5F3 0%, #FAFAF8 60%, #FCE8EC 100%)',
        padding: '80px 24px 48px',
        textAlign: 'center',
        borderBottom: '1px solid rgba(136,201,193,0.15)',
        position: 'relative',
        overflow: 'hidden',
        animation: 'svcFadeUp 0.8s cubic-bezier(0.16,1,0.3,1) both'
      }}>
        {/* Background decorative elements */}
        <div style={{
          position: 'absolute',
          top: '-10%',
          right: '-5%',
          width: '200px',
          height: '200px',
          borderRadius: '50%',
          background: 'rgba(244,184,193,0.12)',
          filter: 'blur(40px)',
          pointerEvents: 'none'
        }} />
        <div style={{
          position: 'absolute',
          bottom: '-10%',
          left: '-5%',
          width: '250px',
          height: '250px',
          borderRadius: '50%',
          background: 'rgba(136,201,193,0.12)',
          filter: 'blur(50px)',
          pointerEvents: 'none'
        }} />
        
        <span style={{
          display: 'inline-block',
          background: 'rgba(136, 201, 193, 0.12)',
          color: '#2d6a61',
          padding: '6px 16px',
          borderRadius: '20px',
          fontFamily: "'Outfit', sans-serif",
          fontSize: '12px',
          fontWeight: 700,
          letterSpacing: '2px',
          textTransform: 'uppercase',
          marginBottom: '16px'
        }}>Contacto</span>
        
        <h1 style={{
          fontFamily: "'Cormorant Garamond', serif",
          fontSize: '48px',
          fontWeight: 400,
          fontStyle: 'italic',
          color: '#1a1a1a',
          margin: '0 0 12px',
          lineHeight: 1.2
        }}>Escríbenos</h1>
        
        <p style={{
          fontFamily: "'Outfit', sans-serif",
          fontSize: '16px',
          color: '#666',
          margin: '0 auto',
          maxWidth: '480px',
          fontWeight: 300,
          lineHeight: 1.6
        }}>
          Estamos aquí para resolver tus dudas y ayudarte a agendar tu momento de autocuidado ideal.
        </p>
      </div>
 
      {/* ─── Contact Body Container ──────────────────────────── */}
      <div style={{ maxWidth: 1200, margin: '0 auto', padding: '64px 32px 80px' }}>
        <div className="contact5-grid">
          
          {/* LEFT COLUMN: Live Info & WhatsApp Generator */}
          <div style={{ display: 'flex', flexDirection: 'column', gap: '36px' }}>
            
            {/* Live Status Card */}
            <div style={{ 
              background: '#fff', 
              border: '1px solid rgba(136, 201, 193, 0.25)', 
              borderRadius: '20px', 
              padding: '24px', 
              boxShadow: '0 4px 15px rgba(136,201,193,0.02)',
              display: 'flex',
              alignItems: 'center',
              gap: '16px'
            }}>
              <div style={{ 
                width: '12px', 
                height: '12px', 
                borderRadius: '50%', 
                background: isOpen ? '#25D366' : '#F4B8C1', 
                animation: 'pulseDot 2s infinite ease-in-out',
                flexShrink: 0
              }} />
              <div style={{ fontFamily: "'Outfit', sans-serif", fontSize: '14px', color: '#1a1a1a', fontWeight: 500 }}>
                {isOpen ? (
                  <span><strong style={{ color: '#25D366' }}>Abierto ahora:</strong> Escríbenos y te responderemos de inmediato.</span>
                ) : (
                  <span><strong style={{ color: '#F4B8C1' }}>Cerrado ahora:</strong> Déjanos tu mensaje y te responderemos a primera hora.</span>
                )}
              </div>
            </div>
 
            {/* WhatsApp Interactive Generator */}
            <div style={{ 
              background: '#fff', 
              border: '1px solid rgba(136, 201, 193, 0.25)', 
              borderRadius: '24px', 
              padding: '32px', 
              boxShadow: '0 8px 30px rgba(136,201,193,0.04)' 
            }}>
              <h2 style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: '26px', fontStyle: 'italic', color: '#1a1a1a', marginBottom: '16px' }}>
                WhatsApp Interactivo
              </h2>
              <p style={{ fontFamily: "'Outfit', sans-serif", fontSize: '13px', color: '#666', marginBottom: '24px', lineHeight: 1.5 }}>
                Elige uno de los temas predefinidos para preparar tu mensaje o escribe el tuyo directamente abajo:
              </p>
 
              {/* Presets Grid */}
              <div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px', marginBottom: '24px' }}>
                {presets.map((preset, idx) => (
                  <button 
                    key={idx}
                    onClick={() => setWaMessage(preset.text)}
                    className="wa-preset-btn"
                  >
                    {preset.label}
                  </button>
                ))}
              </div>
 
              {/* Textarea */}
              <div style={{ marginBottom: '24px' }}>
                <textarea 
                  value={waMessage}
                  onChange={e => setWaMessage(e.target.value)}
                  rows={4}
                  style={{
                    width: '100%',
                    padding: '16px',
                    borderRadius: '12px',
                    border: '1px solid rgba(136, 201, 193, 0.3)',
                    fontFamily: "'Outfit', sans-serif",
                    fontSize: '14px',
                    color: '#333',
                    background: '#FAFAF8',
                    resize: 'none',
                    outline: 'none',
                    boxSizing: 'border-box',
                    transition: 'border-color 0.2s'
                  }}
                  onFocus={e => e.target.style.borderColor = '#88C9C1'}
                  onBlur={e => e.target.style.borderColor = 'rgba(136, 201, 193, 0.3)'}
                />
              </div>
 
              <a 
                href={`https://wa.me/56983059044?text=${encodeURIComponent(waMessage)}`}
                target="_blank"
                rel="noopener noreferrer"
                className="btn-wa"
                style={{ width: '100%' }}
              >
                <IconWhatsApp />
                <span>Enviar por WhatsApp</span>
              </a>
            </div>
 
            {/* Info Cards (Dirección, Horarios) */}
            <div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
              {[
                { title: '📍 Dirección', val: 'Mariano Sánchez Fontecilla 11950\nPeñalolén, Santiago, Chile\n(Estacionamiento privado disponible)', href: 'https://maps.google.com/?q=Mariano+Sanchez+Fontecilla+11950+Penalolen' },
                { title: '📸 Instagram', val: '@elartedequererte.fran', href: 'https://instagram.com/elartedequererte.fran' }
              ].map(({ title, val, href }) => (
                <div key={title} style={{ 
                  background: '#fff', 
                  border: '1px solid rgba(136, 201, 193, 0.15)', 
                  borderRadius: '20px', 
                  padding: '24px',
                  boxShadow: '0 4px 15px rgba(0,0,0,0.01)'
                }}>
                  <div style={{ fontFamily: "'Outfit', sans-serif", fontSize: '11px', color: '#88C9C1', letterSpacing: '1.5px', textTransform: 'uppercase', fontWeight: 600, marginBottom: '8px' }}>
                    {title}
                  </div>
                  <a href={href} target="_blank" rel="noopener noreferrer" style={{
                    fontFamily: "'Cormorant Garamond', serif",
                    fontSize: '20px',
                    color: '#1a1a1a',
                    fontWeight: 500,
                    textDecoration: 'none',
                    lineHeight: '1.5',
                    whiteSpace: 'pre-line',
                    transition: 'color 0.2s'
                  }}
                    onMouseEnter={e => e.target.style.color = '#88C9C1'}
                    onMouseLeave={e => e.target.style.color = '#1a1a1a'}
                  >
                    {val}
                  </a>
                </div>
              ))}
            </div>
          </div>
 
          {/* RIGHT COLUMN: Contact Form & Schedule Table */}
          <div style={{ display: 'flex', flexDirection: 'column', gap: '36px' }}>
            
            {/* Form Box */}
            <div style={{ 
              background: '#fff', 
              border: '1px solid rgba(136, 201, 193, 0.25)', 
              borderRadius: '24px', 
              padding: '40px 32px', 
              boxShadow: '0 8px 30px rgba(136,201,193,0.04)' 
            }}>
              {sent ? (
                <div style={{ textAlign: 'center', padding: '24px 0' }}>
                  <div style={{ 
                    width: 70, 
                    height: 70, 
                    borderRadius: '50%', 
                    background: '#88C9C1', 
                    display: 'flex', 
                    alignItems: 'center', 
                    justifyContent: 'center', 
                    margin: '0 auto 24px', 
                    color: '#fff', 
                    fontSize: 32,
                    boxShadow: '0 8px 24px rgba(136,201,193,0.3)' 
                  }}>
                    ✓
                  </div>
                  <h2 style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: '32px', fontStyle: 'italic', color: '#1a1a1a', marginBottom: '12px' }}>
                    Mensaje Enviado
                  </h2>
                  <p style={{ fontFamily: "'Outfit', sans-serif", fontSize: '14px', color: '#666', lineHeight: '1.6', marginBottom: '32px' }}>
                    Gracias por escribirnos. Francesca responderá tu consulta muy pronto por correo o WhatsApp.
                  </p>
                  <button 
                    onClick={() => { setSent(false); setForm({ name: '', email: '', phone: '', msg: '' }); }}
                    className="btn-primary-mint"
                  >
                    Enviar otro mensaje
                  </button>
                </div>
              ) : (
                <form onSubmit={e => { e.preventDefault(); setSent(true); }}>
                  <h2 style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: '30px', fontStyle: 'italic', color: '#1a1a1a', marginBottom: '28px', lineHeight: 1.2 }}>
                    Envíanos un mensaje
                  </h2>
 
                  {fields.map(({ key, label, type, placeholder }) => (
                    <div key={key} style={{ marginBottom: '20px' }}>
                      <label style={{ 
                        fontFamily: "'Outfit', sans-serif", 
                        fontSize: '11px', 
                        color: focused === key ? '#88C9C1' : '#777', 
                        textTransform: 'uppercase', 
                        letterSpacing: '1px', 
                        display: 'block', 
                        marginBottom: '8px', 
                        fontWeight: 600,
                        transition: 'color 0.2s' 
                      }}>
                        {label}
                      </label>
                      <input 
                        type={type}
                        placeholder={placeholder}
                        required={key !== 'phone'}
                        value={form[key]}
                        onChange={e => setForm(p => ({ ...p, [key]: e.target.value }))}
                        className="input-mint"
                        onFocus={() => setFocused(key)}
                        onBlur={() => setFocused(null)}
                      />
                    </div>
                  ))}
 
                  <div style={{ marginBottom: '28px' }}>
                    <label style={{ 
                      fontFamily: "'Outfit', sans-serif", 
                      fontSize: '11px', 
                      color: focused === 'msg' ? '#88C9C1' : '#777', 
                      textTransform: 'uppercase', 
                      letterSpacing: '1px', 
                      display: 'block', 
                      marginBottom: '8px', 
                      fontWeight: 600,
                      transition: 'color 0.2s' 
                    }}>
                      Mensaje / Consulta
                    </label>
                    <textarea 
                      rows={4}
                      placeholder="¿En qué podemos ayudarte?"
                      required
                      value={form.msg}
                      onChange={e => setForm(p => ({ ...p, msg: e.target.value }))}
                      className="input-mint"
                      style={{ resize: 'none', borderRadius: '16px' }}
                      onFocus={() => setFocused('msg')}
                      onBlur={() => setFocused(null)}
                    />
                  </div>
 
                  <button type="submit" className="btn-primary-mint" style={{ width: '100%' }}>
                    Enviar mensaje
                  </button>
                </form>
              )}
            </div>
 
            {/* Horarios Card */}
            <div style={{ 
              background: 'linear-gradient(135deg, #ffffff 0%, #FAFAF8 100%)', 
              border: '1px solid rgba(136, 201, 193, 0.25)', 
              borderRadius: '24px', 
              padding: '32px', 
              boxShadow: '0 8px 30px rgba(136,201,193,0.06)' 
            }}>
              <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '24px' }}>
                <div style={{ fontFamily: "'Outfit', sans-serif", fontSize: '11px', color: '#88C9C1', letterSpacing: '2px', textTransform: 'uppercase', fontWeight: 700 }}>
                  Horarios de Atención
                </div>
                <div style={{ width: '40px', height: '1px', background: 'rgba(136, 201, 193, 0.4)' }}/>
              </div>
              
              {[
                { title: 'Lunes, Miércoles y Viernes', time: '16:00 – 20:00 hrs', days: [1,3,5], icon: '🌿' },
                { title: 'Martes y Jueves', time: '08:00 – 20:00 hrs', days: [2,4], icon: '✨' },
                { title: 'Sábados', time: '09:00 – 15:00 hrs', days: [6], icon: '💆‍♀️' },
                { title: 'Domingos y Festivos', time: 'Cerrado', days: [0], icon: '🕊️' }
              ].map((row) => {
                const isToday = row.days.includes(new Date().getDay());
                return (
                  <div key={row.title} style={{ 
                    display: 'flex', 
                    justifyContent: 'space-between', 
                    alignItems: 'center', 
                    padding: '16px', 
                    borderRadius: '16px',
                    marginBottom: '8px',
                    background: isToday ? 'rgba(136, 201, 193, 0.08)' : 'transparent',
                    border: isToday ? '1px solid rgba(136, 201, 193, 0.3)' : '1px solid transparent',
                    boxShadow: isToday ? '0 4px 12px rgba(136,201,193,0.05)' : 'none',
                    transition: 'all 0.3s'
                  }}>
                    <div style={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
                      <span style={{ fontSize: '18px', filter: isToday ? 'none' : 'grayscale(100%) opacity(0.6)' }}>{row.icon}</span>
                      <div style={{ display: 'flex', flexDirection: 'column' }}>
                        <span style={{ fontFamily: "'Outfit', sans-serif", fontSize: '13px', color: isToday ? '#2d6a61' : '#666', fontWeight: isToday ? 700 : 500 }}>
                          {row.title}
                        </span>
                        {isToday && (
                          <span style={{ fontFamily: "'Outfit', sans-serif", fontSize: '9px', color: '#88C9C1', letterSpacing: '1px', textTransform: 'uppercase', fontWeight: 600, marginTop: '2px' }}>
                            Día actual
                          </span>
                        )}
                      </div>
                    </div>
                    <span style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: '18px', fontWeight: 600, color: row.time === 'Cerrado' ? '#F4B8C1' : '#2d6a61', fontStyle: 'italic' }}>
                      {row.time}
                    </span>
                  </div>
                );
              })}
            </div>
          </div>
          
        </div>
      </div>
    </div>
  );
};
 
Object.assign(window, { ContactoV5 });
