Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,9 +3,7 @@ import pandas as pd
|
|
| 3 |
from google.oauth2.service_account import Credentials
|
| 4 |
import gspread
|
| 5 |
from urllib.parse import quote_plus
|
| 6 |
-
import time
|
| 7 |
import base64
|
| 8 |
-
from pathlib import Path
|
| 9 |
|
| 10 |
# --- 1. CONFIGURACIÓN ---
|
| 11 |
st.set_page_config(page_title="ARZON STUDIOS", layout="wide", initial_sidebar_state="collapsed")
|
|
@@ -19,48 +17,46 @@ def get_image_base64(image_path):
|
|
| 19 |
except:
|
| 20 |
return None
|
| 21 |
|
| 22 |
-
# --- 3. CSS MAESTRO
|
| 23 |
st.markdown("""
|
| 24 |
-
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500&family=Inter:wght@300;400;500;600&display=swap" />
|
| 25 |
<style>
|
|
|
|
|
|
|
| 26 |
/* === FORZAR FONDO BLANCO Y TEXTO NEGRO === */
|
| 27 |
-
|
| 28 |
-
[data-testid="stAppViewContainer"], .stApp, header, section {
|
| 29 |
background-color: #ffffff !important;
|
| 30 |
color: #000000 !important;
|
| 31 |
font-family: 'Inter', sans-serif !important;
|
| 32 |
}
|
| 33 |
|
| 34 |
/* Ocultar elementos nativos */
|
| 35 |
-
#MainMenu, footer, header, [data-testid="stToolbar"]
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
/* Ocultar Sidebar nativo visualmente */
|
| 39 |
-
[data-testid="stSidebar"] {
|
| 40 |
-
background-color: #fff !important;
|
| 41 |
-
border-right: 1px solid #eee;
|
| 42 |
}
|
| 43 |
-
|
| 44 |
-
|
| 45 |
/* === BARRA DE NAVEGACIÓN CENTRADA === */
|
| 46 |
.nav-container {
|
| 47 |
display: flex;
|
| 48 |
align-items: center;
|
| 49 |
justify-content: space-between;
|
| 50 |
width: 100%;
|
| 51 |
-
max-width: 1400px;
|
| 52 |
-
margin: 0 auto;
|
| 53 |
padding: 20px 40px;
|
|
|
|
|
|
|
| 54 |
}
|
| 55 |
|
| 56 |
.nav-left, .nav-right {
|
| 57 |
display: flex;
|
| 58 |
align-items: center;
|
| 59 |
-
gap:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
}
|
| 61 |
|
| 62 |
.nav-center {
|
| 63 |
-
flex: 1;
|
| 64 |
text-align: center;
|
| 65 |
}
|
| 66 |
|
|
@@ -69,34 +65,53 @@ st.markdown("""
|
|
| 69 |
height: 24px;
|
| 70 |
cursor: pointer;
|
| 71 |
transition: opacity 0.2s;
|
|
|
|
| 72 |
}
|
| 73 |
|
| 74 |
.nav-icon:hover {
|
| 75 |
-
opacity: 0.
|
| 76 |
}
|
| 77 |
|
| 78 |
.brand-logo {
|
| 79 |
font-family: 'Playfair Display', serif;
|
| 80 |
font-size: 32px;
|
| 81 |
-
letter-spacing:
|
| 82 |
color: #000;
|
| 83 |
text-transform: uppercase;
|
| 84 |
cursor: pointer;
|
| 85 |
white-space: nowrap;
|
| 86 |
}
|
| 87 |
|
| 88 |
-
/*
|
| 89 |
-
|
| 90 |
-
|
|
|
|
| 91 |
}
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
}
|
| 98 |
|
| 99 |
-
/* ===
|
| 100 |
button[kind="primary"] {
|
| 101 |
background-color: #000000 !important;
|
| 102 |
color: #ffffff !important;
|
|
@@ -108,9 +123,9 @@ st.markdown("""
|
|
| 108 |
letter-spacing: 2px !important;
|
| 109 |
padding: 16px 20px !important;
|
| 110 |
height: auto !important;
|
| 111 |
-
box-shadow: none !important;
|
| 112 |
width: 100%;
|
| 113 |
}
|
|
|
|
| 114 |
button[kind="primary"]:hover {
|
| 115 |
background-color: #333 !important;
|
| 116 |
}
|
|
@@ -126,11 +141,12 @@ st.markdown("""
|
|
| 126 |
padding: 12px 16px !important;
|
| 127 |
width: 100%;
|
| 128 |
}
|
|
|
|
| 129 |
button[kind="secondary"]:hover {
|
| 130 |
border-color: #000 !important;
|
| 131 |
}
|
| 132 |
|
| 133 |
-
/*
|
| 134 |
[data-testid="stTextInput"] input {
|
| 135 |
border: none !important;
|
| 136 |
border-bottom: 1px solid #000 !important;
|
|
@@ -140,37 +156,23 @@ st.markdown("""
|
|
| 140 |
box-shadow: none !important;
|
| 141 |
}
|
| 142 |
|
| 143 |
-
/*
|
| 144 |
-
.
|
| 145 |
-
|
| 146 |
-
font-size: 24px;
|
| 147 |
-
color: #000;
|
| 148 |
-
background: none;
|
| 149 |
-
border: none;
|
| 150 |
-
padding: 0 10px;
|
| 151 |
}
|
| 152 |
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
width: 100%;
|
| 156 |
-
text-align: left;
|
| 157 |
-
padding: 15px 0 !important;
|
| 158 |
-
border: none !important;
|
| 159 |
-
border-bottom: 1px solid #f5f5f5 !important;
|
| 160 |
-
background: transparent !important;
|
| 161 |
-
font-size: 13px;
|
| 162 |
-
text-transform: uppercase;
|
| 163 |
-
letter-spacing: 2px;
|
| 164 |
-
cursor: pointer;
|
| 165 |
-
color: black;
|
| 166 |
-
border-radius: 0 !important;
|
| 167 |
-
font-family: 'Inter', sans-serif !important;
|
| 168 |
}
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
}
|
| 175 |
</style>
|
| 176 |
""", unsafe_allow_html=True)
|
|
@@ -200,12 +202,23 @@ def cargar_catalogo():
|
|
| 200 |
client = gspread.authorize(creds)
|
| 201 |
sh = client.open_by_url(SHEET_URL)
|
| 202 |
df = pd.DataFrame(sh.worksheet(HOJA_NOMBRE).get_all_records())
|
| 203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
df['Imagen'] = df['Imagen'].astype(str)
|
| 205 |
df = df[df['Imagen'].str.strip().str.startswith(('http://', 'https://'))]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
return df
|
| 207 |
except Exception as e:
|
| 208 |
-
st.error(f"Error cargando catálogo: {e}")
|
| 209 |
return pd.DataFrame()
|
| 210 |
|
| 211 |
# --- ESTADOS ---
|
|
@@ -220,16 +233,26 @@ if 'search_query' not in st.session_state: st.session_state.search_query = ""
|
|
| 220 |
|
| 221 |
df = cargar_catalogo()
|
| 222 |
|
| 223 |
-
# --- CARGAR IMÁGENES PNG
|
| 224 |
menu_icon = get_image_base64("menu.png")
|
| 225 |
search_icon = get_image_base64("search.png")
|
| 226 |
wish_icon = get_image_base64("wish.png")
|
| 227 |
bag_icon = get_image_base64("bag.png")
|
| 228 |
-
user_icon = get_image_base64("user.png") # Si tienes, si no usa un placeholder
|
| 229 |
|
| 230 |
-
#
|
| 231 |
-
|
| 232 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
<div class="nav-container">
|
| 234 |
<div class="nav-left">
|
| 235 |
<img src="data:image/png;base64,{menu_icon}" class="nav-icon" onclick="document.getElementById('nav_menu_btn').click();" alt="Menu">
|
|
@@ -239,48 +262,55 @@ nav_html = f"""
|
|
| 239 |
<span class="brand-logo" onclick="window.location.reload()">ARZON STUDIOS</span>
|
| 240 |
</div>
|
| 241 |
<div class="nav-right">
|
| 242 |
-
<img src="data:image/png;base64,{user_icon if user_icon else menu_icon}" class="nav-icon" onclick="document.getElementById('nav_user_btn').click();" alt="User">
|
| 243 |
<img src="data:image/png;base64,{wish_icon}" class="nav-icon" onclick="document.getElementById('nav_wish_btn').click();" alt="Wishlist">
|
| 244 |
<img src="data:image/png;base64,{bag_icon}" class="nav-icon" onclick="document.getElementById('nav_bag_btn').click();" alt="Bag">
|
| 245 |
</div>
|
| 246 |
</div>
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
st.markdown(nav_html, unsafe_allow_html=True)
|
| 254 |
|
| 255 |
-
# --- BOTONES OCULTOS
|
| 256 |
-
|
| 257 |
-
with
|
| 258 |
if st.button("menu_hidden", key="nav_menu_btn"):
|
| 259 |
st.session_state.active_drawer = 'menu' if st.session_state.active_drawer != 'menu' else None
|
| 260 |
st.session_state.search_open = False
|
| 261 |
st.rerun()
|
| 262 |
-
with
|
| 263 |
if st.button("search_hidden", key="nav_search_btn"):
|
| 264 |
st.session_state.search_open = not st.session_state.search_open
|
| 265 |
st.session_state.active_drawer = None
|
| 266 |
st.rerun()
|
| 267 |
-
with
|
| 268 |
-
if st.button("user_hidden", key="nav_user_btn"):
|
| 269 |
-
st.toast("User profile - Coming soon")
|
| 270 |
-
with col_hidden[3]:
|
| 271 |
if st.button("wish_hidden", key="nav_wish_btn"):
|
| 272 |
st.session_state.page = 'wishlist'
|
| 273 |
st.session_state.active_drawer = None
|
| 274 |
st.session_state.search_open = False
|
| 275 |
st.rerun()
|
| 276 |
-
with
|
| 277 |
if st.button("bag_hidden", key="nav_bag_btn"):
|
| 278 |
st.session_state.active_drawer = 'cart' if st.session_state.active_drawer != 'cart' else None
|
| 279 |
st.session_state.search_open = False
|
| 280 |
st.rerun()
|
| 281 |
|
| 282 |
-
st.markdown('</div>', unsafe_allow_html=True)
|
| 283 |
-
|
| 284 |
# === SEARCH OVERLAY ===
|
| 285 |
if st.session_state.search_open:
|
| 286 |
st.markdown("<br>", unsafe_allow_html=True)
|
|
@@ -291,137 +321,163 @@ if st.session_state.search_open:
|
|
| 291 |
if st.button("✕", key="close_search"):
|
| 292 |
st.session_state.search_open = False
|
| 293 |
st.rerun()
|
| 294 |
-
|
| 295 |
if query != st.session_state.search_query:
|
| 296 |
st.session_state.search_query = query
|
| 297 |
st.rerun()
|
| 298 |
-
|
| 299 |
-
st.markdown(
|
| 300 |
-
|
| 301 |
-
with
|
| 302 |
st.caption("MEN'S DENIM")
|
| 303 |
st.caption("WOMEN'S BAGS")
|
| 304 |
-
with
|
| 305 |
st.caption("NEW ARRIVALS")
|
| 306 |
st.caption("ACCESSORIES")
|
| 307 |
st.markdown("---")
|
| 308 |
|
| 309 |
-
# === SIDEBAR DRAWER
|
| 310 |
if st.session_state.active_drawer:
|
| 311 |
with st.sidebar:
|
| 312 |
-
|
| 313 |
-
with
|
| 314 |
st.markdown(f"<h3 style='letter-spacing:2px; margin:0;'>{'MENU' if st.session_state.active_drawer == 'menu' else 'SHOPPING BAG'}</h3>", unsafe_allow_html=True)
|
| 315 |
-
with
|
| 316 |
if st.button("✕", key="close_drawer"):
|
| 317 |
st.session_state.active_drawer = None
|
| 318 |
st.rerun()
|
| 319 |
|
| 320 |
st.divider()
|
| 321 |
-
|
| 322 |
if st.session_state.active_drawer == 'menu':
|
| 323 |
cats = ["VIEW ALL"]
|
| 324 |
if not df.empty and 'Categoria' in df.columns:
|
| 325 |
cats += sorted([c for c in df['Categoria'].unique() if pd.notna(c)])
|
| 326 |
|
| 327 |
for cat in cats:
|
| 328 |
-
if st.button(cat, key=f"cat_{cat}"
|
| 329 |
st.session_state.category_filter = cat
|
| 330 |
st.session_state.page = 'home'
|
| 331 |
st.session_state.active_drawer = None
|
| 332 |
st.rerun()
|
| 333 |
-
|
| 334 |
elif st.session_state.active_drawer == 'cart':
|
| 335 |
if not st.session_state.cart:
|
| 336 |
-
st.markdown("<div style='text-align:center; margin:
|
| 337 |
-
if st.button("CONTINUE SHOPPING", key="cont_shop", type="primary"
|
| 338 |
st.session_state.active_drawer = None
|
| 339 |
st.rerun()
|
| 340 |
else:
|
| 341 |
total = 0
|
| 342 |
for i, item in enumerate(st.session_state.cart):
|
| 343 |
-
|
| 344 |
-
with
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
except:
|
| 348 |
-
st.image("https://via.placeholder.com/100", use_container_width=True)
|
| 349 |
-
with col2:
|
| 350 |
st.markdown(f"**{item['name']}**")
|
| 351 |
st.caption(f"Size: {item['size']}")
|
| 352 |
st.markdown(f"**${item['price']}**")
|
| 353 |
if st.button("REMOVE", key=f"rem_{i}"):
|
| 354 |
st.session_state.cart.pop(i)
|
| 355 |
st.rerun()
|
| 356 |
-
try:
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
except:
|
| 360 |
pass
|
| 361 |
st.divider()
|
| 362 |
|
| 363 |
-
st.markdown(f"<div style='display:flex; justify-content:space-between; font-weight:bold;
|
| 364 |
msg = f"PEDIDO ARZON: Total ${total}"
|
| 365 |
link = f"https://api.whatsapp.com/send?phone={WHATSAPP_VENTAS}&text={quote_plus(msg)}"
|
| 366 |
st.link_button("CHECKOUT", link, type="primary", use_container_width=True)
|
| 367 |
|
| 368 |
-
# ===
|
| 369 |
if st.session_state.page == 'home':
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 378 |
else:
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
|
|
|
|
| 396 |
elif st.session_state.page == 'product':
|
| 397 |
if st.session_state.selected_product:
|
| 398 |
p = st.session_state.selected_product
|
| 399 |
|
| 400 |
# Botón back
|
| 401 |
-
if st.button("← BACK TO SHOP", key="
|
| 402 |
st.session_state.page = 'home'
|
| 403 |
st.rerun()
|
| 404 |
|
| 405 |
-
|
| 406 |
-
|
|
|
|
| 407 |
try:
|
| 408 |
st.image(p['Imagen'], use_container_width=True)
|
| 409 |
except:
|
| 410 |
-
st.image("https://via.placeholder.com/600x700?text=ARZON", use_container_width=True)
|
| 411 |
|
| 412 |
-
with
|
| 413 |
st.markdown(f"<h1 style='font-size:32px; margin-bottom:10px;'>{p['Producto']}</h1>", unsafe_allow_html=True)
|
| 414 |
st.markdown(f"<h2 style='font-size:24px; font-weight:400; margin-bottom:20px;'>${p['Precio']} MXN</h2>", unsafe_allow_html=True)
|
| 415 |
|
| 416 |
-
|
|
|
|
| 417 |
size = st.selectbox("SELECT SIZE", tallas)
|
| 418 |
|
|
|
|
| 419 |
if st.button("ADD TO BAG", type="primary", use_container_width=True):
|
| 420 |
st.session_state.cart.append({
|
| 421 |
-
"id": p['ID'],
|
| 422 |
-
"name": p['Producto'],
|
| 423 |
-
"price": p['Precio'],
|
| 424 |
-
"size": size,
|
| 425 |
"img": p['Imagen']
|
| 426 |
})
|
| 427 |
st.session_state.active_drawer = 'cart'
|
|
@@ -429,9 +485,13 @@ elif st.session_state.page == 'product':
|
|
| 429 |
st.rerun()
|
| 430 |
|
| 431 |
st.divider()
|
|
|
|
|
|
|
| 432 |
st.markdown("**DESCRIPTION**")
|
| 433 |
-
|
|
|
|
| 434 |
|
|
|
|
| 435 |
elif st.session_state.page == 'wishlist':
|
| 436 |
st.markdown("<h1 style='text-align:center; font-size:28px; margin:40px 0;'>WISHLIST</h1>", unsafe_allow_html=True)
|
| 437 |
|
|
@@ -443,10 +503,10 @@ elif st.session_state.page == 'wishlist':
|
|
| 443 |
else:
|
| 444 |
cols = st.columns(3)
|
| 445 |
for i, item in enumerate(st.session_state.wishlist):
|
| 446 |
-
with cols[i%3]:
|
| 447 |
try:
|
| 448 |
st.image(item['Imagen'], use_container_width=True)
|
| 449 |
except:
|
| 450 |
st.image("https://via.placeholder.com/400", use_container_width=True)
|
| 451 |
-
st.
|
| 452 |
st.caption(f"${item['Precio']}")
|
|
|
|
| 3 |
from google.oauth2.service_account import Credentials
|
| 4 |
import gspread
|
| 5 |
from urllib.parse import quote_plus
|
|
|
|
| 6 |
import base64
|
|
|
|
| 7 |
|
| 8 |
# --- 1. CONFIGURACIÓN ---
|
| 9 |
st.set_page_config(page_title="ARZON STUDIOS", layout="wide", initial_sidebar_state="collapsed")
|
|
|
|
| 17 |
except:
|
| 18 |
return None
|
| 19 |
|
| 20 |
+
# --- 3. CSS MAESTRO ---
|
| 21 |
st.markdown("""
|
|
|
|
| 22 |
<style>
|
| 23 |
+
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500&family=Inter:wght@300;400;500;600&display=swap');
|
| 24 |
+
|
| 25 |
/* === FORZAR FONDO BLANCO Y TEXTO NEGRO === */
|
| 26 |
+
.stApp, [data-testid="stAppViewContainer"] {
|
|
|
|
| 27 |
background-color: #ffffff !important;
|
| 28 |
color: #000000 !important;
|
| 29 |
font-family: 'Inter', sans-serif !important;
|
| 30 |
}
|
| 31 |
|
| 32 |
/* Ocultar elementos nativos */
|
| 33 |
+
#MainMenu, footer, header, [data-testid="stToolbar"], .stDeployButton {
|
| 34 |
+
display: none !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
}
|
| 36 |
+
|
|
|
|
| 37 |
/* === BARRA DE NAVEGACIÓN CENTRADA === */
|
| 38 |
.nav-container {
|
| 39 |
display: flex;
|
| 40 |
align-items: center;
|
| 41 |
justify-content: space-between;
|
| 42 |
width: 100%;
|
|
|
|
|
|
|
| 43 |
padding: 20px 40px;
|
| 44 |
+
margin-bottom: 30px;
|
| 45 |
+
border-bottom: 1px solid #f0f0f0;
|
| 46 |
}
|
| 47 |
|
| 48 |
.nav-left, .nav-right {
|
| 49 |
display: flex;
|
| 50 |
align-items: center;
|
| 51 |
+
gap: 25px;
|
| 52 |
+
flex: 1;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
.nav-right {
|
| 56 |
+
justify-content: flex-end;
|
| 57 |
}
|
| 58 |
|
| 59 |
.nav-center {
|
|
|
|
| 60 |
text-align: center;
|
| 61 |
}
|
| 62 |
|
|
|
|
| 65 |
height: 24px;
|
| 66 |
cursor: pointer;
|
| 67 |
transition: opacity 0.2s;
|
| 68 |
+
object-fit: contain;
|
| 69 |
}
|
| 70 |
|
| 71 |
.nav-icon:hover {
|
| 72 |
+
opacity: 0.5;
|
| 73 |
}
|
| 74 |
|
| 75 |
.brand-logo {
|
| 76 |
font-family: 'Playfair Display', serif;
|
| 77 |
font-size: 32px;
|
| 78 |
+
letter-spacing: 8px;
|
| 79 |
color: #000;
|
| 80 |
text-transform: uppercase;
|
| 81 |
cursor: pointer;
|
| 82 |
white-space: nowrap;
|
| 83 |
}
|
| 84 |
|
| 85 |
+
/* === SIDEBAR === */
|
| 86 |
+
[data-testid="stSidebar"] {
|
| 87 |
+
background-color: #fff !important;
|
| 88 |
+
border-right: 1px solid #eee;
|
| 89 |
}
|
| 90 |
|
| 91 |
+
[data-testid="stSidebar"] .stButton button {
|
| 92 |
+
width: 100%;
|
| 93 |
+
text-align: left;
|
| 94 |
+
background: transparent !important;
|
| 95 |
+
border: none !important;
|
| 96 |
+
border-bottom: 1px solid #f5f5f5 !important;
|
| 97 |
+
padding: 15px 0 !important;
|
| 98 |
+
border-radius: 0 !important;
|
| 99 |
+
font-size: 13px;
|
| 100 |
+
text-transform: uppercase;
|
| 101 |
+
letter-spacing: 2px;
|
| 102 |
+
color: black;
|
| 103 |
+
font-weight: 400;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
[data-testid="stSidebar"] .stButton button:hover {
|
| 107 |
+
font-weight: 700;
|
| 108 |
+
padding-left: 10px !important;
|
| 109 |
+
transition: 0.2s;
|
| 110 |
+
background: transparent !important;
|
| 111 |
+
border-bottom: 1px solid #000 !important;
|
| 112 |
}
|
| 113 |
|
| 114 |
+
/* === BOTONES === */
|
| 115 |
button[kind="primary"] {
|
| 116 |
background-color: #000000 !important;
|
| 117 |
color: #ffffff !important;
|
|
|
|
| 123 |
letter-spacing: 2px !important;
|
| 124 |
padding: 16px 20px !important;
|
| 125 |
height: auto !important;
|
|
|
|
| 126 |
width: 100%;
|
| 127 |
}
|
| 128 |
+
|
| 129 |
button[kind="primary"]:hover {
|
| 130 |
background-color: #333 !important;
|
| 131 |
}
|
|
|
|
| 141 |
padding: 12px 16px !important;
|
| 142 |
width: 100%;
|
| 143 |
}
|
| 144 |
+
|
| 145 |
button[kind="secondary"]:hover {
|
| 146 |
border-color: #000 !important;
|
| 147 |
}
|
| 148 |
|
| 149 |
+
/* === INPUTS === */
|
| 150 |
[data-testid="stTextInput"] input {
|
| 151 |
border: none !important;
|
| 152 |
border-bottom: 1px solid #000 !important;
|
|
|
|
| 156 |
box-shadow: none !important;
|
| 157 |
}
|
| 158 |
|
| 159 |
+
/* === GRID DE PRODUCTOS === */
|
| 160 |
+
.product-grid {
|
| 161 |
+
margin-top: 30px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
}
|
| 163 |
|
| 164 |
+
.stImage {
|
| 165 |
+
margin-bottom: 10px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
}
|
| 167 |
+
|
| 168 |
+
/* === BOTÓN CERRAR === */
|
| 169 |
+
.close-btn {
|
| 170 |
+
background: none !important;
|
| 171 |
+
border: none !important;
|
| 172 |
+
font-size: 24px !important;
|
| 173 |
+
cursor: pointer !important;
|
| 174 |
+
padding: 0 !important;
|
| 175 |
+
color: #000 !important;
|
| 176 |
}
|
| 177 |
</style>
|
| 178 |
""", unsafe_allow_html=True)
|
|
|
|
| 202 |
client = gspread.authorize(creds)
|
| 203 |
sh = client.open_by_url(SHEET_URL)
|
| 204 |
df = pd.DataFrame(sh.worksheet(HOJA_NOMBRE).get_all_records())
|
| 205 |
+
|
| 206 |
+
# Debug: Ver qué columnas tiene
|
| 207 |
+
st.sidebar.write("Columnas encontradas:", list(df.columns))
|
| 208 |
+
|
| 209 |
+
if 'Imagen' not in df.columns:
|
| 210 |
+
st.error("No se encontró la columna 'Imagen'")
|
| 211 |
+
return pd.DataFrame()
|
| 212 |
+
|
| 213 |
df['Imagen'] = df['Imagen'].astype(str)
|
| 214 |
df = df[df['Imagen'].str.strip().str.startswith(('http://', 'https://'))]
|
| 215 |
+
|
| 216 |
+
# Debug: Ver cuántos productos se cargaron
|
| 217 |
+
st.sidebar.write(f"Productos cargados: {len(df)}")
|
| 218 |
+
|
| 219 |
return df
|
| 220 |
except Exception as e:
|
| 221 |
+
st.error(f"Error cargando catálogo: {str(e)}")
|
| 222 |
return pd.DataFrame()
|
| 223 |
|
| 224 |
# --- ESTADOS ---
|
|
|
|
| 233 |
|
| 234 |
df = cargar_catalogo()
|
| 235 |
|
| 236 |
+
# --- CARGAR IMÁGENES PNG ---
|
| 237 |
menu_icon = get_image_base64("menu.png")
|
| 238 |
search_icon = get_image_base64("search.png")
|
| 239 |
wish_icon = get_image_base64("wish.png")
|
| 240 |
bag_icon = get_image_base64("bag.png")
|
|
|
|
| 241 |
|
| 242 |
+
# Si no encuentran las imágenes, usar emojis como fallback
|
| 243 |
+
if not menu_icon:
|
| 244 |
+
menu_icon = None
|
| 245 |
+
if not search_icon:
|
| 246 |
+
search_icon = None
|
| 247 |
+
if not wish_icon:
|
| 248 |
+
wish_icon = None
|
| 249 |
+
if not bag_icon:
|
| 250 |
+
bag_icon = None
|
| 251 |
+
|
| 252 |
+
# --- NAVEGACIÓN PERSONALIZADA SIN USER ---
|
| 253 |
+
if menu_icon and search_icon and wish_icon and bag_icon:
|
| 254 |
+
# Usar PNGs si existen
|
| 255 |
+
nav_html = f"""
|
| 256 |
<div class="nav-container">
|
| 257 |
<div class="nav-left">
|
| 258 |
<img src="data:image/png;base64,{menu_icon}" class="nav-icon" onclick="document.getElementById('nav_menu_btn').click();" alt="Menu">
|
|
|
|
| 262 |
<span class="brand-logo" onclick="window.location.reload()">ARZON STUDIOS</span>
|
| 263 |
</div>
|
| 264 |
<div class="nav-right">
|
|
|
|
| 265 |
<img src="data:image/png;base64,{wish_icon}" class="nav-icon" onclick="document.getElementById('nav_wish_btn').click();" alt="Wishlist">
|
| 266 |
<img src="data:image/png;base64,{bag_icon}" class="nav-icon" onclick="document.getElementById('nav_bag_btn').click();" alt="Bag">
|
| 267 |
</div>
|
| 268 |
</div>
|
| 269 |
+
"""
|
| 270 |
+
else:
|
| 271 |
+
# Fallback con emojis
|
| 272 |
+
nav_html = """
|
| 273 |
+
<div class="nav-container">
|
| 274 |
+
<div class="nav-left">
|
| 275 |
+
<span class="nav-icon" onclick="document.getElementById('nav_menu_btn').click();" style="font-size:24px;">☰</span>
|
| 276 |
+
<span class="nav-icon" onclick="document.getElementById('nav_search_btn').click();" style="font-size:24px;">🔍</span>
|
| 277 |
+
</div>
|
| 278 |
+
<div class="nav-center">
|
| 279 |
+
<span class="brand-logo" onclick="window.location.reload()">ARZON STUDIOS</span>
|
| 280 |
+
</div>
|
| 281 |
+
<div class="nav-right">
|
| 282 |
+
<span class="nav-icon" onclick="document.getElementById('nav_wish_btn').click();" style="font-size:24px;">🔖</span>
|
| 283 |
+
<span class="nav-icon" onclick="document.getElementById('nav_bag_btn').click();" style="font-size:24px;">🛍️</span>
|
| 284 |
+
</div>
|
| 285 |
+
</div>
|
| 286 |
+
"""
|
| 287 |
|
| 288 |
st.markdown(nav_html, unsafe_allow_html=True)
|
| 289 |
|
| 290 |
+
# --- BOTONES OCULTOS ---
|
| 291 |
+
col1, col2, col3, col4 = st.columns(4)
|
| 292 |
+
with col1:
|
| 293 |
if st.button("menu_hidden", key="nav_menu_btn"):
|
| 294 |
st.session_state.active_drawer = 'menu' if st.session_state.active_drawer != 'menu' else None
|
| 295 |
st.session_state.search_open = False
|
| 296 |
st.rerun()
|
| 297 |
+
with col2:
|
| 298 |
if st.button("search_hidden", key="nav_search_btn"):
|
| 299 |
st.session_state.search_open = not st.session_state.search_open
|
| 300 |
st.session_state.active_drawer = None
|
| 301 |
st.rerun()
|
| 302 |
+
with col3:
|
|
|
|
|
|
|
|
|
|
| 303 |
if st.button("wish_hidden", key="nav_wish_btn"):
|
| 304 |
st.session_state.page = 'wishlist'
|
| 305 |
st.session_state.active_drawer = None
|
| 306 |
st.session_state.search_open = False
|
| 307 |
st.rerun()
|
| 308 |
+
with col4:
|
| 309 |
if st.button("bag_hidden", key="nav_bag_btn"):
|
| 310 |
st.session_state.active_drawer = 'cart' if st.session_state.active_drawer != 'cart' else None
|
| 311 |
st.session_state.search_open = False
|
| 312 |
st.rerun()
|
| 313 |
|
|
|
|
|
|
|
| 314 |
# === SEARCH OVERLAY ===
|
| 315 |
if st.session_state.search_open:
|
| 316 |
st.markdown("<br>", unsafe_allow_html=True)
|
|
|
|
| 321 |
if st.button("✕", key="close_search"):
|
| 322 |
st.session_state.search_open = False
|
| 323 |
st.rerun()
|
| 324 |
+
|
| 325 |
if query != st.session_state.search_query:
|
| 326 |
st.session_state.search_query = query
|
| 327 |
st.rerun()
|
| 328 |
+
|
| 329 |
+
st.markdown("<p style='font-size:11px; font-weight:700; letter-spacing:1px; margin:20px 0 10px;'>POPULAR SEARCHES</p>", unsafe_allow_html=True)
|
| 330 |
+
col_a, col_b, col_c = st.columns(3)
|
| 331 |
+
with col_a:
|
| 332 |
st.caption("MEN'S DENIM")
|
| 333 |
st.caption("WOMEN'S BAGS")
|
| 334 |
+
with col_b:
|
| 335 |
st.caption("NEW ARRIVALS")
|
| 336 |
st.caption("ACCESSORIES")
|
| 337 |
st.markdown("---")
|
| 338 |
|
| 339 |
+
# === SIDEBAR DRAWER ===
|
| 340 |
if st.session_state.active_drawer:
|
| 341 |
with st.sidebar:
|
| 342 |
+
col_close1, col_close2 = st.columns([6, 1])
|
| 343 |
+
with col_close1:
|
| 344 |
st.markdown(f"<h3 style='letter-spacing:2px; margin:0;'>{'MENU' if st.session_state.active_drawer == 'menu' else 'SHOPPING BAG'}</h3>", unsafe_allow_html=True)
|
| 345 |
+
with col_close2:
|
| 346 |
if st.button("✕", key="close_drawer"):
|
| 347 |
st.session_state.active_drawer = None
|
| 348 |
st.rerun()
|
| 349 |
|
| 350 |
st.divider()
|
| 351 |
+
|
| 352 |
if st.session_state.active_drawer == 'menu':
|
| 353 |
cats = ["VIEW ALL"]
|
| 354 |
if not df.empty and 'Categoria' in df.columns:
|
| 355 |
cats += sorted([c for c in df['Categoria'].unique() if pd.notna(c)])
|
| 356 |
|
| 357 |
for cat in cats:
|
| 358 |
+
if st.button(cat, key=f"cat_{cat}"):
|
| 359 |
st.session_state.category_filter = cat
|
| 360 |
st.session_state.page = 'home'
|
| 361 |
st.session_state.active_drawer = None
|
| 362 |
st.rerun()
|
| 363 |
+
|
| 364 |
elif st.session_state.active_drawer == 'cart':
|
| 365 |
if not st.session_state.cart:
|
| 366 |
+
st.markdown("<div style='text-align:center; margin:60px 0;'>Your bag is empty</div>", unsafe_allow_html=True)
|
| 367 |
+
if st.button("CONTINUE SHOPPING", key="cont_shop", type="primary"):
|
| 368 |
st.session_state.active_drawer = None
|
| 369 |
st.rerun()
|
| 370 |
else:
|
| 371 |
total = 0
|
| 372 |
for i, item in enumerate(st.session_state.cart):
|
| 373 |
+
col_img, col_info = st.columns([1, 2])
|
| 374 |
+
with col_img:
|
| 375 |
+
st.image(item['img'], use_container_width=True)
|
| 376 |
+
with col_info:
|
|
|
|
|
|
|
|
|
|
| 377 |
st.markdown(f"**{item['name']}**")
|
| 378 |
st.caption(f"Size: {item['size']}")
|
| 379 |
st.markdown(f"**${item['price']}**")
|
| 380 |
if st.button("REMOVE", key=f"rem_{i}"):
|
| 381 |
st.session_state.cart.pop(i)
|
| 382 |
st.rerun()
|
| 383 |
+
try:
|
| 384 |
+
total += float(str(item['price']).replace(',', '').replace('$', ''))
|
| 385 |
+
except:
|
|
|
|
| 386 |
pass
|
| 387 |
st.divider()
|
| 388 |
|
| 389 |
+
st.markdown(f"<div style='display:flex; justify-content:space-between; font-weight:bold;'><span>TOTAL</span><span>${total:,.2f}</span></div>", unsafe_allow_html=True)
|
| 390 |
msg = f"PEDIDO ARZON: Total ${total}"
|
| 391 |
link = f"https://api.whatsapp.com/send?phone={WHATSAPP_VENTAS}&text={quote_plus(msg)}"
|
| 392 |
st.link_button("CHECKOUT", link, type="primary", use_container_width=True)
|
| 393 |
|
| 394 |
+
# === VISTA PRINCIPAL - PRODUCTOS ===
|
| 395 |
if st.session_state.page == 'home':
|
| 396 |
+
st.markdown("<div class='product-grid'>", unsafe_allow_html=True)
|
| 397 |
+
|
| 398 |
+
if df.empty:
|
| 399 |
+
st.warning("⚠️ No se pudieron cargar los productos. Verifica la conexión con Google Sheets.")
|
| 400 |
+
|
| 401 |
+
# Mostrar datos de ejemplo para debug
|
| 402 |
+
st.info("""
|
| 403 |
+
**Instrucciones:**
|
| 404 |
+
1. Asegúrate que tu Google Sheet tenga estas columnas exactas: ID, Producto, Precio, Imagen, Categoria, Tallas, Descripcion
|
| 405 |
+
2. La columna 'Imagen' debe contener URLs válidas de imágenes
|
| 406 |
+
3. Comparte el sheet con: gestor-rifa@trhhats.iam.gserviceaccount.com
|
| 407 |
+
""")
|
| 408 |
else:
|
| 409 |
+
# Filtrar productos
|
| 410 |
+
df_show = df.copy()
|
| 411 |
+
|
| 412 |
+
if st.session_state.category_filter != "VIEW ALL":
|
| 413 |
+
df_show = df_show[df_show['Categoria'] == st.session_state.category_filter]
|
| 414 |
+
|
| 415 |
+
if st.session_state.search_query:
|
| 416 |
+
df_show = df_show[df_show.apply(lambda x: st.session_state.search_query.lower() in str(x.values).lower(), axis=1)]
|
| 417 |
+
|
| 418 |
+
if df_show.empty:
|
| 419 |
+
st.info("No products found")
|
| 420 |
+
else:
|
| 421 |
+
# Grid de 3 columnas
|
| 422 |
+
cols = st.columns(3, gap="large")
|
| 423 |
+
|
| 424 |
+
for idx, row in df_show.iterrows():
|
| 425 |
+
with cols[idx % 3]:
|
| 426 |
+
# Imagen
|
| 427 |
+
try:
|
| 428 |
+
st.image(row['Imagen'], use_container_width=True)
|
| 429 |
+
except:
|
| 430 |
+
st.image("https://via.placeholder.com/400x500?text=ARZON+STUDIOS", use_container_width=True)
|
| 431 |
+
|
| 432 |
+
# Información del producto
|
| 433 |
+
st.markdown(f"""
|
| 434 |
+
<div style='text-align:center; margin-top:15px;'>
|
| 435 |
+
<div style='font-weight:600; font-size:14px; margin-bottom:5px;'>{row['Producto']}</div>
|
| 436 |
+
<div style='font-size:13px; color:#666; margin-bottom:15px;'>${row['Precio']} MXN</div>
|
| 437 |
+
</div>
|
| 438 |
+
""", unsafe_allow_html=True)
|
| 439 |
+
|
| 440 |
+
# Botón Shop Now
|
| 441 |
+
if st.button("SHOP NOW", key=f"shop_{row['ID']}", type="secondary", use_container_width=True):
|
| 442 |
+
st.session_state.selected_product = row.to_dict()
|
| 443 |
+
st.session_state.page = 'product'
|
| 444 |
+
st.rerun()
|
| 445 |
+
|
| 446 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 447 |
|
| 448 |
+
# === VISTA DE PRODUCTO ===
|
| 449 |
elif st.session_state.page == 'product':
|
| 450 |
if st.session_state.selected_product:
|
| 451 |
p = st.session_state.selected_product
|
| 452 |
|
| 453 |
# Botón back
|
| 454 |
+
if st.button("← BACK TO SHOP", key="back_btn"):
|
| 455 |
st.session_state.page = 'home'
|
| 456 |
st.rerun()
|
| 457 |
|
| 458 |
+
col_img, col_info = st.columns([1.5, 1], gap="large")
|
| 459 |
+
|
| 460 |
+
with col_img:
|
| 461 |
try:
|
| 462 |
st.image(p['Imagen'], use_container_width=True)
|
| 463 |
except:
|
| 464 |
+
st.image("https://via.placeholder.com/600x700?text=ARZON+STUDIOS", use_container_width=True)
|
| 465 |
|
| 466 |
+
with col_info:
|
| 467 |
st.markdown(f"<h1 style='font-size:32px; margin-bottom:10px;'>{p['Producto']}</h1>", unsafe_allow_html=True)
|
| 468 |
st.markdown(f"<h2 style='font-size:24px; font-weight:400; margin-bottom:20px;'>${p['Precio']} MXN</h2>", unsafe_allow_html=True)
|
| 469 |
|
| 470 |
+
# Tallas
|
| 471 |
+
tallas = [t.strip() for t in str(p.get('Tallas', 'ONE SIZE')).split(',')]
|
| 472 |
size = st.selectbox("SELECT SIZE", tallas)
|
| 473 |
|
| 474 |
+
# Botón Add to Bag
|
| 475 |
if st.button("ADD TO BAG", type="primary", use_container_width=True):
|
| 476 |
st.session_state.cart.append({
|
| 477 |
+
"id": p['ID'],
|
| 478 |
+
"name": p['Producto'],
|
| 479 |
+
"price": p['Precio'],
|
| 480 |
+
"size": size,
|
| 481 |
"img": p['Imagen']
|
| 482 |
})
|
| 483 |
st.session_state.active_drawer = 'cart'
|
|
|
|
| 485 |
st.rerun()
|
| 486 |
|
| 487 |
st.divider()
|
| 488 |
+
|
| 489 |
+
# Descripción
|
| 490 |
st.markdown("**DESCRIPTION**")
|
| 491 |
+
descripcion = p.get('Descripcion', 'No description available')
|
| 492 |
+
st.caption(descripcion)
|
| 493 |
|
| 494 |
+
# === VISTA WISHLIST ===
|
| 495 |
elif st.session_state.page == 'wishlist':
|
| 496 |
st.markdown("<h1 style='text-align:center; font-size:28px; margin:40px 0;'>WISHLIST</h1>", unsafe_allow_html=True)
|
| 497 |
|
|
|
|
| 503 |
else:
|
| 504 |
cols = st.columns(3)
|
| 505 |
for i, item in enumerate(st.session_state.wishlist):
|
| 506 |
+
with cols[i % 3]:
|
| 507 |
try:
|
| 508 |
st.image(item['Imagen'], use_container_width=True)
|
| 509 |
except:
|
| 510 |
st.image("https://via.placeholder.com/400", use_container_width=True)
|
| 511 |
+
st.markdown(f"**{item['Producto']}**")
|
| 512 |
st.caption(f"${item['Precio']}")
|