/* ==================================================================
   Penya FC Barcelona Guatemala — estilos base v2
   Paleta: granate #a50044, azul #004d98, amarillo #ffcb05
   ================================================================== */

:root {
  /* Colores oficiales del Barça */
  --primary: #a50044;
  --primary-dark: #8a0039;
  --primary-darker: #6e002d;
  --secondary: #004d98;
  --secondary-dark: #003c79;
  --accent: #ffcb05;
  --accent-dark: #e0b300;

  /* Grises */
  --bg: #f5f6f8;
  --bg-card: #ffffff;
  --bg-soft: #f9fafb;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  /* Estado */
  --error: #d32f2f;
  --error-bg: #fef2f2;
  --success: #2e7d32;
  --success-bg: #f0fdf4;
  --warning: #ed6c02;
  --warning-bg: #fffbeb;
  --info: #0d6efd;
  --info-bg: #eff6ff;

  /* Geometría */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --shadow-xl: 0 12px 36px rgba(165,0,68,0.15);

  /* Layout */
  --nav-height: 64px;
  --header-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: var(--secondary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

h1, h2, h3, h4, h5 { font-weight: 700; line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }

/* ============== AUTH LAYOUT ============== */
.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}
.auth-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 440px; overflow: hidden;
}
.auth-header {
  text-align: center; padding: 32px 30px 24px; color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}
.auth-header h1 { margin: 0; font-size: 24px; font-weight: 700; }
.auth-header .subtitle {
  margin: 6px 0 0; font-size: 12px; font-weight: 600;
  letter-spacing: 1.5px; color: var(--accent);
}
.auth-body { padding: 30px; }
.auth-body h2 { margin: 0 0 8px; font-size: 20px; }
.auth-body p.lead { margin: 0 0 24px; color: var(--text-muted); font-size: 14px; }
.auth-footer {
  text-align: center; padding: 16px 30px;
  background: #fafafa; border-top: 1px solid var(--border);
  font-size: 14px; color: var(--text-muted);
}
.auth-footer a { color: var(--primary); font-weight: 600; }

/* ============== APP SHELL (con header + main + bottom nav) ============== */
.app-shell {
  display: flex; flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #fff;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 50;
  min-height: var(--header-height);
}
.app-header-left, .app-header-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-header-left { flex: 1; min-width: 0; }
.app-header-right { flex-shrink: 0; }

.header-brand { color: #fff; display: flex; align-items: center; gap: 8px; min-width: 0; }
.header-brand:hover { text-decoration: none; }
.brand-emoji { font-size: 22px; }
.brand-text { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.header-back {
  color: #fff; font-size: 24px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  margin-left: -8px;
}
.header-back:hover { background: rgba(255,255,255,0.15); text-decoration: none; }
.header-title {
  font-weight: 700; font-size: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.points-pill {
  background: rgba(255,255,255,0.2);
  padding: 6px 12px;
  border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
  font-weight: 700; font-size: 13px;
  color: #fff !important;
  transition: background 0.15s;
}
.points-pill:hover { background: rgba(255,255,255,0.3); text-decoration: none; }
.pts-icon { font-size: 14px; }

/* Main content */
.app-main {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 720px) {
  .app-main { padding: 24px; }
}

/* ============== BOTTOM NAV ============== */
.app-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: var(--safe-bottom);
  z-index: 50;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 10px 4px 8px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  transition: color 0.15s;
  text-decoration: none;
  position: relative;
  min-height: var(--nav-height);
}
.nav-item:hover { text-decoration: none; color: var(--primary); }
.nav-item.active { color: var(--primary); font-weight: 700; }
.nav-item.active::before {
  content: ''; position: absolute; top: 0; left: 25%; right: 25%;
  height: 3px; background: var(--primary); border-radius: 0 0 3px 3px;
}
.nav-icon { font-size: 22px; line-height: 1; margin-bottom: 2px; }
.nav-label { font-size: 11px; }

/* ============== CARDS Y MÓDULOS ============== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.card-title {
  margin: 0 0 12px; font-size: 17px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}

.hero-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.hero-card::after {
  content: ''; position: absolute; right: -40px; top: -40px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(255,203,5,0.15) 0%, transparent 70%);
  pointer-events: none;
}
.hero-card h2 { color: #fff; margin: 0 0 8px; }
.hero-card p { margin: 0; opacity: 0.95; }

/* Stat cards (admin & dashboard) */
.stats-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--primary);
}
.stat-card.s-secondary { border-left-color: var(--secondary); }
.stat-card.s-accent    { border-left-color: var(--accent); }
.stat-num {
  font-size: 26px; font-weight: 800; color: var(--primary);
  line-height: 1.1;
}
.stat-card.s-secondary .stat-num { color: var(--secondary); }
.stat-card.s-accent    .stat-num { color: var(--accent-dark); }
.stat-label {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ============== FORMS ============== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-weight: 600; font-size: 14px; color: var(--text);
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="search"],
.form-group select,
.form-group textarea {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 15px; font-family: inherit;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(165,0,68,0.12);
}
.form-group .hint {
  display: block; margin-top: 4px;
  font-size: 12px; color: var(--text-light);
}
.form-group .field-status {
  display: block; margin-top: 4px;
  font-size: 12px; min-height: 16px;
}
.form-group .field-status.ok       { color: var(--success); }
.form-group .field-status.error    { color: var(--error); }
.form-group .field-status.checking { color: var(--text-light); }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

.checkbox-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; margin: 14px 0; color: var(--text-muted);
}
.checkbox-line input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--primary);
}

/* ============== BUTTONS ============== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 20px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
  text-align: center; font-family: inherit;
  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover  { background: var(--primary-dark); text-decoration: none; color: #fff; box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled { background: #aaa; cursor: not-allowed; opacity: 0.7; }
.btn-block { display: flex; width: 100%; }
.btn-secondary { background: var(--secondary); }
.btn-secondary:hover { background: var(--secondary-dark); }
.btn-accent { background: var(--accent); color: #1a1a1a; }
.btn-accent:hover { background: var(--accent-dark); color: #1a1a1a; }
.btn-ghost {
  background: transparent; color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-ghost:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

/* ============== ALERTS y FLASH ============== */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 14px;
  border-left: 4px solid;
}
.alert-error   { background: var(--error-bg);   border-color: var(--error);   color: #5d1a1a; }
.alert-success { background: var(--success-bg); border-color: var(--success); color: #1e3920; }
.alert-warning { background: var(--warning-bg); border-color: var(--warning); color: #6b3f00; }
.alert-info    { background: var(--info-bg);    border-color: var(--info);    color: #0d3d6a; }
.alert ul { margin: 6px 0 0 18px; padding: 0; }
.alert li { margin: 2px 0; }

.flash-msg {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 14px; font-size: 14px;
  border-left: 4px solid;
  animation: slideDown 0.25s ease-out;
}
.flash-success { background: var(--success-bg); border-color: var(--success); color: #1e3920; }
.flash-error   { background: var(--error-bg);   border-color: var(--error);   color: #5d1a1a; }
.flash-info    { background: var(--info-bg);    border-color: var(--info);    color: #0d3d6a; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============== UTILITIES ============== */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-small  { font-size: 13px; }
.text-bold   { font-weight: 700; }
.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; border: none; }

/* Code-style inline */
code, .code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  background: #f1f3f5;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Avatar circle (placeholder por ahora) */
.avatar-circle {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700;
  border: 3px solid var(--accent);
  flex-shrink: 0;
}
.avatar-circle.lg { width: 120px; height: 120px; font-size: 48px; }
.avatar-circle.sm { width: 40px; height: 40px; font-size: 16px; border-width: 2px; }

/* Pill / Badge */
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.pill-primary   { background: rgba(165,0,68,0.1);    color: var(--primary); }
.pill-secondary { background: rgba(0,77,152,0.1);    color: var(--secondary); }
.pill-success   { background: var(--success-bg);     color: var(--success); }
.pill-warning   { background: var(--warning-bg);     color: var(--warning); }
.pill-error     { background: var(--error-bg);       color: var(--error); }

/* Lista limpia */
.list-clean { list-style: none; padding: 0; margin: 0; }
.list-clean li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-clean li:last-child { border-bottom: none; }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, #ececec 25%, #f5f5f5 50%, #ececec 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Install banner (PWA) */
.install-banner {
  position: fixed; bottom: calc(var(--nav-height) + 8px + var(--safe-bottom));
  left: 12px; right: 12px;
  background: var(--bg-card);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 12px;
  z-index: 60;
  animation: slideUp 0.3s ease-out;
  max-width: 540px; margin: 0 auto;
}
.install-banner .ib-icon { font-size: 28px; }
.install-banner .ib-text { flex: 1; font-size: 13px; }
.install-banner .ib-text strong { display: block; font-size: 14px; margin-bottom: 2px; }
.install-banner .ib-close {
  background: transparent; border: none; font-size: 20px; cursor: pointer;
  color: var(--text-light); padding: 0 4px;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============== RESPONSIVE ============== */
@media (max-width: 480px) {
  .auth-card { border-radius: 0; min-height: 100vh; min-height: 100dvh; box-shadow: none; }
  .auth-wrap { padding: 0; }
  .form-row { flex-direction: column; gap: 0; }
  .brand-text { font-size: 14px; }
}

/* Pantallas anchas: ocultar emoji del brand y agrandar el texto */
@media (min-width: 1024px) {
  .app-main { padding: 32px; max-width: 800px; }
}

/* Reducir motion para usuarios que lo prefieren */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============== AVATAR EN HEADER (agregar al app.css) ============== */

.header-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #fff;
    background: #fff;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s;
}
.header-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
    text-decoration: none;
}
.header-avatar svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Avatar SVG en general */
.avatar-svg {
    display: block;
    border-radius: 50%;
    overflow: hidden;
}

/* Versión grande para mi-perfil */
.profile-avatar {
    width: 140px; height: 140px;
    margin: 0 auto;
    border-radius: 50%;
    border: 4px solid #fff;
    box-shadow: var(--shadow);
    overflow: hidden;
    background: linear-gradient(135deg, #f5f6f8, #e9ecef);
}
.profile-avatar svg { width: 100%; height: 100%; }


/* ==================================================================
   FIXES COSMÉTICOS — agregar al final de assets/css/app.css
   v6 — fix scroll desktop + candado items locked + minor improvements
   ================================================================== */

/* ============== FIX 1: SCROLL EN DESKTOP ==============
   El padding-bottom de app-main era 64+safe+16 = ~80px, suficiente para
   el nav. Pero en desktop, cuando el contenido es largo, el último item
   queda tapado porque el cálculo no contempla bien el viewport.
   La solución: padding-bottom más generoso y asegurar que app-shell
   pueda scrollear correctamente.
*/
.app-main {
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 32px) !important;
    min-height: calc(100vh - var(--header-height));
    min-height: calc(100dvh - var(--header-height));
}

@media (min-width: 720px) {
    .app-main {
        padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 48px) !important;
    }
}

/* ============== FIX 2: CANDADO EN ITEMS LOCKED ==============
   Antes el candado se ponía como ::after de .shop-img y quedaba tapado por
   el botón "Faltan X". Lo movemos: el item locked tiene un overlay sobre toda
   la card, y el candado va encima del badge de rareza pero centrado.
*/
.shop-card.locked {
    opacity: 1;  /* quitamos la opacidad global, así el texto sigue legible */
    position: relative;
}
.shop-card.locked .shop-img {
    position: relative;
}
.shop-card.locked .shop-img::after {
    /* Sobreescribir la regla anterior: candado más grande, centrado, con fondo */
    content: '🔒';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 2;
    pointer-events: none;
}
.shop-card.locked .shop-img > svg {
    opacity: 0.4;
    filter: grayscale(60%);
}

/* El botón "Faltan X" más legible en items locked */
.shop-card.locked .shop-buy button[disabled] {
    background: #e5e7eb !important;
    color: #6b7280 !important;
    font-weight: 600;
    cursor: not-allowed;
    opacity: 1;
}

/* ============== FIX 3: ADMIN MOBILE (texto vertical) ==============
   El admin no era responsive y los textos se cortaban letra por letra
   en mobile (lo viste en eventos del admin).
*/
.admin-shell {
    overflow-x: hidden;
    word-wrap: break-word;
}
.admin-shell .event-row {
    flex-wrap: wrap;
}
.admin-shell .event-row .info {
    word-break: break-word;
    min-width: 0;
}
.admin-shell .event-row .actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
    margin-top: 8px;
}

@media (max-width: 720px) {
    .admin-shell {
        padding: 12px !important;
    }
    .admin-shell .event-row {
        flex-direction: column;
        align-items: stretch;
    }
    .admin-shell .event-row .cover-thumb {
        width: 100%;
        height: 120px;
    }
    .admin-shell .event-row .actions {
        margin-top: 0;
    }
    .admin-shell .form-row {
        flex-direction: column;
        gap: 0;
    }
    .admin-shell .gen-card,
    .admin-shell .table-card {
        padding: 16px !important;
    }
    .admin-shell h1 { font-size: 22px; }
    .admin-shell .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Header del admin más limpio en mobile */
@media (max-width: 720px) {
    header.app-header .brand {
        font-size: 13px !important;
    }
    header.app-header .user-info {
        gap: 6px;
        font-size: 12px;
    }
    header.app-header .user-info span {
        display: none;  /* ocultar el nombre completo en mobile */
    }
}

/* ============== FIX 4: CARD DE EVENTO EN DASHBOARD MEJOR ============== */
.event-cta .cover {
    background-color: var(--primary);  /* color de fondo si la imagen falla */
}

/* ============== FIX 5: SHOP MEJORADO ============== */
/* El balance del shop se ve mejor con avatar visible */
.shop-balance {
    flex-wrap: wrap;
    gap: 12px;
}
@media (max-width: 480px) {
    .shop-balance .val { font-size: 24px; }
    .shop-balance .lbl { font-size: 11px; }
}

/* Cards de shop con altura uniforme */
.shop-card {
    height: 100%;
}
.shop-info {
    flex: 1;  /* empuja el footer hacia abajo, cards se alinean */
}