// TopBar.jsx — Comesa header + category tabs + search + price/cata toggles const TopBar = ({ category, onCategory, categories, counts, showPrices, onTogglePrices, showCata, onToggleCata, esComercial, selectionMode, onToggleSelectionMode, showMenu, onMenu, vw = 1440, search, onSearch, }) => { const narrow = vw < 1280; // move category nav to its own row const compact = vw < 720; // stack tighter, allow wrapping const navEl = ( {categories.map(c => { const active = category === c; const n = counts[c] || 0; return ( onCategory(c)} style={{ position: 'relative', background: 'transparent', border: 0, padding: narrow ? '10px 14px' : '14px 18px', fontFamily: 'Sora', fontWeight: active ? 600 : 500, fontSize: 12, letterSpacing: '0.18em', textTransform: 'uppercase', color: active ? '#FFFFFF' : '#565555', cursor: 'pointer', whiteSpace: 'nowrap', transition: 'color 180ms cubic-bezier(0.4,0,0.2,1)', }} onMouseEnter={(e) => { if (!active) e.currentTarget.style.color = '#EFEDED'; }} onMouseLeave={(e) => { if (!active) e.currentTarget.style.color = '#565555'; }} > {c} {n} {active && ( )} ); })} ); return ( {/* Top row */} {/* Menu button (tablet / mobile) */} {showMenu && { e.currentTarget.style.borderColor = '#4A4A48'; }} onMouseLeave={(e) => { e.currentTarget.style.borderColor = '#3A3A38'; }}> } {/* Brand block */} {!compact && Catálogo Vinos 2026 } {/* Category tabs (inline only when wide) */} {!narrow && navEl} {/* Right cluster: search + toggles */} {/* Search */} onSearch(e.target.value)} placeholder="Buscar vino, variedad, D.O…" style={{ flex: 1, minWidth: 0, background: 'transparent', border: 0, outline: 'none', color: '#FFFFFF', fontFamily: 'Sora', fontWeight: 300, fontSize: 13, }} /> {search && ( onSearch('')} style={{ background: 'transparent', border: 0, color: '#B7B6B6', cursor: 'pointer', padding: 0, lineHeight: 0, }}> )} {/* Herramientas comerciales: precios, cata y modo selección. Una visita sin sesión no las ve, y tampoco recibe los precios del servidor. */} {esComercial && <> >} {/* Category tabs row (tablet / mobile) */} {narrow && navEl} ); }; // Entrada y salida del equipo comercial. Discreto a propósito: el catálogo // público es la cara de Comesa y esto es una puerta de servicio. const AccesoLink = ({ esComercial }) => ( { e.currentTarget.style.color = '#FFFFFF'; e.currentTarget.style.borderColor = '#4A4A48'; }} onMouseLeave={(e) => { e.currentTarget.style.color = esComercial ? '#B7B6B6' : '#565555'; e.currentTarget.style.borderColor = '#2A2A28'; }}> {esComercial ? : <>>} {esComercial ? 'Salir' : 'Acceso comercial'} ); const HeaderToggle = ({ on, onChange, labelOn, labelOff, title }) => { return ( onChange(!on)} aria-pressed={on} title={title} style={{ display: 'flex', alignItems: 'center', gap: 9, background: on ? 'var(--comesa-red)' : '#1D1D1B', border: on ? '1px solid var(--comesa-red)' : '1px solid #3A3A38', padding: '8px 12px', cursor: 'pointer', transition: 'background-color 180ms cubic-bezier(0.4,0,0.2,1), border-color 180ms', }} onMouseEnter={(e) => { if (on) e.currentTarget.style.background = 'var(--accent-hover)'; else { e.currentTarget.style.borderColor = '#4A4A48'; e.currentTarget.style.background = '#2A2A28'; } }} onMouseLeave={(e) => { e.currentTarget.style.background = on ? 'var(--comesa-red)' : '#1D1D1B'; e.currentTarget.style.borderColor = on ? 'var(--comesa-red)' : '#3A3A38'; }} > {/* Capsule visual */} {on ? labelOn : labelOff} ); }; const PriceToggle = ({ on, onChange }) => { return ( onChange(!on)} aria-pressed={on} style={{ display: 'flex', alignItems: 'center', gap: 14, background: on ? 'var(--comesa-red)' : '#1D1D1B', border: on ? '1px solid var(--comesa-red)' : '1px solid #3A3A38', padding: '10px 16px 10px 14px', cursor: 'pointer', transition: 'background-color 180ms cubic-bezier(0.4,0,0.2,1), border-color 180ms', }} onMouseEnter={(e) => { if (on) e.currentTarget.style.background = 'var(--accent-hover)'; else { e.currentTarget.style.borderColor = '#4A4A48'; e.currentTarget.style.background = '#2A2A28'; } }} onMouseLeave={(e) => { e.currentTarget.style.background = on ? 'var(--comesa-red)' : '#1D1D1B'; e.currentTarget.style.borderColor = on ? 'var(--comesa-red)' : '#3A3A38'; }} > {/* Capsule visual */} {on ? 'Precios visibles' : 'Precios ocultos'} {on ? 'Mostrando PVP' : 'Modo presentación'} ); }; window.TopBar = TopBar; window.PriceToggle = PriceToggle; window.HeaderToggle = HeaderToggle;