/* ============================================================
   Xales — Sistema de diseño "Estudio oscuro" (rediseño)
   Shell común: tokens, greca, navbar, botones, badges, tab bar.
   Cada página añade su CSS específico. NO cambia lógica ni ids.
   ============================================================ */

:root {
  /* Superficies */
  --bg: #120E1D;
  --surface: #1A1428;
  --surface-2: rgba(255,255,255,.06);
  --surface-3: rgba(255,255,255,.08);
  --border: #292040;
  --border-2: #302647;
  --border-soft: rgba(167,139,250,.18);
  /* Morados */
  --p-950: #4C1D95;
  --p-900: #5B21B6;
  --p-700: #6B46C1;
  --p-600: #7C3AED;
  --p-500: #8B5CF6;
  --p-400: #A78BFA;
  --p-300: #C4A6FF;
  --p-200: #C4B5FD;
  --pill-active: #2E2450;
  /* Ámbar / oro */
  --a-700: #D97706;
  --a-600: #F59E0B;
  --a-400: #FBBF24;
  --a-300: #FCD34D;
  /* Texto */
  --tx: #ffffff;
  --tx-1: #EDE7FA;
  --tx-2: #C6BEDA;
  --tx-3: #9C93B4;
  --tx-4: #7D739A;
  /* Semánticos */
  --ok: #34D399;
  --info: #60A5FA;
  --warn: #FBBF24;
  --err: #F87171;
  --live: #DC2626;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--tx);
  min-height: 100vh;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

.font-aztec, .cinzel { font-family: 'Cinzel', serif; }

a { color: inherit; text-decoration: none; }

/* ===== GRECA animada (arriba y abajo) ===== */
.greca-top, .greca-bottom {
  position: fixed; left: 0; right: 0; height: 5px; z-index: 1200;
  background: linear-gradient(90deg,#7C3AED 0%,#A78BFA 20%,#F59E0B 35%,#A78BFA 50%,#7C3AED 65%,#F59E0B 80%,#A78BFA 100%);
  background-size: 300% 100%;
  animation: grecaFlow 8s linear infinite;
}
.greca-top { top: 0; }
.greca-bottom { bottom: 0; }
@keyframes grecaFlow { 0% { background-position: 0% 50%; } 100% { background-position: 300% 50%; } }

@keyframes livePulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== NAVBAR ===== */
.xnav {
  position: sticky; top: 5px; z-index: 1000;
  height: 68px;
  background: rgba(30,0,60,.55);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
}
.xnav-inner {
  max-width: 1240px; margin: 0 auto; height: 100%;
  padding: 0 24px; display: flex; align-items: center; gap: 20px;
}
.xnav-logo { display: flex; align-items: center; gap: 9px; height: 34px; }
.xnav-logo img { height: 30px; width: auto; display: block; }
.xnav-brand { font-family: 'Cinzel', serif; font-size: 20px; font-weight: 800; color: #fff; letter-spacing: .04em; line-height: 1; }
.xnav-links { display: flex; align-items: center; gap: 8px; }
.xnav-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 10px; font-size: 14px; font-weight: 600;
  color: var(--tx-3); background: transparent; border: none; cursor: pointer;
  transition: .2s ease;
}
.xnav-pill:hover { color: var(--tx); background: rgba(255,255,255,.05); }
.xnav-pill.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(124,58,237,.5), rgba(91,33,182,.5));
}
.xnav-spacer { flex: 1; }
.xnav-search {
  position: relative; width: 100%; max-width: 320px;
}
.xnav-search input {
  width: 100%; height: 40px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border-2);
  color: var(--tx); font-size: 14px; padding: 0 12px 0 36px; outline: none;
}
.xnav-search input::placeholder { color: var(--tx-4); }
.xnav-search input:focus { border-color: var(--p-700); }
.xnav-search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--tx-4); width: 16px; height: 16px; }

/* Avatar + dropdown */
.xavatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--p-400), var(--a-600));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #1a1030; border: none; cursor: pointer;
  overflow: hidden;
}
.xavatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
/* Botón de perfil canónico: avatar + flecha (pill) */
.user-avatar-btn { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; background: rgba(255,255,255,.08); border-radius: 30px; border: none; cursor: pointer; transition: background .2s; }
.user-avatar-btn:hover { background: rgba(255,255,255,.16); }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--p-400), var(--a-300)); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; color: #1a1030; overflow: hidden; flex-shrink: 0; }
.user-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.user-dropdown-wrap { position: relative; }
.user-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0; width: 260px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 24px 48px -24px rgba(0,0,0,.7);
  overflow: hidden; opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: .2s ease; z-index: 1001;
}
.user-dropdown.show { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-header { padding: 14px; border-bottom: 1px solid var(--border); }
.dropdown-username { font-weight: 700; color: var(--tx); font-size: 14px; }
.dropdown-email { font-size: 12px; color: var(--tx-3); margin-top: 2px; }
.dropdown-menu-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  color: var(--tx-1); font-weight: 500; font-size: 14px; width: 100%;
  background: none; border: none; cursor: pointer; text-align: left; transition: .2s;
}
.dropdown-menu-item:hover { background: rgba(124,58,237,.12); }
.dropdown-menu-item.logout { color: var(--err); border-top: 1px solid var(--border); }
.dropdown-menu-item.logout:hover { background: rgba(248,113,113,.1); }
.dropdown-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: rgba(124,58,237,.15); color: var(--p-400); }
.dropdown-icon svg { width: 18px; height: 18px; }
.dropdown-arrow { width: 16px; height: 16px; color: var(--tx-3); transition: transform .2s; }

/* ===== Shell de páginas: breadcrumb + hero + filtros (compartido) ===== */
.xwrap { max-width: 1100px; margin: 0 auto; padding: 20px 18px 64px; }
.xbreadcrumb { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--tx-3); margin-bottom: 14px; }
.xbreadcrumb a { color: var(--p-400); font-weight: 600; }
.xbreadcrumb a:hover { color: var(--p-300); text-decoration: underline; }
.xbreadcrumb svg { width: 15px; height: 15px; opacity: .5; }
.xbreadcrumb .cur { color: var(--tx-2); }

.xhero { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.xhero-icon { width: 46px; height: 46px; border-radius: 14px; background: rgba(124,58,237,.15); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.xhero-icon svg { width: 24px; height: 24px; color: var(--p-300); }
.xhero-titles { min-width: 0; flex: 1; }
.xhero-title { font-family: 'Cinzel', serif; font-size: 1.5rem; font-weight: 800; color: #fff; margin: 0; line-height: 1.1; }
.xhero-sub { color: var(--tx-3); font-size: .88rem; margin-top: 3px; }
.xhero-stat { text-align: right; flex-shrink: 0; }
.xhero-stat .v { font-family: 'Cinzel', serif; font-size: 1.5rem; font-weight: 800; color: #fff; display: block; line-height: 1; }
.xhero-stat .l { color: var(--tx-3); font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; }
@media (max-width: 560px) { .xhero-sub { display: none; } .xhero-title { font-size: 1.2rem; } }

.xfilters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.xfilter { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,.04); color: var(--tx-3); font-weight: 700; font-size: .85rem; cursor: pointer; transition: .15s; font-family: 'Inter', sans-serif; }
.xfilter:hover { color: #fff; border-color: var(--p-700); }
.xfilter.active { background: var(--p-600); color: #fff; border-color: var(--p-600); }
.xfilter .cnt { background: rgba(0,0,0,.22); border-radius: 999px; padding: 1px 7px; font-size: .72rem; min-width: 18px; text-align: center; }
.xfilter.active .cnt { background: rgba(0,0,0,.28); }

/* ===== BOTONES ===== */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 22px; border-radius: 12px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--p-600), var(--p-900));
  color: #fff; font-size: 15px; font-weight: 700; transition: .2s ease;
}
.btn-primary:hover { box-shadow: 0 0 30px rgba(124,58,237,.5); }
.btn-amber {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 22px; border-radius: 12px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--a-600), var(--a-700));
  color: #1C1917; font-size: 15px; font-weight: 800; transition: .2s ease;
}
.btn-amber:hover { box-shadow: 0 8px 24px rgba(245,158,11,.4); }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 22px; border-radius: 12px; cursor: pointer;
  background: transparent; border: 1px solid var(--border-soft);
  color: var(--tx-1); font-size: 15px; font-weight: 600; transition: .2s ease;
}
.btn-ghost:hover { border-color: rgba(167,139,250,.5); background: rgba(255,255,255,.04); }

/* ===== BADGE EN VIVO ===== */
.badge-live {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--live); color: #fff; font-size: 11px; font-weight: 800;
  letter-spacing: .06em; border-radius: 20px; padding: 4px 10px;
}
.badge-live .dot { width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: livePulse 2s ease-in-out infinite; }

/* ===== TAB BAR MÓVIL ===== */
.xtabbar { display: none; }
@media (max-width: 768px) {
  /* Navbar compacto tipo app */
  .xnav { height: 56px; }
  .xnav-inner { padding: 0 14px; gap: 10px; }
  .xnav-logo img { height: 26px; }
  .xnav-brand { font-size: 18px; }
  /* En móvil la navegación vive en el tab bar; ocultamos las pills del navbar. */
  .xnav-links { display: none; }
  /* Menos padding lateral (app-like) */
  .container-1240 { padding: 0 14px; }

  /* Tab bar inferior con área segura (notch / barra de gestos) y estado activo morado */
  .xtabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1100;
    height: calc(58px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(18,14,29,.98);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
  }
  .xtabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; color: var(--tx-3); font-size: 10px; font-weight: 600; padding-top: 6px;
    transition: color .15s ease;
  }
  .xtabbar a .ic { font-size: 18px; line-height: 1; }
  .xtabbar a.active { color: var(--p-300); }
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
}

/* ===== SPINNER ===== */
.spinner {
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  border: 3px solid rgba(167,139,250,.2); border-top-color: var(--p-400);
  animation: spin .7s linear infinite; margin: 2rem auto;
}

/* ===== TOAST (conserva comportamiento; adapta fondo) ===== */
.toast, #toast {
  background: rgba(15,0,40,.95) !important;
  border: 1px solid rgba(167,139,250,.3) !important;
  color: var(--tx) !important;
}

/* ===== Iconos flat (SVG de línea, heredan currentColor) ===== */
.xic { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: middle; }
.xnav-pill .xic { width: 17px; height: 17px; }
.xtabbar .ic { display: inline-flex; align-items: center; justify-content: center; }
.xtabbar .ic .xic { width: 22px; height: 22px; }
.dropdown-icon .xic { width: 18px; height: 18px; }

/* ===== Utilidades ===== */
.container-1240 { max-width: 1240px; margin: 0 auto; padding: 0 24px; }

/* Partículas decorativas: no van en el diseño "Estudio oscuro" y su contenedor
   ocupaba espacio en flujo arriba del navbar en algunas páginas. Se ocultan
   (el JS que las crea sigue funcionando, solo que no se ven). */
#particles-container { display: none !important; }

/* ===== FAB de acción (crear stream / publicar producto) =====
   Flotante abajo-derecha, color de acción (ámbar/naranja). Sin sombra ni glow:
   el único feedback es el rollover (brillo sutil) y el active (leve empuje). */
.fab {
    position: fixed; bottom: 84px; right: 24px; z-index: 50;
    display: inline-flex; align-items: center; gap: 8px;
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: #1C1917; border: none; border-radius: 50px;
    padding: 12px 22px; font-family: Inter, sans-serif; font-size: 14px; font-weight: 800;
    line-height: 1; cursor: pointer; text-decoration: none; box-shadow: none;
    transition: filter .15s ease, transform .15s ease;
}
.fab:hover { filter: brightness(1.06); box-shadow: none; }
.fab:active { transform: translateY(1px); }
.fab .xic { width: 18px; height: 18px; }
