/* FTTH Map Module — styles with .ftth- prefix (scoped) */

.ftth-wrap {
    display: flex;
    height: calc(100vh - 140px);
    min-height: 560px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.ftth-sidebar {
    position: relative;
    width: var(--ftth-lat, 340px);
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    overflow: hidden;
}
.ftth-map-wrap { flex: 1; min-width: 0; position: relative; }
.ftth-map { position: absolute; inset: 0; background: #1a1a2e; }
.ftth-map.ftth-crosshair, .ftth-map.ftth-crosshair .leaflet-interactive { cursor: crosshair !important; }
.ftth-muted { color: var(--text-muted); font-size: 11px; }
.ftth-hint { color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.ftth-empty { text-align: center; color: var(--text-muted); padding: 18px 6px; font-size: 12px; }
.ftth-clickable { cursor: pointer; }
.ftth-hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
.ftth-danger { color: #ef4444 !important; }
.ftth-tag {
    display: inline-block; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    padding: 1px 6px; border-radius: 99px; border: 1px solid var(--border); color: var(--text-muted); vertical-align: middle;
}
.ftth-readonly .ftth-edit-only { display: none !important; }

/* ── Sidebar header ── */
.ftth-sidebar-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.ftth-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.ftth-counts {
    display: flex; gap: 10px; flex-wrap: wrap;
    padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 11px; color: var(--text-muted);
}
.ftth-counts span b { color: var(--text-primary); }

/* ── Sidebar tabs ── */
.ftth-sidebar-tabs { display: flex; border-bottom: 1px solid var(--border); }
.ftth-stab {
    flex: 1; position: relative;
    padding: 8px 2px 7px; cursor: pointer;
    font-size: 10px; font-weight: 600;
    border: none; background: none; color: var(--text-muted);
    border-bottom: 2px solid transparent; transition: .15s;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.ftth-stab i { font-size: 13px; }
.ftth-stab:hover { color: var(--text-primary); }
.ftth-stab.active { color: var(--accent); border-bottom-color: var(--accent); }
.ftth-badge {
    position: absolute; top: 3px; right: 8px;
    background: #ef4444; color: #fff; font-size: 9px; line-height: 14px; min-width: 14px;
    padding: 0 4px; border-radius: 99px;
}
.ftth-badge.hidden { display: none; }

/* ── Sidebar panels ── */
.ftth-sidebar-panel {
    flex: 1; overflow-y: auto; padding: 10px 12px;
    display: none; flex-direction: column; gap: 9px;
}
.ftth-sidebar-panel.active { display: flex; }

/* ── Filters / forms ── */
.ftth-filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ftth-filter-label {
    font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
}
.ftth-filter {
    width: 100%; padding: 6px 8px; font-size: 12px;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--bg); color: var(--text-primary);
    box-sizing: border-box;
}
.ftth-filter:focus { outline: none; border-color: var(--accent); }
.ftth-check { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px; padding: 2px 0; }
.ftth-check input { width: auto; margin: 0; }
.ftth-layer-toggles { display: flex; flex-direction: column; gap: 1px; }
.ftth-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ftth-span2 { grid-column: span 2; }

/* ── Busca ── */
.ftth-search-wrap { position: relative; }
.ftth-search-results {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin-top: 2px;
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px;
    max-height: 320px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.35); padding: 4px;
}
.ftth-search-results.hidden { display: none; }

/* ── Listas compactas ── */
.ftth-mini-list { display: flex; flex-direction: column; gap: 4px; }
.ftth-mini-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg);
    font-size: 12px;
}
.ftth-mini-item > i { width: 14px; text-align: center; flex-shrink: 0; }
.ftth-mini-item.ftth-clickable:hover, .ftth-mini-main.ftth-clickable:hover { border-color: var(--accent); }
.ftth-mini-main { flex: 1; min-width: 0; }
.ftth-mini-main > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Legend ── */
.ftth-legend {
    display: flex; flex-wrap: wrap; gap: 4px 8px;
    padding: 7px 12px; background: var(--bg-elevated); border-top: 1px solid var(--border);
    font-size: 10px; align-items: center; color: var(--text-muted);
}
.ftth-legend-dot, .ftth-legend-sq { width: 9px; height: 9px; display: inline-block; margin-right: 3px; vertical-align: middle; }
.ftth-legend-dot { border-radius: 50%; }
.ftth-legend-sq { border-radius: 2px; margin-left: 4px; }
.ftth-legend-sep { margin-left: auto; }

/* ── Toolbar e banner no mapa ── */
.ftth-toolbar a {
    width: 34px !important; height: 34px !important; line-height: 34px !important;
    display: flex !important; align-items: center; justify-content: center;
    font-size: 14px; color: #1f2937;
}
.ftth-toolbar a.active { background: #06b6d4; color: #fff; }
.ftth-mode-banner {
    position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 800;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
    max-width: calc(100% - 140px);
    background: var(--bg-elevated); color: var(--text-primary);
    border: 1px solid var(--accent); border-radius: 10px; padding: 7px 12px;
    font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
.ftth-mode-banner.hidden { display: none; }
.ftth-mode-banner > i { color: var(--accent); }

/* ── Ícones do mapa ── */
.ftth-cto-icon, .ftth-olt-icon, .ftth-splitter-icon { background: none; border: none; }
.ftth-cto-box {
    width: 22px; height: 22px; border-radius: 5px;
    background: var(--c); border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.45);
    color: #fff; font-size: 10px; font-weight: 800; line-height: 18px; text-align: center;
    text-shadow: 0 1px 1px rgba(0,0,0,.4);
}
.ftth-cto-box.ftth-cto-planned { background: transparent; border: 2px dashed var(--c); color: var(--c); text-shadow: none; }
.ftth-dragging .ftth-cto-box { outline: 3px solid #06b6d4; cursor: move; }
.ftth-pulse { animation: ftthPulse 1.4s ease-out infinite; }
@keyframes ftthPulse {
    0%   { box-shadow: 0 0 0 0 rgba(239,68,68,.75); }
    100% { box-shadow: 0 0 0 14px rgba(239,68,68,0); }
}
.ftth-olt {
    width: 30px; height: 30px; border-radius: 50%;
    background: #ef4444; border: 2px solid #fff; color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,.45);
}
.ftth-olt.off { background: #6b7280; }
.ftth-splitter {
    width: 26px; height: 26px; border-radius: 50%;
    background: #a78bfa; color: #fff; border: 2px solid #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 8px; font-weight: 800; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.ftth-vertex { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid #06b6d4; box-sizing: border-box; cursor: move; }
.ftth-vertex.mid { width: 10px; height: 10px; border: 2px solid #06b6d4; opacity: .7; cursor: copy; }
.ftth-viab-pin { color: #06b6d4; font-size: 26px; text-shadow: 0 1px 3px rgba(0,0,0,.5); }

/* ── Popups ── */
/* 11/11/2026: o balão era o branco padrão do Leaflet, mas o conteúdo segue o tema — no escuro os botões ficavam
   texto branco em fundo branco (.btn-ghost usa --text-primary) e os rótulos cinza-claro. Agora o balão segue o tema
   (como o .mr-popup do Mapa da Rede). Só balões com .ftth-pop: outros mapas têm cor escura fixa no conteúdo. */
.leaflet-popup:has(.ftth-pop) .leaflet-popup-content-wrapper {
    background: var(--bg-surface); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md, 0 12px 28px rgba(0,0,0,.35));
}
.leaflet-popup:has(.ftth-pop) .leaflet-popup-tip { background: var(--bg-surface); border: 1px solid var(--border); box-shadow: none; }
.leaflet-popup:has(.ftth-pop) .leaflet-popup-content { margin: 12px 14px 12px; line-height: 1.45; }
.leaflet-popup:has(.ftth-pop) a.leaflet-popup-close-button { color: var(--text-muted); top: 6px; right: 6px; font-size: 18px; }
.leaflet-popup:has(.ftth-pop) a.leaflet-popup-close-button:hover { color: var(--text-primary); }
.ftth-pop { font-size: 12px; min-width: 210px; color: var(--text-primary); }
.ftth-pop-title { font-weight: 700; font-size: 13px; margin-bottom: 2px; padding-right: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--text-primary); }
.ftth-pop-grid { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 8px 0; }
.ftth-pop-grid > span { color: var(--text-secondary); }
.ftth-pop-grid > b { color: var(--text-primary); font-weight: 600; }
.ftth-pop .ftth-muted { color: var(--text-secondary); }
.ftth-pop .btn.ftth-danger, .ftth-pop .btn-ghost.ftth-danger { color: #ef4444 !important; }
/* etiquetas do swap usam a cor do dado (inline): no tema escuro, clarear para ler sobre o fundo do balão */
:root:not([data-theme="light"]) .ftth-pop span[style*="border-radius:9px"] { filter: brightness(1.6) saturate(1.15); }
.ftth-pop-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.ftth-pop-alert {
    background: rgba(239,68,68,.12); color: #ef4444; border: 1px solid rgba(239,68,68,.35);
    border-radius: 6px; padding: 5px 8px; font-size: 11px; font-weight: 600; margin: 6px 0;
}
.ftth-occ-bar {
    height: 6px; border-radius: 99px; overflow: hidden; display: flex;
    background: rgba(34,197,94,.35); margin: 6px 0;
}
.ftth-occ-bar span { display: block; height: 100%; }

/* ── Modal ── */
.ftth-modal { width: 92vw; max-width: 560px !important; }
.ftth-modal.ftth-modal-wide { max-width: 760px !important; }
.ftth-modal .modal-body { display: flex; flex-direction: column; gap: 10px; max-height: 70vh; overflow-y: auto; }
.ftth-modal-footer { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 10px 16px; border-top: 1px solid var(--border); }
.ftth-cto-head { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; font-size: 12px; }
.ftth-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-top: 6px; }
.ftth-port-panel { border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: var(--bg); }
.ftth-viab-verdict { font-weight: 700; font-size: 12px; padding: 6px 8px; border-radius: 6px; background: var(--bg-elevated); margin: 4px 0; }
.ftth-viab-verdict.ok { color: #22c55e; background: rgba(34,197,94,.1); }
.ftth-viab-verdict.bad { color: #ef4444; background: rgba(239,68,68,.1); }

/* ── Port grid ── */
.ftth-port-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 5px; }
.ftth-port {
    height: 40px; border-radius: 6px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    font-size: 12px; font-weight: 700; cursor: pointer;
    border: 1px solid var(--border); background: var(--bg); color: var(--text-primary);
    transition: transform .12s, box-shadow .12s;
}
.ftth-port i { font-size: 10px; }
.ftth-port.free     { background: rgba(34,197,94,.10); color: #22c55e; border-color: rgba(34,197,94,.35); }
.ftth-port.used     { background: rgba(59,130,246,.14); color: #3b82f6; border-color: rgba(59,130,246,.4); }
.ftth-port.used.off { background: rgba(239,68,68,.12); color: #ef4444; border-color: rgba(239,68,68,.4); }
.ftth-port.reserved { background: rgba(245,158,11,.12); color: #f59e0b; border-color: rgba(245,158,11,.4); }
.ftth-port.defect   { background: rgba(107,114,128,.15); color: #6b7280; border-color: rgba(107,114,128,.4); }
.ftth-port:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.ftth-port.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.ftth-port-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 10px; color: var(--text-muted); }
.ftth-port-key { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-right: -6px; border: 1px solid; }
.ftth-port-key.free { background: rgba(34,197,94,.3); border-color: #22c55e; }
.ftth-port-key.used.on { background: rgba(59,130,246,.3); border-color: #3b82f6; }
.ftth-port-key.used.off { background: rgba(239,68,68,.3); border-color: #ef4444; }
.ftth-port-key.reserved { background: rgba(245,158,11,.3); border-color: #f59e0b; }
.ftth-port-key.defect { background: rgba(107,114,128,.3); border-color: #6b7280; }

/* ── Reports ── */
.ftth-report-wrap { overflow: auto; flex: 1; min-height: 0; }
.ftth-report-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.ftth-report-table th {
    position: sticky; top: 0; z-index: 1;
    text-align: left; padding: 5px 7px;
    background: var(--bg-elevated); color: var(--text-muted);
    font-size: 9px; font-weight: 700; text-transform: uppercase;
    border-bottom: 2px solid var(--border); white-space: nowrap;
}
.ftth-report-table td { padding: 5px 7px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ftth-report-table tr:hover td { background: var(--bg-hover); }
.ftth-report-toolbar { display: flex; gap: 6px; align-items: center; }

/* ── Responsive ── */
@media (max-width: 900px) {
    .ftth-wrap { flex-direction: column; height: auto; }
    .ftth-sidebar { width: 100%; height: 45vh; border-right: none; border-bottom: 1px solid var(--border); }
    .ftth-map-wrap { height: 60vh; }
    .ftth-cto-head { grid-template-columns: 1fr 1fr; }
    .ftth-form-grid { grid-template-columns: 1fr; }
    .ftth-span2 { grid-column: auto; }
    .ftth-mode-banner { max-width: calc(100% - 60px); }
}

/* ── Visão: janela própria, tela cheia e menus recolhíveis (09/11/2026) ── */
.leaflet-control.ftth-visao { position: relative; z-index: 900; }
.ftth-visao-bar { display: flex; }
.ftth-visao-bar a {
    width: 34px !important; height: 34px !important; line-height: 34px !important;
    display: flex !important; align-items: center; justify-content: center;
    font-size: 14px; color: #1f2937; border-bottom: none !important;
    border-right: 1px solid #ccc;
}
.ftth-visao-bar a:last-child { border-right: none; }
.ftth-visao-menu {
    position: absolute; top: calc(100% + 6px); right: 0; width: 270px; padding: 10px 12px;
    display: flex; flex-direction: column; gap: 6px;
    background: var(--bg-surface); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.35); font-size: 12px;
}
.ftth-visao-menu.hidden { display: none; }
.ftth-visao-tit { font-weight: 700; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.ftth-visao-menu .btn { align-self: flex-start; margin-top: 2px; }
.ftth-wrap.ftth-sem-painel .ftth-sidebar { display: none; }
.ftth-wrap.ftth-sem-ferramentas .ftth-toolbar { display: none; }
.ftth-wrap.ftth-sem-base .leaflet-top.leaflet-right .leaflet-control:not(.ftth-visao) { display: none; }
.ftth-wrap.ftth-sem-zoom .leaflet-control-zoom,
.ftth-wrap.ftth-sem-zoom .leaflet-control-scale { display: none; }
html.ftth-tela #ftth-map-section { margin: 0; padding: 0; height: 100%; }
html.ftth-tela .ftth-wrap { height: 100vh; height: 100dvh; min-height: 0; border: none; border-radius: 0; }
@media (max-width: 900px) {
    .ftth-wrap.ftth-sem-painel .ftth-map-wrap { height: calc(100vh - 130px); height: calc(100dvh - 130px); }
    html.ftth-tela .ftth-sidebar { height: 42dvh; }
    html.ftth-tela .ftth-map-wrap { flex: 1; height: auto; min-height: 0; }
    html.ftth-tela .ftth-wrap.ftth-sem-painel .ftth-map-wrap { height: auto; }
}

/* ── Lateral: encolher, largura e grupos recolhíveis (09/11/2026) ── */
.ftth-lat-acoes { display: flex; gap: 4px; flex-shrink: 0; }
.ftth-painel-borda { position: absolute; top: 0; right: 0; bottom: 0; width: 6px; cursor: ew-resize; z-index: 5; touch-action: none; }
.ftth-painel-borda:hover, .ftth-arrastando .ftth-painel-borda { background: var(--accent); opacity: .6; }
.ftth-arrastando { user-select: none; }
.ftth-painel-alca {
    position: absolute; left: 0; top: 50%; transform: translateY(-50%); z-index: 801;
    width: 18px; height: 60px; padding: 0; cursor: pointer;
    border: 1px solid var(--border); border-left: none; border-radius: 0 8px 8px 0;
    background: var(--bg-surface); color: var(--text-primary); font-size: 11px;
}
.ftth-painel-alca:hover { color: var(--accent); }
.ftth-cam-topo { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
button.ftth-cam-sec {
    display: flex; align-items: center; gap: 6px; width: 100%; padding: 3px 0; text-align: left;
    background: none; border: none; color: inherit; cursor: pointer;
}
button.ftth-cam-sec:hover { opacity: 1; color: var(--accent); }
.ftth-cam-seta { font-size: 9px; transition: transform .15s; }
button.ftth-cam-sec[aria-expanded="false"] .ftth-cam-seta { transform: rotate(-90deg); }
.ftth-cam-grupo[hidden] { display: none; }
.ftth-wrap.ftth-painel-mini .ftth-counts,
.ftth-wrap.ftth-painel-mini .ftth-sidebar-panel,
.ftth-wrap.ftth-painel-mini .ftth-legend,
.ftth-wrap.ftth-painel-mini .ftth-painel-borda { display: none; }
@media (min-width: 901px) {
    .ftth-wrap.ftth-painel-mini .ftth-sidebar { width: 56px; }
    .ftth-painel-mini .ftth-title { display: none; }
    .ftth-painel-mini .ftth-sidebar-header { padding: 8px 4px; justify-content: center; }
    .ftth-painel-mini .ftth-lat-acoes { flex-direction: column; }
    .ftth-painel-mini .ftth-lat-recarga { display: none; }
    .ftth-painel-mini .ftth-sidebar-tabs { flex-direction: column; border-bottom: none; }
    .ftth-painel-mini .ftth-stab { flex: none; padding: 12px 0; border-bottom: none; }
    .ftth-painel-mini .ftth-stab span { display: none; }
}
@media (max-width: 900px) {
    .ftth-painel-borda { display: none; }
    .ftth-wrap.ftth-painel-mini .ftth-sidebar { height: auto; }
    .ftth-wrap.ftth-painel-mini .ftth-map-wrap { height: calc(100vh - 240px); height: calc(100dvh - 240px); }
    html.ftth-tela .ftth-wrap.ftth-painel-mini .ftth-map-wrap { height: auto; }
    .ftth-painel-alca { top: auto; bottom: 70px; transform: none; }
    [data-lat="encolher"] i { transform: rotate(90deg); }
}
