
/* ==========================================================================
   CONFIGURACIÓN OPTIMIZADA - BUSCADOR Y FILTROS
   ========================================================================== */
/* =========================================
   1. VARIABLES GLOBALES
   ========================================= */
:root {
    --res-img-radius: 6px;
    --primary-color: #4A90E2;
    --accent-color: #a7ffeb;
    --bg-dark: #1a1a1a;
    --border-color: #d1d5db; /* Actualizado al último valor */
    --max-ui-width: 400px;
}



.submenu-container {
  padding-left: 20px; /* Desplaza todo el bloque hacia la derecha */
  border-left: 2px solid #eee; /* Opcional: una línea guía visual */
  margin-left: 10px;
}

/* Ajuste específico por nivel si quieres más profundidad */
.flag-lvl-2 {
  margin-left: 15px !important;
  width: calc(100% - 15px) !important;
}

.flag-lvl-3 {
  margin-left: 30px !important;
  width: calc(100% - 30px) !important;
}

/* Asegúrate de que el contenido interno no se desborde */
.result-item-horizontal {
  display: flex;
  align-items: center;
  box-sizing: border-box;
}


/* =========================================
   3. BARRA DE FILTROS Y BOTONES
   ========================================= */
/* =========================================
   3. BARRA DE FILTROS + BARRA DESLIZANTE SIEMPRE VISIBLE
   ========================================= */
.filter-bar-scroll {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 10px 5px 10px 5px;
    overflow-x: scroll !important;           /* ← BARRA SIEMPRE VISIBLE */
    overflow-y: hidden !important;
    position: relative;
    z-index: 100;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin !important;
    scrollbar-color: #bbbbbb #f5f5f5 !important;
}

/* Barra siempre visible en Chrome/Edge/Safari */
.filter-bar-scroll::-webkit-scrollbar {
    display: block !important;
    height: 8px !important;
}
.filter-bar-scroll::-webkit-scrollbar-track {
    background: #f5f5f5 !important;
}
.filter-bar-scroll::-webkit-scrollbar-thumb {
    background: #bbbbbb !important;
    border-radius: 10px;
}

.filter-btn, .filter-main-btn {
    flex: 0 0 auto;
    height: 34px;
    padding: 0 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    font-family: 'Fira Sans Condensed', sans-serif;
}

.filter-btn:hover, .filter-main-btn:hover {
    background: #f5f5f5;
}

#filter-divider {
    max-width: var(--max-ui-width);
    border: 0;
    border-top: 1px solid #eee;
    margin: 0 auto 15px;
}

/* =========================================
   4. MENÚS DESPLEGABLES (DROPDOWNS) - CORREGIDO
   ========================================= */
.filter-group {
    position: relative !important;           /* ← CLAVE para que salga debajo del botón */
    display: inline-block;
    flex: 0 0 auto;
}

 
.filter-opt {
    padding: 10px 15px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.2s;
}

.filter-opt:hover {
    background-color: #f0f7ff;
}

.filter-opt.selected {
    background-color: #e3f2fd;
    color: #1976d2;
    font-weight: bold;
}

/* Opciones complejas (Switches en dropdown) */
.filter-row-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
    min-width: 140px;
}

.filter-row-item:hover {
    background-color: #f5f5f5;
}

.filter-opt-label {
    font-size: 14px;
    color: #333;
}

.filter-row-item[data-state="2"] {
    background-color: #fff5f5;
}

.filter-row-item[data-state="2"] .filter-opt-label {
    color: #e74c3c;
    text-decoration: line-through;
    font-weight: 500;
}

.filter-clear-all-btn {
    margin-right: 8px;
    margin-left: 0;
    flex-shrink: 0;
}

/* =========================================
   5. MINI SWITCH (TOGGLES)
   ========================================= */
.mini-switch {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 16px;
    pointer-events: none;
}

.mini-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.mini-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: background-color 0.2s, transform 0.2s;
    border-radius: 16px;
}

.mini-slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .mini-slider,
.filter-row-item[data-state="1"] .mini-slider {
    background-color: #2ecc71 !important;
}

.filter-row-item[data-state="2"] .mini-slider {
    background-color: #e74c3c !important;
}

input:checked + .mini-slider:before,
.filter-row-item[data-state="1"] .mini-slider:before,
.filter-row-item[data-state="2"] .mini-slider:before {
    transform: translateX(12px);
}

/* =========================================
   6. BARRA SECUNDARIA (TRI-BUTTONS & SORT)
   ========================================= */
.secondary-actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 5px;
    gap: 8px;
    max-width: var(--max-ui-width);
    margin: 0 auto;
    box-sizing: border-box;
    font-family: 'Fira Sans', sans-serif;
    position: relative;
    z-index: 1;
}

.tri-button-group {
    display: flex;
    background: #eee;
    padding: 2px;
    border: 1px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
}

.tri-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: 'Fira Sans', sans-serif;
}

.tri-btn.active {
    background: white;
    color: var(--primary-color);
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#select-sort-order {
    flex: 1;
    max-width: 140px;
    height: 32px;
    padding: 0 25px 0 8px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    color: #374151;
    font-family: 'Fira Sans', sans-serif;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    text-overflow: ellipsis;
}

#select-sort-order:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* =========================================
   7. LISTA DE RESULTADOS Y CARDS
   ========================================= */
#results-list {
    background-color: #ffffff;
    max-width: var(--max-ui-width);
    margin: 20px auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.result-item {
    display: flex;
    align-items: center;
    width: 100% !important;
    padding: 10px;
    gap: 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
    background-color: #ffffff !important;
    margin-left: 0 !important;
    box-sizing: border-box;
}

.result-item:hover {
    background-color: #f9f9f9 !important;
}

.result-item.flag-item {
    flex-direction: row;
    padding: 12px 10px;
    gap: 12px;
    position: relative;
}

/* Imagen de la bandera / visual */
.result-visual {
    width: 55px;
    height: 37px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eee;
    border: 1px solid #000;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.result-visual img {
    width: 100%;
    height: 100%;
    object-fit: fill; /* Fuerza la bandera a ocupar el cuadro */
    display: block;
  
}

/* Bloque central de texto */
.result-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    flex-grow: 1;
    overflow: hidden;
    min-width: 0;
    padding-left: 4px;
}

.result-name {
    font-weight: 800;
    font-size: 16px;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    margin-bottom: 2px;
}

.result-description {
    font-size: 14px;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
    line-height: 1.3;
}

/* =========================================
   8. BOTÓN DE AÑADIR (VERDE OSCURO NEUMÓRFICO)
   ========================================= */
.btn-add-item {
    width: 34px;
    height: 34px;
    min-width: 34px;
    background: #ffffff;
    border: 1.5px solid #1e4620; /* Verde oscuro */
    border-radius: 50%;
    cursor: pointer;
    font-size: 22px;
    font-weight: 400;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1e4620;
    flex-shrink: 0;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-left: 10px;
}

.btn-add-item:hover {
    background: #1e4620;
    color: #ffffff;
    border-color: #1e4620;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(74, 144, 226, 0.3);
}

.btn-add-item:active {
    transform: scale(0.95);
}

/* =========================================
   9. JERARQUÍA Y SUBMENÚS (NIVELES)
   ========================================= */
.submenu-container {
    background-color: #ffffff !important;
    border-left: 3px solid #d1d5db;
    margin-left: 0 !important;
    width: 100% !important;
}

.flag-lvl-1, .flag-lvl-2, .flag-lvl-3 {
    background-color: #ffffff !important;
    margin-left: 0 !important;
    width: 100% !important;
}

.flag-lvl-2 { padding-left: 20px !important; }
.flag-lvl-3 { padding-left: 40px !important; }

/* Ajuste de texto para los subniveles */
.flag-lvl-2 .result-name { font-size: 15px; }
.flag-lvl-2 .result-description { font-size: 13px; }

.flag-lvl-3 .result-name { font-size: 14px; }
.flag-lvl-3 .result-description { font-size: 12px; }

/* Items específicos submenú */
.flag-item-lvl2, .flag-item-lvl3 {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.flag-item-lvl2 .result-visual, 
.flag-item-lvl3 .result-visual {
    width: 30px;
    height: 16px;
}

.flag-item-lvl2 .result-visual img, 
.flag-item-lvl3 .result-visual img {
    width: 30px;
    height: auto;
    border-radius: 4px;
    object-fit: cover;
}

.btn-lvl2-action {
    width: 28px;
    height: 28px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-lvl2-action:hover {
    background: var(--primary-color);
    color: white;
}

/* Indentaciones extras para estructuras anidadas */
.submenu-lvl2 { margin-left: 20px; border-left: 2px solid #eee; }
.submenu-lvl3 { margin-left: 40px; border-left: 2px solid #ddd; }

/* =========================================
   10. LOADERS Y ANIMACIONES
   ========================================= */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes spin-loader {
    to { transform: rotate(360deg); }
}

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

.loader-row {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
    width: 100%;
    background: rgba(46, 204, 113, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.spinner-loader {
    width: 28px;
    height: 28px;
    border: 4px solid rgba(30, 70, 32, 0.1); /* Verde suave de fondo */
    border-radius: 50%;
    border-top-color: #1e4620; /* Verde oscuro girando */
    animation: spin 0.8s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.search-loader-mini {
    width: 28px;
    height: 28px;
    border: 3px solid #f3f3f3;
    border-top-color: #1e4620 !important;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

.spinner-tiny {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin-loader 0.6s linear infinite;
    vertical-align: middle;
}

/* =========================================
   11. MEDIA QUERIES (RESPONSIVE)
   ========================================= */
@media (max-width: 360px) {
    .search-btn-internal {
        padding: 0 8px;
        font-size: 11px;
    }
    .filter-btn {
        flex-basis: 90px !important;
        font-size: 11px;
    }
}

/* MENÚ DE AJUSTES OCULTO (Para compatibilidad con tu código JS) */
#settings-menu {
    display: none;
    position: absolute;
    background: var(--bg-dark);
    border: 1px solid #444;
    border-radius: 8px;
    min-width: 150px;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    padding: 6px 0;
}

.lang-option {
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: #fff;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
}

.lang-option:hover {
    background: #333;
    color: var(--accent-color);
}

/* Fila de burbujas: sin límite de altura y fondo transparente */
.active-bubbles-row {
  margin-top: 10px !important;    /* Separación extra sobre las burbujas */
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0; /* Sin padding lateral para que alinee con el resto */
    background: transparent !important; 
    min-height: 20px;
}

/* Acordeones: Títulos más grandes y sin fondo */
.filter-subheader {
    font-size: 16px !important; /* Títulos más grandes */
    font-weight: 800 !important;
    padding: 12px;
    background: transparent !important; /* Sin fondo diferente */
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #333;
    text-transform: uppercase;
}

/* El contenedor del dropdown sí puede tener scroll si hay demasiadas opciones, 
   pero las burbujas NO. */


/* 2. COLORES DE LOS BOTONES DEL SUBMENÚ */
.search-input-field {
  width: 100%;
  height: 42px;
  /* Ajustado el padding derecho al quitar el botón (antes era 90px) */
  padding: 8px 15px 8px 38px;
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: 16px;
  border: 1px solid #979797;
  border-radius: 8px;
  /* Lupa de búsqueda rediseñada, más nítida y mejor posicionada */
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") no-repeat 12px center / 16px;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

/* Elimina el código CSS de .search-btn-internal si aún lo tienes, ya no lo necesitas */
.search-btn-internal {
  display: none !important;
}
/* Estado 1: VERDE (Seleccionado) */
.filter-row-item[data-state="1"] {
    background-color: rgba(40, 167, 69, 0.15) !important;
    border-left: 4px solid #28a745;
}
.filter-row-item[data-state="1"] .filter-opt-label {
    color: #1e7e34;
    font-weight: bold;
}

/* Estado 2: ROJO (Excluido / No Touch) */
.filter-row-item[data-state="2"] {
    background-color: rgba(220, 53, 69, 0.15) !important;
    border-left: 4px solid #dc3545;
}
.filter-row-item[data-state="2"] .filter-opt-label {
    color: #bd2130;
    font-weight: bold;
}

/* Estilo base para que el hover se note */
.filter-row-item {
    transition: background 0.2s;
    border-left: 4px solid transparent;
}

/* Reducir espacio vertical */
#dynamic-filter-bar {
    padding: 5px 0 !important;
    margin-bottom: 0 !important;
}

#filter-divider {
    margin: 5px 0 !important; /* Casi pega los filtros a la siguiente fila */
    opacity: 0.3;
}

.secondary-actions-row {
    margin-top: 0 !important;
    padding-top: 5px !important;
}

.active-bubbles-row {
    padding: 5px 0 !important; /* Burbujas más compactas */
}


/* Evitar que el texto de los filtros se rompa en mil líneas */
.filter-opt-label {
    white-space: nowrap;
    padding-right: 20px;
}


/* Contenedor de burbujas: que crezca hacia abajo y respete el ancho */
.active-bubbles-row {
    display: flex;
    flex-wrap: wrap; /* Permite que salten de línea */
    gap: 6px;
    padding: 5px 0 !important;
    width: 100%;
    max-width: var(--max-ui-width); /* Los 400px */
    margin: 0 auto;
    background: transparent !important;
}



/* Eliminar el espacio entre filtros y resultados */
#dynamic-filter-bar {
    padding: 5px 0 0 0 !important; /* Solo padding superior leve */
    margin-bottom: 0 !important;
}

#filter-divider {
    margin: 0 auto !important; /* Elimina el margen de 15px que tenías */
    padding: 0 !important;
    border-top: 1px solid #eee;
    max-width: var(--max-ui-width);
}

.secondary-actions-row {
    margin-top: 0 !important; /* Pega los botones de Results/New/Missed al divisor */
    padding-top: 5px !important;
    padding-bottom: 5px !important;
}

/* Quitar margen superior de la lista de resultados */
#results-list {
    margin-top: 0 !important; 
    padding-top: 0 !important;
}



.filter-opt-label {
    white-space: normal !important; /* Permite que el texto largo salte de línea */
    word-wrap: break-word;
    font-size: 13px;
    line-height: 1.2;
}

/* --- COLORES DE LAS BURBUJAS (Activas) --- */
.filter-bubble {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s;
}

/* Color Verde (Estado 1: Incluir) */
.bubble-green {
    background-color: #e6ffed !important;
    color: #28a745 !important;
    border: 1px solid #28a745;
}

/* Color Rojo (Estado 2: Excluir) */
.bubble-red {
    background-color: #ffeef0 !important;
    color: #dc3545 !important;
    border: 1px solid #dc3545;
}

.filter-bubble:hover {
    transform: scale(1.05);
}

#dynamic-filter-bar {
  padding-bottom: 0 !important; /* Elimina espacio inferior */
}

.active-bubbles-row {
  padding-top: 0 !important;
  margin-top: -5px; /* Sube las burbujas para pegarlas a los botones */
  margin-bottom: 5px;
}

#filter-divider {
  margin: 0 auto !important; /* Quita el margen de 15px que separa la línea */
}




/* --- ESTILO DE LAS OPCIONES (No Touch, etc) --- */
.filter-opt-label {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    text-transform: none !important; /* Asegura texto normal */
    white-space: nowrap;
}

.filter-opt-label:hover {
    background-color: #f5f5f5;
}




/* --- ESTILO DE LAS OPCIONES --- */
.filter-opt-label {
    display: flex !important;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    text-transform: none !important; /* Normalizado */
    border-bottom: 1px solid #f0f0f0;
}

.filter-opt-label:last-child { border-bottom: none; }
.filter-opt-label {
    text-transform: capitalize !important; /* Pone la primera en Mayus y el resto normal */
}
.filter-opt-label:hover { background-color: #f8f9fa; }

/* --- COLORES DE LAS BURBUJAS --- */
.filter-bubble.bubble-green { background: #e6ffed !important; color: #22863a !important; border: 1px solid #22863a; }
.filter-bubble.bubble-red { background: #ffeef0 !important; color: #cb2431 !important; border: 1px solid #cb2431; }

/* Reducir altura de las sub-líneas (Blue, Red, etc.) */
.filter-row-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px !important; /* Altura reducida */
    min-height: 28px !important;    /* Altura mínima menor */
    cursor: pointer;
    transition: background 0.2s;
}

/* Texto más a la izquierda y ajustes de fuente */
.filter-opt-label {
    flex: 1;              /* Empuja el switch al final */
    text-align: left;     /* Texto a la izquierda */
    font-size: 13px;      /* Un poco más pequeño para que quepa mejor */
    padding-right: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ajuste del switch para que no se vea gigante en líneas pequeñas */
.mini-switch {
    width: 24px !important;
    height: 14px !important;
    flex-shrink: 0;
}

.mini-slider:before {
    height: 10px !important;
    width: 10px !important;
    left: 2px !important;
    bottom: 2px !important;
}




:root {
    --max-ui-width: 500px; /* Aumenta este valor (antes 400px). Prueba con 500px o 600px */
}
.tri-btn {
    cursor: pointer !important;
}


/* Estilo base del botón basado en tu diseño de .flag-close-btn */
.btn-add-item.flag-toggle-btn {
  margin-top: 0; /* Ajustado para el item de la lista */
  padding: 0;
  width: 32px;
  height: 32px;
  background-color: #004a35;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  transition: background-color 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.btn-add-item.flag-toggle-btn:hover {
  background-color: #00664e;
}

/* Estado cuando está abierto (cambia a X) */
.btn-add-item.flag-toggle-btn.is-active {
  background-color: #666; /* Color más neutro para cerrar */
}

.btn-add-item.flag-toggle-btn.is-active .icon-state {
  transform: rotate(0deg); /* Opcional: puedes rotar el + para que sea x */
}

/* Estilo para las X de cierre de modales que pasaste (para mantener consistencia) */
.flag-close-x {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  font-weight: bold;
  z-index: 10000;
}
.flag-close-x:hover { color: #000; }
.flag-toggle-btn.is-active .icon-state {
    color: red;
    transform: rotate(45deg); /* If you want to rotate the + to make an x */
}

.expand-btn {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  cursor: pointer;
  background-color: #f3f3f3;
  color: black !important;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;

  /* Fuente Fira Sans */
  font-family: 'Fira Sans', sans-serif;
  font-size: 20px;
  font-weight: 700;

  transition: all 0.1s ease;
  box-sizing: border-box;
  padding: 0;

  /* Sombreado de botón real (Exterior para elevar, interior para borde) */
  box-shadow: 0 2px 4px rgba(0,0,0,0.15), 
              inset 0 -1px 0 rgba(0,0,0,0.2);
}

.expand-btn:hover {
  background-color: #eeeeee;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2), 
              inset 0 -1px 0 rgba(0,0,0,0.2);
}

/* Efecto de hundirse al clicar */
.expand-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1), 
              inset 0 1px 2px rgba(0,0,0,0.2);
  background-color: #e9e9e9;
}

/* Estado cuando está abierto (-) */
.expand-btn.is-active {
  background-color: #e0e0e0;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
  color: #333 !important;
}

/* Nivel 1: Original / Blanco */
.flag-lvl-1 {
    background-color: #ffffff;
}

/* Nivel 2: 10% de gris (Gris muy claro) */
.flag-lvl-2 {
    background-color: rgba(0, 0, 0, 0.10); /* 10% negro sobre el fondo */
    border-left: 3px solid #ccc; /* Opcional: guía visual */
}

/* Nivel 3: 20% de gris */
.flag-lvl-3 {
    background-color: rgba(0, 0, 0, 0.20); /* 20% negro */
    border-left: 3px solid #aaa;
}

/* Si tu contenedor tiene bordes o líneas separadoras */
.submenu-lvl2 {

    border-top: 1px solid rgba(0,0,0,0.1);
}
.submenu-lvl3 {
    border-top: 1px solid rgba(0,0,0,0.2);
}

.result-item.flag-lvl-3 {
  background-color: rgb(242, 231, 212) !important; /* Gris suave */
  border-bottom: 1px solid #ddd; /* Separación sutil */
}
 .result-item.flag-lvl-2 {
   background-color: rgb(255, 255, 255) !important; /* Gris suave */
   border-bottom: 1px solid #ddd; /* Separación sutil */
 }




/* Modificar la estructura base para el ancho y bloqueo de scroll */
body {
    overflow-x: hidden; /* Evita el movimiento horizontal en toda la página */
    width: 100%;
}

:root {
    /* Ajustamos el máximo a 500px como pediste */
    --max-ui-width: 500px;
}

/* Limitar estrictamente los contenedores a 500px */
.search-wrapper, 
#dynamic-filter-bar, 
#filter-divider, 
.secondary-actions-row, 
#results-list,
.active-bubbles-row {
    width: 100% !important;
    max-width: 500px !important; 
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
}
/* 1. Separar la barra de búsqueda del título */
.search-wrapper {
    margin-top: 25px !important; /* Ajusta este valor para separarlo más del título */
    position: relative !important;
}

 

/* Asegurar que el contenedor de la barra no corte los hijos */
#dynamic-filter-bar {
    overflow: visible !important; /* Para que el dropdown pueda salir */
    display: flex;
    gap: 8px;
    padding: 10px 0;
}

/* Contenedor de scroll para los botones */
.filter-bar-scroll {
    overflow-x: auto !important;
    overflow-y: visible !important; /* CLAVE: permitir que el dropdown sea visible */
    padding-bottom: 5px;
}
/* Evitar que el contenedor interno de filtros desborde su padre */
.filter-bar-scroll {
    width: 100% !important;
    max-width: 100% !important;
}

/* Banderas más pequeñas para subdivisiones (Lvl 2 y 3) */
.flag-item-lvl2 .result-visual, 
.flag-item-lvl3 .result-visual {
    width: 32px !important;  /* Reducido de 40px */
    height: 20px !important; /* Reducido de 26px */
}

.flag-item-lvl2 .result-visual img, 
.flag-item-lvl3 .result-visual img {
    width: 32px !important;
    height: auto !important;
}



/* ====================== FORMATO SUBMENÚS (Shape, Colors, No Touch, etc.) ====================== */
.filter-category-block {
    margin-bottom: 14px !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.filter-subheader {
    font-size: 15px !important;
    font-weight: 700 !important;
    padding: 11px 15px !important;
    background: linear-gradient(90deg, #f8f9fa, #e9ecef) !important;
    color: #212529 !important;
    border-bottom: 1px solid #ddd !important;
    border-radius: 9px 9px 0 0 !important;
    letter-spacing: 0.3px;
}

.filter-subheader:hover {
    background: linear-gradient(90deg, #e9ecef, #dee2e6) !important;
}

/* Color especial para "No Touch" y similares */
.filter-subheader:has-text("No Touch"),
.filter-subheader:has-text("Touch") {
    background: linear-gradient(90deg, #fff3cd, #ffeaa7) !important;
    color: #856404 !important;
}

/* Acordeón más limpio */
.accordion-content {
    padding: 6px 0 10px 0 !important;
}



/* ====================== SUBDIVISIONES MÁS PEQUEÑAS (lvl 2 y 3) ====================== */
.result-item-horizontal.flag-lvl-2,
.result-item-horizontal.flag-lvl-3 {
    padding: 7px 10px !important;
    gap: 10px !important;
}


.flag-lvl-2 .result-visual {
    width: 46px !important;
    height: 31px !important;           /* ratio ≈ 3:2 de banderas */
    flex-shrink: 0;
}

.flag-lvl-2 .result-visual img {
    width: 46px !important;
    height: 31px !important;
    object-fit: fill !important;
    border-radius: 4px !important;
}


.flag-lvl-3 .result-visual {
    width: 40px !important;
    height: 27px !important;           /* ratio ≈ 3:2 de banderas */
    flex-shrink: 0;
}

.flag-lvl-3 .result-visual img {
    width: 40px !important;
    height: 27px !important;
    object-fit: fill !important;
    border-radius: 4px !important;
}

.flag-lvl-2 .result-name,
.flag-lvl-3 .result-name {
    font-size: 13.2px !important;
    line-height: 1.2 !important;
}

.flag-lvl-2 .result-description,
.flag-lvl-3 .result-description {
    font-size: 11.5px !important;
}

.flag-lvl-2 .expand-btn,
.flag-lvl-3 .expand-btn {
    width: 24px !important;
    height: 24px !important;
    font-size: 17px !important;
    padding: 0 !important;
}

/* ====================== FIX FINAL - BARRA SIEMPRE VISIBLE + DROPDOWN EXACTO DEBAJO DEL BOTÓN ====================== */
/* BORRA TODO LO ANTERIOR sobre #dynamic-filter-bar y .filter-dropdown-content */
/* PEGA ESTO AL FINAL DEL TODO de tu <style> (justo antes de </style>) */

#dynamic-filter-bar,
.filter-bar-scroll {
    max-width: 500px !important;               /* limitado al container */
    margin: 0 auto !important;
    overflow-x: auto !important;               /* barra cuando haga falta */
    overflow-y: hidden !important;
    scrollbar-width: thin !important;
    scrollbar-color: #bbbbbb #f5f5f5 !important;
}
 

/* ====================== DROPDOWN GRANDE Y EXACTAMENTE DEBAJO DEL BOTÓN ====================== */
.filter-group {
    position: relative !important;             /* ← CLAVE para que salga justo debajo */
}

/* Posicionamiento relativo para el botón contenedor */
.filter-group {
    position: relative !important;
    display: inline-block;
    flex: 0 0 auto;
}
 

/* Evita que nada corte el dropdown ni la barra */



/* Subcategorías más a la izquierda */
.filter-row-item {
    padding-left: 8px !important;
}

.filter-opt-label {
    padding-left: 6px !important;
    text-align: left !important;
}


/* 1. Separar el buscador del título (25px de margen) */
.search-wrapper {
    margin-top: 25px !important; 
    position: relative !important;
}
.search-input-field {
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") no-repeat 12px center / 18px !important;
    padding-left: 42px !important;
}

/* 2. El dropdown ahora es FIXED para que no lo corte el overflow del padre */
.filter-dropdown-content {
    display: none;
    position: fixed !important; /* <--- CLAVE: sale del flujo de la barra */
    width: 300px !important;
    max-width: 80vw !important; 
    max-height: 500px !important;
    background: white !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4) !important;
    border-radius: 12px !important;
    border: 1px solid #ddd !important;
    z-index: 1000000 !important;
    overflow-y: auto !important;
    /* Eliminamos top/left de aquí, los pondrá el JS */
}

/* 3. Mantener la barra con scroll horizontal */
.filter-bar-scroll {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 10px 5px;
    overflow-x: auto !important;
    overflow-y: hidden !important; /* Esto ya no romperá el menú porque es fixed */
    -webkit-overflow-scrolling: touch;
}

/* Limitamos el ancho de las subdivisiones */
.flag-lvl-2, .flag-lvl-3 {
    max-width: 400px !important;
    margin-right: auto; /* Alineado a la izquierda */
}

/* Contenedor del nombre con alineación de rejilla */
.name-row {
    display: grid;
    /* Columna 1: Nombre (220px), Columna 2: Botón (30px) */
    grid-template-columns: 220px 30px; 
    align-items: center;
    gap: 5px;
}

.result-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Corta el texto si supera los 220px */
}

/* Botones alineados en su columna */
.expand-btn {
    grid-column: 2;
    background: #eeeeee !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0 !important;
}

/* Sangrías para niveles */
.flag-lvl-2 { padding-left: 20px !important; border-left: 2px solid #eee; }
.flag-lvl-3 { padding-left: 40px !important; border-left: 2px solid #ddd; }
/* =======================================================================================================================================================================================
   1. GLOBAL
============================= */
body {
  font-family: 'Fira Sans Condensed', sans-serif;
  background: #f2f2f2;
  margin: 0;
  padding: 0;
  overflow-x: hidden; /* evita scroll lateral */
  background-color: #f5f5f5;
  padding-top: 40px; /* ajusta según altura del header */
}

/* =============================
   2. CONTENEDOR PRINCIPAL
============================= */
.flagdoku-container {
  max-width: 600px;
  width: 100%;
  margin: auto;
  padding: 16px;
  background: white;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* =============================
   3. ENCABEZADO (HEADLINE)
============================= */
.headline {
  background-color: rgba(33, 51, 46, 0.98);
  color: #fff;
  padding: 6.5px 16px;
  font-family: 'Fira Sans', sans-serif;
  font-weight: 600;
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  box-sizing: border-box;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.headline-text {
  flex-grow: 1;
  text-align: left;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.headline-line {
  width: 100%;
  height: 1px;
  background-color: #fff;
}

/* =============================
   4. MENÚ Y ENLACES
============================= */
.menu-link {
  display: inline-flex;
  align-items: center;
  margin-left: 10px;
  cursor: pointer;
  text-decoration: none;
  color: white;
  font-size: 12px;
  font-family: 'Fira Sans', sans-serif;
  line-height: 1;
}

.menu-link:hover { color: #25d96a; }
.menu-link .icon { font-size: 12px; line-height: 1; }
.menu-link .label { margin-top: 4px; }

/* =============================
   5. BÚSQUEDA Y FILTROS
============================= */
.search-input {
  width: 100%;  /* ocupa todo el ancho del bloque de filtros */
  margin: 12px 0;
padding: 8px 12px 8px 30px;
  font-size: 16.1px;
  border: 1px solid rgb(151, 151, 151);
  border-radius: 8px;
  background: #ffffff;
  display: block;
  box-sizing: border-box;
  font-family: 'Fira Sans Condensed';
}

/* para que herede ese ancho, mételo dentro del mismo contenedor que los botones */
.filters .search-input {
  flex: 1; /* se expande como los botones combinados */
}
/* Para pantallas grandes (PC) */
@media (min-width: 768px) {
  .search-input {
    max-width: 600px; /* ⬅️ más ancho en PC */
  }
}

.filters {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  padding: 6px 2px;
  justify-content: flex-start;
  -webkit-overflow-scrolling: touch;
}

.filters::-webkit-scrollbar { height: 6px; }
.filters::-webkit-scrollbar-thumb {
  background: #c9c9c9;
  border-radius: 4px;
}

.dropdown-wrapper {
  flex: 0 0 auto;
  width: 120px;
  display: flex;
  justify-content: center;
}

.filter-btn {
  width: 100%;
  padding: 4px 2px;
  background: #dfeffc;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: 'Fira Sans Condensed', sans-serif;
  white-space: nowrap;
  text-align: center;
  height: 32px;
  line-height: 1.2;
  overflow: hidden;
}
/* Botones de filtros: fondo blanco, texto negro */
.filter-btn {
  background: #fff !important;
  color: #000 !important;
  border: 1px solid #ccc; /* mantiene el borde */
}

.filter-btn:hover {
  background: #f2f2f2 !important; /* ligero gris al pasar el ratón */
}

/* Dropdown */
/* Asegura que el contenedor padre es relativo */
.flagdoku-container {
  position: relative;
}

/* Dropdown adaptativo */
.dropdown-menu {
  position: absolute; /* antes fixed */
  left: 0;
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  padding: 6px 0;
  max-height: 45vh;
  overflow-y: auto;
  display: none;
  z-index: 1001;

  width: 100%;        /* ocupa todo el contenedor */
  max-width: 360px;   /* límite en móvil */
}


/* Escritorio */
@media (min-width: 768px) {
  .dropdown-menu {
    max-width: 720px; /* más ancho en PC */
  }
}
.dropdown-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.2);
  z-index: 1000;
}
.dropdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.2);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;               /* no bloquea clics mientras está oculto */
  transition: opacity 50ms ease;     /* <- fade */
}

/* visible */
.dropdown-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;               /* bloquea clics detrás cuando está visible */
}

.dropdown-heading {
  padding: 6px 10px;
  font-size: 13px;
  font-weight: bold;
  background: #f4f4f4;
  border-top: 1px solid #ddd;
  color: #333;
}

.dropdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  font-size: 14px;
  gap: 10px;
}


/* base cerrado */
.dropdown-menu {
  transition: opacity 100ms ease, transform 100ms ease;
  opacity: 0;
  transform: translateX(var(--tx, 0)) translateY(-8px); /* --tx se setea en JS */
  pointer-events: none;
}

/* abierto */
.dropdown-menu.is-open {
  opacity: 1;
  transform: translateX(var(--tx, 0)) translateY(0);
  pointer-events: auto;
}

.option-label { flex: 1; font-size: 13px; }

/* =============================
   6. BOTONES Y CONTROLES
============================= */
/* Toggle switch */
.binary-switch {
  position: relative;
  width: 42px;
  height: 22px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: 2px;
  box-sizing: border-box;
  background: linear-gradient(180deg, rgba(255,255,255,0.75), rgba(255,255,255,0.35));
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,0.8),
    inset 0 -1px 2px rgba(0,0,0,0.06),
    0 1px 4px rgba(0,0,0,0.06);
  backdrop-filter: saturate(180%) blur(4px);
  transition: background 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}

.switch-true {
  background:
    linear-gradient(180deg, #d5f8d5, #b7e6b7); /* verde suave tipo label */
  border-color: rgba(21, 94, 21, 0.35); /* borde verde oscuro tipo texto */
}

.switch-false {
  background:
    linear-gradient(180deg, #ffd6d6, #f5bcbc); /* rojo suave tipo label */
  border-color: rgba(179, 0, 0, 0.35); /* borde rojo oscuro tipo texto */
}
.switch-false {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.75), rgba(255,255,255,0.35)),
    linear-gradient(90deg, #f87171, #ef4444);
  border-color: rgba(239, 68, 68, 0.35);
}
.switch-null {
  background: linear-gradient(180deg, rgba(255,255,255,0.8), rgba(245,245,245,0.65));
  border-color: rgba(0,0,0,0.08);
}

.switch-knob {
  position: absolute;
  top: 1px;
  left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background:
    radial-gradient(120% 120% at 30% 30%, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.7) 60%, rgba(255,255,255,0.55) 100%),
    linear-gradient(180deg, #ffffff, #f2f2f2);
  box-shadow:
    0 1px 2px rgba(0,0,0,0.08),
    0 3px 6px rgba(0,0,0,0.08),
    inset 0 1px 0 rgba(255,255,255,0.9);
  transition: transform 200ms cubic-bezier(.2,.8,.2,1), width 120ms ease;
}

.switch-true .switch-knob { transform: translateX(20px); }
.switch-false .switch-knob { transform: translateX(0); }
.switch-null .switch-knob { transform: translateX(0); }

.binary-switch:active .switch-knob { width: 20px; }

.switch-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

/* ✔ visible y verde */
.switch-true .switch-icon {
  left: 6px; /* lado opuesto al knob */
  color: #155e15; /* mismo verde que .tag.green */
}

/* ✖ visible y roja */
.switch-false .switch-icon {
  right: 3px; /* lado opuesto al knob */
  color: #b30000; /* mismo rojo que .tag.red */
}
.switch-null .switch-icon { color: rgba(0,0,0,0.45); }

.clear-btn {
  background: #f6f6f6;
  border: none;
  width: 100%;
  padding: 8px;
  font-size: 13px;
  text-align: center;
  border-bottom: 1px solid #ccc;
  cursor: pointer;
  color: #b00000;
}
.clear-btn:hover { background: #fbeaea; }

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 16px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 13px;
  gap: 4px;
  white-space: nowrap;
}
.tag button {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: inherit;
}
.tag.green { background: #d5f8d5; color: #155e15; }
.tag.red { background: #ffd6d6; color: #b30000; }

.search-btn {
  margin: 16px 0;
  width: 100%;
  padding: 10px;
  background: #003949;
  color: white;
  font-weight: bold;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
  font-family: 'Fira Sans Condensed', sans-serif;
}

/* =============================
   7. LISTA DE BANDERAS
============================= */
.flag-list { margin-top: 1em; }
.flag-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 1em;

}

.flag-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 10px;
  background-color: #fff;
  border-bottom: 1px solid #bbb; /* más oscuro */
  border-radius: 6px;
}

.flag-content {
  display: flex;
  align-items: center;
  width: 100%;
}

.flag-img {
  width: 51.81px;
  height: 36.94px;
  object-fit: fill;
  border: 1.5px solid black;
  border-radius: 4px;
  background-color: white;
  margin-right: 20px;
  cursor: pointer;
  aspect-ratio: 3 / 2;
}

.flag-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.flag-name {
  font-size: 1em;
  font-weight: 600;
  color: #111;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.flag-subtitle { font-size: 0.9em; color: #888; }
/* 1) Deja que el texto pueda encogerse dentro de flex/grid */
/* 1) Deja que el texto pueda encogerse dentro del flex/grid */
.flag-content .flag-text,
.subflag-item .flag-text {
  min-width: 0; /* imprescindible para que el recorte funcione */
}

/* 2) Descripción en máximo 2 líneas con elipsis */
.flag-subtitle {
  display: -webkit-box;        /* comportamiento de caja flexible vertical */
  -webkit-line-clamp: 2;       /* máximo de 2 líneas */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  max-width: 100%;
  cursor: pointer
}

/* (opcional) Para sub-listas de banderas, lo mismo */
.subflag-item .flag-subtitle {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 3) Asegura que el contenedor general no bloquee el recorte */
.flag-text { max-width: 100%; }
/* =============================
   8. MODAL DE BANDERA
============================= */
#flagOverlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9998;
}

#flagModal {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 12px;
  padding: 20px;
  z-index: 9999;
  width: 90vw;
  max-width: 350px;
  max-height: 480px;
  min-height: 480px;
  overflow-y: auto;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
  font-family: 'Fira Sans Condensed', sans-serif;
  text-align: center;
}

.flag-title {
  margin-top: 0;
  font-size: 18px;
  font-weight: bold;
}

.flag-image {
  width: 240px;
  height: auto;
  display: block;
  margin: 12px auto;
  border-radius: 7px;
  border: 2px solid black;
  cursor: pointer;
}

.flag-details-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  text-align: left;
}
.flag-details-list li {
  margin-bottom: 3px;
  line-height: 1.1;
  font-size: 13px;
  color: rgb(56, 56, 56);
}

.flag-description {
  font-size: 80;
  text-align: justify;
  line-height: 1.3;
  margin-bottom: 10px;
}

* Botonera debajo de la imagen */
.link-actions {
  display: flex;
  gap: 8px;
  margin: 6px 0 12px;
  justify-content: flex-start; /* a la izquierda */
  flex-wrap: wrap;             /* por si no caben */
}

/* Botones estilo sort-select/dropdown */
.wiki-link-btn {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #f5f5f5;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 10px; /* 🔹 antes 8px 12px */
  font-size: 13px;
  line-height: 1.4;
  font-weight: 500;
  color: #111827;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(16,24,40,.06);
  transition: border-color .2s, box-shadow .2s, background-color .2s;
  font-family: 'Fira Sans Condensed', sans-serif;
}

.wiki-link-btn:hover {
  background-color: #ffffff;
  border-color: #9ca3af;              /* hover del sort-select */
}

.wiki-link-btn:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);  /* focus ring */
}

/* Versión compacta en móvil */
@media (max-width: 420px) {
  .wiki-link-btn {
    padding: 5px 8px; /* 🔹 más compacto en móvil */
    font-size: 11px;
  }
}
.flag-buttons {
  display: flex;
  justify-content: flex-end; /* 🔹 alineados a la derecha */
  gap: 6px;
  margin-top: 8px; /* pegados a la imagen */
}

.flag-buttons .wiki-link-btn {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #f5f5f5;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 10px; /* un pelín más bajo */
  font-size: 12px;
  line-height: 1.4;
  font-weight: 500;
  color: #111827;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(16,24,40,.06);
  transition: border-color .2s, box-shadow .2s, background-color .2s;
  font-family: 'Fira Sans Condensed', sans-serif;
}

@media (max-width: 420px) {
  .flag-buttons .wiki-link-btn {
    padding: 5px 8px;
    font-size: 10px;
  }
}


.flag-close-btn {
  margin-top: 12px;
  padding: 6px 14px;
  background-color: #004a35;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.flag-close-btn:hover { background-color: #00664e; }

.flag-close-x {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  font-weight: bold;
  z-index: 10000;
}
.flag-close-x:hover { color: #000; }

.flag-color-toast {
  position: absolute;
  background-color: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 7px 12px;
  border-radius: 5px;
  font-size: 13.5px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease-in-out;
  font-family: 'Fira Sans Condensed', sans-serif;
}

/* =============================
   9. OTROS ELEMENTOS
============================= */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
  font-size: 18px;
  font-weight: bold;
}



.sort-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #f5f5f5;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px 40px 8px 12px; /* ↑ más padding vertical */
  font-size: 14px;
  line-height: 1.4;           /* ↑ más altura de línea */
  font-weight: 500;
  color: #111827;
  cursor: pointer;
  font-family: 'Fira Sans Condensed', sans-serif;
  background-image: url("data:image/svg+xml,%3Csvg fill='none' stroke='%236B7280' stroke-width='2' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;     /* asegura que padding no desborde */
}

.sort-select option {
  padding: 8px 12px;          /* ↑ más aire dentro de cada opción */
}

.sort-select:hover {
  border-color: #9ca3af;
}

.sort-select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}







.expand-btn {
  border: none;
    color: black !important;
  background-color: #f3f3f3;
  font-size: 18px;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s ease;
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  text-align: center;
  justify-self: end;
  box-sizing: border-box;
  overflow: hidden;
}
.expand-btn.expanded { transform: rotate(45deg); }

.subflag-list {
  display: none;
  border-left: 2px solid #ddd;
  padding-left: 8px;
  font-size: 12px;
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}
.subflag-list.visible { display: block; }

.subflag-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  padding: 4px 8px;
  font-size: 14px;
  border-bottom: 1px solid #eee;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.subflag-wrapper {
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* =============================
   10. RESPONSIVE
============================= */
@media (min-width: 500px) {
  .dropdown-wrapper { flex: 1 1 18%; }
}



/* 0) Revert: NO le pongas z-index al contenedor padre */
.flagdoku-container {
  position: relative;   /* ok */
  z-index: auto;        /* <- o elimina la línea de z-index si la tenías */
}

/* 1) Capas: header < overlay < dropdown */
.headline { z-index: 800; }              /* por debajo del overlay */

.dropdown-overlay { z-index: 10000; }    /* capa oscura para cerrar */
.dropdown-menu    { z-index: 10001; }    /* SIEMPRE por encima del overlay */

/* 2) Posición y tamaño del dropdown */
.dropdown-menu {
  top: 56px; /* debajo del header fijo */
}

/* MOBILE: dropdown centrado y acotado */
@media (max-width: 767px) {
  .dropdown-menu {
    position: fixed !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: min(92vw, 420px) !important;   /* evita que se haga “ultra horizontal” */
    max-width: 92vw !important;
    max-height: 50vh !important;
    overflow-y: auto !important;
  }
}



/* ⚡️ Haz el overlay más rápido */
.dropdown-overlay {
  transition: opacity 30ms ease;   /* antes 160ms */
}

/* ⚡️ Dropdown más ágil y con pipeline GPU */
.dropdown-menu {
  transition: opacity 30ms ease, transform 70ms ease; /* antes 100ms */
  will-change: transform, opacity;                    /* precompón */
  transform: translateX(var(--tx, 0)) translateY(-6px) translateZ(0); /* activa GPU */
}

/* Al abrir, solo mueve 6px (menos repintado) */
.dropdown-menu.is-open {
  transform: translateX(var(--tx, 0)) translateY(0) translateZ(0);
}

/* Si quieres “instantáneo”, sin animaciones: */
.dropdown-overlay,
.dropdown-menu { transition: none !important; }





/* Contenedor del toggle */
.results-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid #d0d5dd;
  border-radius: 999px;
  padding: 2px;
  background: #f8fafc;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6);
}

/* Botones */
.tab-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 8px 14px;
  font: 600 13.5px/1.1 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: #334155;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .02s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* “Pill” del contador */
.tab-btn .pill {
  display: inline-block;
  min-width: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

/* Estado activo */
.tab-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(16,24,40,.06);
}

/* Pill en activo */
.tab-btn.active .pill {
  background: #0ea5e9;
  color: #ffffff;
}

/* Hover/focus */
.tab-btn:hover { background: rgba(255,255,255,.8); }
.tab-btn:active { transform: translateY(1px); }

/* Responsive */
@media (max-width: 520px) {
  .tab-btn { padding: 8px 12px; font-size: 13px; }
}


/* Botón go-up, estilo tipo sort-select/dropdown */
#goUpBtn {
  position: fixed;
  right: 16px;      /* pegado a la derecha */
  top: 48px;        /* más arriba: ajusta según altura real del header */
  transform: none;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background-color: rgba(245, 245, 245, 0.85);
  backdrop-filter: blur(6px);
  font-size: 13px;
  font-weight: 500;
  color: #111827;
  cursor: pointer;
  z-index: 10005;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  opacity: 0;
  font-family: 'Fira Sans Condensed', sans-serif;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

/* visible */
#goUpBtn.show {
  opacity: 0.95;
  pointer-events: auto;
  transform: translateY(0);
}

#goUpBtn:hover {
  background-color: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.25);
}

#goUpBtn:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

@media (prefers-reduced-motion: reduce) {
  #goUpBtn { transition: none; }
  html { scroll-behavior: auto; }
}





.filters .dropdown-wrapper { width: 100px !important; flex: 0 0 100px !important; }
.filters .filter-btn { width: 100% !important; }

.dropdown-menu { transition: opacity 30ms ease; transform: none; }
.dropdown-menu.is-open { transform: none; }


.expand-btn.expand-sub {
  right: 1148px;   /* ajusta aquí: 36px / 48px / 56px */
}



.search-input {
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: 16.1px;
  width: 100%;
  box-sizing: border-box;
  padding-right: 90px;
  padding-left: 24px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='gray' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat 8px center;
  background-size: 12px;
}






