/* =========================================================
   1. ESTRUTURA GERAL (BLINDADA)
========================================================= */
.yvymap-container {
    position: relative;
    width: 100%;
    height: 100%;
    font-family: 'Segoe UI', Arial, sans-serif;
    overflow: hidden;
    background: #e5e3df;
}

.yvymap-container .yvy-map-canvas {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* =========================================================
   2. BARRA DE PESQUISA (TOP)
========================================================= */
.yvymap-container .yvy-search-container {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 650px;
    padding: 0 20px;
    z-index: 5;
    box-sizing: border-box;
    display: flex;
    align-items: center;
}

.yvymap-container .yvy-pac-input {
    width: 100%;
    padding: 12px 80px 12px 20px;
    font-size: 14px;
    border: none;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    outline: none;
    background: white;
}

.yvymap-container .yvy-btn-filtro-busca {
    position: absolute;
    right: 35px;
    background: none;
    border: none;
    color: #2c3e50;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.yvymap-container .yvy-btn-filtro-busca:hover { color: #3498db; }

.yvymap-container .yvy-btn-clear-search {
    position: absolute;
    right: 65px;
    background: none;
    border: none;
    font-size: 16px;
    color: #95a5a6;
    cursor: pointer;
    padding: 5px;
    transition: 0.2s;
}

.yvymap-container .yvy-btn-clear-search:hover { color: #e74c3c; }

/* =========================================================
   3. BARRAS LATERAIS (LIMITES DE TELA)
========================================================= */
.yvymap-container .yvy-barra-lateral-esquerda {
    position: absolute;
    top: 90px;
    left: 10px;
    width: 320px;
    bottom: 110px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 2;
    pointer-events: none;
}

.yvymap-container .yvy-barra-lateral-direita {
    position: absolute;
    top: 90px;
    right: 10px;
    width: 320px;
    bottom: 110px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 2;
    pointer-events: none;
}

.yvymap-container .yvy-barra-lateral-esquerda > *,
.yvymap-container .yvy-barra-lateral-direita > * {
    pointer-events: auto;
    width: 100%;
}

/* =========================================================
   4. ESTRUTURA DOS PAINÉIS (Camadas, Filtro, Feições, Atributos)
========================================================= */
.yvymap-container .yvy-painel-camadas,
.yvymap-container .yvy-painel-filtro,
.yvymap-container .yvy-painel-feicoes,
.yvymap-container .yvy-painel-atributos {
    background: rgba(255, 255, 255, 0.97);
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 0 1 auto;

    /* 🔥 VOLTOU AO NORMAL: Permite empilhar 2 no desktop full */
    max-height: calc(50% - 7.5px);

    min-height: 40px;
}

.yvymap-container .yvy-painel-filtro,
.yvymap-container .yvy-painel-atributos { display: none; }

.yvymap-container .yvy-painel-header,
.yvymap-container .yvy-painel-atributos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    padding: 10px;
    font-weight: bold;
    flex-shrink: 0;
    background: #2c3e50;
}
.yvymap-container .yvy-painel-atributos-header { background: #34495e; }

/* 🔥 FIX DEFINITIVO APPLE/iOS: Oculta o caractere que vira emoji e injeta um SVG 100% branco */
.yvymap-container .yvy-btn-fechar-painel {
    color: transparent !important; /* Esconde o texto nativo */
    -webkit-text-fill-color: transparent !important;
    background-color: transparent !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E") !important;
    background-size: 20px 20px !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
}

.yvymap-container .yvy-painel-camadas-body,
.yvymap-container .yvy-painel-filtro-body,
.yvymap-container .yvy-painel-body,
.yvymap-container .yvy-painel-atributos-body {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.yvymap-container .yvy-painel-filtro-body { padding: 15px; }
.yvymap-container .yvy-painel-atributos-body { padding: 10px; font-size: 13px; }

.yvymap-container .yvy-painel-filtro-footer,
.yvymap-container .yvy-painel-atributos-footer {
    padding: 10px 15px;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 10px;
    background: #fafafa;
    flex-shrink: 0;
}

/* =========================================================
   5. ACORDEÃO E ITENS WMS (Camadas)
========================================================= */
.yvymap-container .yvy-camada-categoria {
    padding: 8px 10px; background: #ecf0f1; font-weight: bold; font-size: 13px;
    border-bottom: 1px solid #ccc; cursor: pointer; user-select: none;
    display: flex; align-items: center; justify-content: space-between;
}
.yvymap-container .yvy-camada-categoria-titulo { display: flex; align-items: center; gap: 6px; }
.yvymap-container .yvy-camada-categoria-seta { font-size: 12px; width: 14px; display: inline-block; }

.yvymap-container .yvy-camada-item { padding: 10px; border-bottom: 1px solid #ddd; font-size: 13px; }
.yvymap-container .yvy-camada-topo { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.yvymap-container .yvy-camada-nome { flex: 1; word-break: break-word; }
.yvymap-container .yvy-camada-opacidade { display: flex; align-items: center; gap: 8px; }
.yvymap-container .yvy-camada-opacidade input[type="range"] { flex: 1; }
.yvymap-container .yvy-camada-opacidade-valor { min-width: 38px; text-align: right; color: #555; font-size: 12px; }

/* =========================================================
   6. ITENS DO FILTRO (CQL)
========================================================= */
.yvymap-container .yvy-form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.yvymap-container .yvy-form-group label { font-size: 12px; font-weight: bold; color: #555; }

.yvymap-container .yvy-form-group select,
.yvymap-container .yvy-form-group input {
    padding: 8px; border: 1px solid #ccc; border-radius: 6px; font-size: 13px; outline: none;
    width: 100%; box-sizing: border-box;
    position: relative;
    max-width: 100%;
    text-overflow: ellipsis;
}

.yvymap-container .yvy-regras-chips-container {
    display: flex; flex-direction: column; gap: 4px; margin-top: 2px; max-height: 145px; overflow-y: auto; padding-right: 5px;
}
.yvymap-container .yvy-chip-regra {
    display: flex; align-items: center; background: #ecf0f1; border-left: 4px solid #3498db;
    padding: 6px 10px; border-radius: 4px; font-size: 12px; justify-content: space-between; word-break: break-word;
}
.yvymap-container .yvy-chip-logica-badge {
    background: #e67e22; color: white; padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: bold; margin-right: 6px;
}
.yvymap-container .yvy-chip-texto { flex: 1; color: #2c3e50; font-weight: bold; }
.yvymap-container .yvy-btn-remover-chip {
    background: none; border: none; color: #e74c3c; cursor: pointer; font-weight: bold; font-size: 14px; padding: 0 5px;
}
.yvymap-container .yvy-btn-nova-condicao {
    background: transparent; border: 2px dashed #bdc3c7; color: #7f8c8d; padding: 6px; border-radius: 6px;
    cursor: pointer; font-weight: bold; transition: 0.2s; margin-top: 8px; width: 100%;
}

/* =========================================================
   7. TABELA DE FEIÇÕES E ATRIBUTOS
========================================================= */
.yvymap-container .yvy-tabela { width: 100%; border-collapse: collapse; font-size: 13px; }
.yvymap-container .yvy-tabela th { background: #eee; padding: 6px; position: sticky; top: 0; z-index: 1; text-align: left; }
.yvymap-container .yvy-tabela td { padding: 6px; border-bottom: 1px solid #ddd; }
.yvymap-container .yvy-acoes button { border: none; background: transparent; cursor: pointer; font-size: 14px; }

.yvymap-container .yvy-atributo-item,
.yvymap-container .atributo-item { margin-bottom: 6px; border-bottom: 1px solid #eee; padding-bottom: 4px; }
.yvymap-container .yvy-atributo-chave,
.yvymap-container .atributo-chave { font-weight: bold; color: #2c3e50; }

.yvymap-container .yvy-btn-acao { flex: 1; padding: 8px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; }
.yvymap-container .yvy-btn-integrar { background: #27ae60; color: white; }
.yvymap-container .yvy-btn-fechar { background: #c0392b; color: white; }
.yvymap-container .yvy-btn-integrar.escondido { display: none !important; }

.yvymap-container .yvy-item-sobreposto,
.yvymap-container .item-sobreposto {
    padding: 10px; margin-bottom: 8px; background: #ecf0f1; border: 1px solid #bdc3c7;
    border-radius: 6px; cursor: pointer; transition: 0.2s; border-left: 4px solid #3498db;
}

/* =========================================================
   8. TOOLBAR (BOTTOM)
========================================================= */
.yvymap-container .yvy-toolbar {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 10px; background: rgba(255, 255, 255, 0.95); padding: 10px 15px;
    border-radius: 40px; box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3); z-index: 3;
}

/* 🔥 A MÁGICA AQUI: Quando a toolbar ganha a classe minimizado, esconde os filhos */
.yvymap-container .yvy-toolbar.minimizado .yvy-tool-btn:not([data-action='toggle-toolbar']) {
    display: none !important;
}

.yvymap-container .yvy-tool-btn {
    position: relative; border: none; background: #f0f0f0; padding: 10px 14px;
    border-radius: 20px; cursor: pointer; font-weight: 600; display: flex;
    align-items: center; justify-content: center; color: #2c3e50; transition: 0.2s;

    /* 🔥 MATA O QUADRADO CINZA DO ANDROID AO TOCAR */
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

/* Estado "Ligado" (Controlado pelo Javascript) */
.yvymap-container .yvy-tool-btn.active { background: #5dade2; color: white; transform: scale(1.1); }

/* Efeito Físico de Toque no Celular (Afunda o botão rapidinho) */
.yvymap-container .yvy-tool-btn:active { background: #3498db; color: white; transform: scale(0.95); }
.yvymap-container .yvy-tool-btn.danger:active { background: #c0392b; color: white; transform: scale(0.95); }

/* Tooltips ocultos por padrão */
.yvymap-container .yvy-tool-btn::after {
    content: attr(data-tooltip); position: absolute; bottom: 120%; left: 50%; transform: translateX(-50%);
    background: #333; color: white; padding: 5px 8px; border-radius: 5px; font-size: 11px;
    opacity: 0; pointer-events: none; transition: 0.2s; white-space: nowrap;
}

/* 🔥 O SEGREDO DO "STICKY HOVER": Só existe Hover e Tooltip se houver MOUSE (Desktop) */
@media (hover: hover) and (pointer: fine) {
    .yvymap-container .yvy-tool-btn:hover { background: #5dade2; color: white; }
    .yvymap-container .yvy-tool-btn.danger:hover { background: #e74c3c; color: white; }
    .yvymap-container .yvy-tool-btn:hover::after { opacity: 1; }
}

/* =========================================================
   9. MODAIS (AVISOS E CONFIRMAÇÕES)
========================================================= */
.yvymap-container .yvy-modal-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); display: none; align-items: center; justify-content: center; z-index: 9999;
}

/* 🔥 FIX DO EMPILHAMENTO: Garante que o Alerta Genérico cubra qualquer outro modal aberto */
.yvymap-container #modal-alerta {
    z-index: 10005 !important;
}

.yvymap-container .yvy-modal-painel {
    background: rgba(255, 255, 255, 0.98); border-radius: 12px; box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35);
    width: 340px; max-width: 90%;
    max-height: 85%;
    overflow: hidden; display: flex; flex-direction: column;
}
.yvymap-container .yvy-modal-header {
    background: #2c3e50; color: white; padding: 10px; font-weight: bold; display: flex; align-items: center; justify-content: center;
}

.yvymap-container .yvy-modal-header {
    background: #2c3e50; color: white; padding: 10px; font-weight: bold; display: flex; align-items: center; justify-content: center;
}

/* 🔥 FIX DO CABEÇALHO GIGANTE: Remove as margens automáticas do navegador para o H3 */
.yvymap-container .yvy-modal-header h3 {
    margin: 0;
    font-size: 15px; /* Deixa o tamanho da fonte proporcional aos outros painéis */
}

.yvymap-container .yvy-modal-body {
    padding: 20px; color: #333; font-size: 14px; text-align: center;
    flex: 1;
    overflow-y: auto;
}
.yvymap-container .yvy-modal-footer { padding: 10px; border-top: 1px solid #ddd; display: flex; gap: 10px; }
.yvymap-container .yvy-modal-footer button {
    flex: 1; padding: 8px; border: none; border-radius: 6px; font-weight: bold; cursor: pointer; transition: 0.2s;
}
.yvymap-container .yvy-btn-cancelar { background: #ecf0f1; color: #7f8c8d; }
.yvymap-container .yvy-btn-cancelar:hover { background: #bdc3c7; color: #2c3e50; }

.yvymap-container .yvy-btn-confirmar { background: #e74c3c; color: white; }
.yvymap-container .yvy-btn-confirmar:hover { background: #c0392b; }

.yvymap-container .yvy-btn-ok { background: #3498db; color: white; }
.yvymap-container .yvy-btn-ok:hover { background: #2980b9; }


/* =========================================================
   10. GOOGLE MAPS E SCROLLBAR
========================================================= */
.yvymap-container .gm-style div { text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000 !important; }
.yvymap-container .gm-style span, .yvymap-container .gm-style div { color: #fff !important; font-weight: bold !important; }
.yvymap-container ::-webkit-scrollbar { width: 6px; height: 6px; }
.yvymap-container ::-webkit-scrollbar-thumb { background: #bdc3c7; border-radius: 10px; }

/* =========================================================
   11. RESPONSIVIDADE BASEADA NO CONTAINER (COMPACT MODE)
========================================================= */

.yvymap-container.yvy-compact .yvy-barra-lateral-esquerda,
.yvymap-container.yvy-compact .yvy-barra-lateral-direita {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    bottom: auto !important;
    background: transparent !important;
    pointer-events: none !important;
    display: flex;
    flex-direction: column;
    justify-content: center !important;
    align-items: center !important;
    z-index: 2000 !important;
}

.yvymap-container.yvy-compact .yvy-painel-camadas,
.yvymap-container.yvy-compact .yvy-painel-filtro,
.yvymap-container.yvy-compact .yvy-painel-feicoes,
.yvymap-container.yvy-compact .yvy-painel-atributos {
    pointer-events: auto !important;
    width: 90% !important;
    max-width: 400px !important;
    height: auto !important;
    max-height: 85% !important;
    margin: 0 !important;
    border-radius: 12px !important;
    transform: none !important;
    position: relative !important;
    box-shadow: 0 0 0 2000px rgba(0,0,0,0.6), 0 10px 40px rgba(0,0,0,0.5) !important;
}

.yvymap-container.yvy-compact .yvy-painel-body {
    flex: 1;
    overflow-y: auto;
}

/* 3. A Toolbar vira um "Dock" elegante e dinâmico */
.yvymap-container.yvy-compact .yvy-toolbar {
    bottom: 15px !important;

    /* 🔥 O SEGREDO: Em vez de forçar 100%, manda ela abraçar o conteúdo */
    width: max-content !important;
    /* E aqui dizemos: Cresça o quanto quiser, mas pare ao bater nas bordas da tela */
    max-width: calc(100% - 20px) !important;

    border-radius: 30px !important; /* Arredondado para parecer uma pílula flutuante */
    padding: 8px 12px !important;
    justify-content: flex-start !important;
    gap: 12px;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

.yvymap-container.yvy-compact .yvy-toolbar::-webkit-scrollbar { display: none; }

.yvymap-container.yvy-compact .yvy-tool-btn {
    width: 44px !important;
    height: 44px !important;
    flex-shrink: 0;
}

.yvymap-container.yvy-compact .yvy-search-container {
    top: 15px;
    width: 92%;
}

.yvymap-container.yvy-compact .yvy-pac-input {
    font-size: 16px;
    padding: 14px 70px 14px 18px;
}

.yvymap-container.yvy-compact .yvy-tool-btn::after { display: none !important; }

/* 🔥 FIX EXTRA APPLE/iOS MOBILE: Mantém a proporção da imagem de fundo no celular */
.yvymap-container.yvy-compact .yvy-btn-fechar-painel {
    width: 44px !important;
    height: 44px !important;
    background-size: 24px 24px !important; /* Aumenta um pouco o X no mobile */
}

/* =========================================================
   12. RESPONSIVIDADE VERTICAL (TELAS ACHATADAS)
========================================================= */
.yvymap-container.yvy-short .yvy-painel-camadas,
.yvymap-container.yvy-short .yvy-painel-filtro,
.yvymap-container.yvy-short .yvy-painel-feicoes,
.yvymap-container.yvy-short .yvy-painel-atributos {
    /* 🔥 Quando a tela é achatada (< 650px), usa a altura toda */
    max-height: 100% !important;
}
