:root {
    --bg: #202830;
    --surface-nav: #486078;
    --surface-card: #304050;
    --surface-inset: #182028;
    --surface-hover: #203040;
    --border: #182028;
    --frame: #e8e8e8;
    --accent: #f8d800;
    --blue: #2c5cc3;
    --green: #48c878;
    --purple: #c878f8;
    --red: #d82800;
    --text: #f8f8f8;
    --muted: #c8d2dc;
    --muted-2: #a8b4c0;
    --topbar-height: 4.5rem;
}

body {
    color-scheme: dark;
    font-family: 'Pixelify Sans', sans-serif;
    background-color: var(--bg);
    background-image: linear-gradient(var(--surface-inset) 2px, transparent 2px), linear-gradient(90deg, var(--surface-inset) 2px, transparent 2px);
    background-size: 32px 32px;
    background-attachment: fixed;
    color: var(--text);
    font-size: 1.25rem;
    /* Evita negritas/itálicas sintetizadas (borrosas) si el navegador no
       encuentra un peso real de la fuente pixel */
    font-synthesis: none;
}

/* Identidad retro: solo el logotipo LMTD conserva la fuente pixel */
.font-gba { font-family: 'Press Start 2P', cursive; }

/* --- Sistema de diseño --- */

.card {
    background-color: var(--surface-card);
    border: 2px solid var(--frame);
    /* Sombra dura estilo GBA: asienta la caja sobre la cuadrícula del fondo */
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.45);
}

.card-header {
    background-color: var(--surface-nav);
    border-bottom: 2px solid var(--frame);
    padding: 12px 16px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background-color: var(--surface-nav);
    border-bottom: 2px solid var(--frame);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
    will-change: transform;
}

.btn {
    background-color: var(--blue);
    border: 2px solid var(--frame);
    color: #fff;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 120ms ease, transform 80ms ease;
}
.btn:hover { background-color: #3a6fd8; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Variante peligro: solo acciones destructivas/irreversibles */
.btn-danger { background-color: var(--red); }
.btn-danger:hover { background-color: #f04030; }

.btn-secondary {
    background-color: transparent;
    color: var(--text);
}
.btn-secondary:hover { background-color: var(--surface-hover); }

.input {
    background: var(--surface-inset);
    border: 1px solid #708090;
    color: var(--text);
    font-family: inherit;
    padding: 10px 12px;
    width: 100%;
}
.input:focus { border-color: var(--accent); outline: none; }
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Insignias tipo píldora (rangos, estado pendiente) */
.badge {
    display: inline-flex;
    align-items: center;
    border: 1px solid currentColor;
    padding: 1px 10px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* --- Tarjetas de Pokémon (expositor público y peticiones) --- */

.poke-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.poke-card {
    position: relative;
    background-color: var(--surface-inset);
    border: 2px solid var(--frame);
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.4);
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 160px;
    transition: border-color 120ms ease, background-color 120ms ease;
}
.poke-card:hover { background-color: var(--surface-hover); }

.pixel-rendering { image-rendering: pixelated; }

/* Evita el retraso/zoom de doble toque en controles táctiles
   (.drag-handle mantiene su propio touch-action: none) */
button, a, select, input, label.tag-checkbox {
    touch-action: manipulation;
}

/* Sin animaciones para quien pide movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    .sprite-container,
    .sprite-container::before,
    .tag-tooltip,
    .btn,
    .nav-item,
    .menu-row,
    .poke-card,
    .chat-widget, #chat, .chatbox, .chat-embed {
        transition: none !important;
    }
    .group:hover .sprite-container { transform: none; }
}

/* Shiny normal no tiene aura */
.sprite-shiny { filter: none; }
/* Alfa: aura dorada */
.sprite-alfa { filter: drop-shadow(0 0 4px rgba(248, 216, 0, 0.8)); }

/* Pokémon perdidos/vendidos: gris + atenuado; el aura alfa sigue brillando en color */
.sprite-shiny.perdido { filter: grayscale(100%); opacity: 0.8; }
.sprite-alfa.perdido { filter: grayscale(100%) drop-shadow(0 0 4px rgba(248, 216, 0, 0.8)); opacity: 0.8; }

.sprite-container { z-index: 10; position: relative; transition: transform 0.1s steps(2); }
.group:hover .sprite-container { transform: translateY(-4px); }

/* Partículas brillantes en hover para todos los shinys */
.sprite-container::before {
    content: '';
    position: absolute;
    top: -10%; left: -10%; right: -10%; bottom: -10%;
    pointer-events: none;
    background-image: url('/static/shiny_particle.gif');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 70%;
    opacity: 0;
    z-index: 20;
    transition: opacity 0.2s ease-in-out;
    mix-blend-mode: screen;
}
.group:hover .sprite-container::before { opacity: 0.75; }

.tag-icon-btn {
    background: none;
    border: none;
    padding: 2px;
    margin: -2px;
    cursor: pointer;
}

.tag-tooltip {
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

/* Tooltip visible con hover (ratón), foco (teclado) o tap (táctil, clase .is-active vía JS) */
.tag-icon-btn:hover .tag-tooltip,
.tag-icon-btn:focus-visible .tag-tooltip,
.tag-icon-btn.is-active .tag-tooltip {
    opacity: 1;
}

.tag-checkbox input:checked + div {
    border-color: var(--accent);
    background-color: var(--surface-hover);
}

.tag-checkbox input:focus-visible + div {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Visually hidden but still focusable/tabbable, unlike display:none */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--surface-inset); }
::-webkit-scrollbar-thumb { background: var(--surface-nav); border: 2px solid var(--surface-inset); }
::-webkit-scrollbar-thumb:hover { background: #56708c; }

/* Ajustes genéricos para widgets de chat — selectores no invasivos */
.chat-widget, #chat, .chatbox, .chat-embed {
    transition: top 120ms ease, margin-top 120ms ease;
}

/* --- Barra lateral del panel (dashboard) --- */

.sidebar {
    background-color: var(--surface-nav);
    border-right: 1px solid var(--border);
    /* En móvil la barra es horizontal (sombra hacia abajo); en escritorio es
       columna izquierda (sombra hacia la derecha) */
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}
@media (min-width: 768px) {
    .sidebar { box-shadow: 4px 0 0 rgba(0, 0, 0, 0.35); }
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: none;
    border-left: 3px solid transparent;
    background: none;
    color: var(--muted);
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: color 120ms ease, background-color 120ms ease;
}
.nav-item:hover { color: var(--text); background-color: #56708c; }
.nav-item.active {
    border-left-color: var(--accent);
    color: var(--accent);
    background-color: rgba(24, 32, 40, 0.35);
}
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* --- Listas del panel (Pokémon, entrenadores) --- */

.menu-row {
    position: relative;
    transition: background-color 120ms ease, border-color 120ms ease;
}
.menu-row:hover,
.menu-row:focus-within { background-color: var(--surface-hover); border-color: var(--accent); }

/* Asa de arrastre para reordenar la lista de Pokémon con ratón/táctil */
.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
    margin: -4px;
    color: var(--muted);
    cursor: grab;
    touch-action: none;
}
.drag-handle:hover { color: var(--accent); }
.menu-row.dragging {
    opacity: 0.6;
    border-color: var(--accent);
    cursor: grabbing;
}
.menu-row.dragging .drag-handle { cursor: grabbing; }

/* Tarjetas de peticiones pendientes */
.ticket-card { border-style: dashed; }
