﻿/* =================================================== */
/* ||          INVMAP v2.0 - DESIGN SYSTEM          || */
/* =================================================== */

:root {
    /* --- Paleta de Cores Base --- */
    --bg-app: #0f0f12;                  /* Fundo ultra escuro */
    --bg-panel: rgba(30, 30, 35, 0.65); /* Painéis de vidro */
    --bg-input: rgba(0, 0, 0, 0.4);     /* Inputs escuros */
    
    /* --- Cores de Acento --- */
    --accent-primary: #f95738;          /* Laranja Sniff (Principal) */
    --accent-glow: rgba(249, 87, 56, 0.4);
    --accent-secondary: #e0e0e5;        /* Platinum (Secundário - para links/info) */
    --accent-success: #00ff9d;          /* Verde Matrix */
    --accent-danger: #ff2a6d;           /* Rosa/Vermelho Erro */
    
    /* --- Texto --- */
    --text-main: #ffffff;
    --text-muted: #a0a0a5;
    
    /* --- Bordas e Separadores --- */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(249, 87, 56, 0.6);
    
    /* --- Efeitos (Glassmorphism) --- */
    --blur-strength: 12px;
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-border: 1px solid rgba(255, 255, 255, 0.05);
    
    /* --- Transições --- */
    --ease-out: cubic-bezier(0.215, 0.61, 0.355, 1);
}

/* --- Reset Básico e Tipografia --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
    margin-block: 16px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* =================================================== */
/* ||                  HEADER                       || */
/* =================================================== */

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s var(--ease-out);
    border: var(--glass-border);
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    border-color: rgba(255,255,255,0.15);
}

.main-header {
    height: 70px;
    padding: 0 24px;
    background: var(--bg-panel);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    border-bottom: var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 100;
    box-shadow: var(--glass-shadow);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-logo {
    height: 36px;
    width: auto;
    filter: drop-shadow(0 0 8px var(--accent-glow));
    transition: transform 0.3s var(--ease-out);
}

.header-logo:hover {
    transform: scale(1.05);
}

/* --- Título da Investigação --- */
.map-meta-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.map-title-input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.1rem;
    font-weight: 600;
    width: 280px;
    outline: none;
    transition: text-shadow 0.3s ease;
}

.map-title-input:focus {
    text-shadow: 0 0 8px var(--accent-glow);
}

.map-title-input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

/* --- Status do Arquivo --- */
.save-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    cursor: default;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent-success);
    box-shadow: 0 0 8px var(--accent-success);
    transition: all 0.3s ease;
}

.save-status.modified .status-dot {
    background-color: #ffca3a;
    box-shadow: 0 0 8px rgba(255, 202, 58, 0.6);
}

.save-status.modified .status-text::after {
    content: " (Não salvo)";
}

/* --- Widget de Relógio --- */
.system-clock {
    background: var(--bg-input);
    padding: 8px 14px;
    border-radius: 8px;
    border: var(--glass-border);
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--accent-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.system-clock i {
    font-size: 0.9em;
}

/* --- Elementos da Direita --- */
.header-divider {
    width: 1px;
    height: 24px;
    background: var(--border-subtle);
}

.github-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.github-link:hover {
    color: var(--text-main);
}

.version-badge {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    letter-spacing: 0.5px;
}

.hide-mobile {
    display: inline;
}

@media (max-width: 768px) {
    .main-header {
        height: auto;
        min-height: 70px;
        flex-direction: column;
        padding: 12px 15px;
        gap: 12px;
    }
    
    .header-left {
        width: 100%;
        justify-content: space-between;
    }
    
    .header-right {
        width: 100%;
        justify-content: center;
    }
    
    .header-actions {
        width: 100%;
        justify-content: space-between;
        gap: 6px;
    }
    
    .header-btn {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
        flex-grow: 1;
        max-width: 55px;
    }

    .map-title-input {
        width: 100%;
        font-size: 1rem;
    }

    .hide-mobile,
    .system-clock,
    .header-divider,
    .github-link,
    .version-badge {
        display: none !important;
    }

    #main-controls-wrapper {
        top: auto;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: column-reverse;
        align-items: center;
    }

    #mobile-menu-toggle {
        display: flex;
        box-shadow: var(--glass-shadow);
    }

    #controls-container {
        display: none;
        flex-direction: row; 
        padding: 10px;
    }

    #controls-container.show {
        display: block;
        animation: slideUpFade 0.3s var(--ease-out);
    }
    
    #controls {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    
    .separator { display: none; }
}

/* =================================================== */
/* ||                 TEMA CLARO                    || */
/* =================================================== */

body.light-theme {
    --bg-app: #e2e2e2;
    --bg-panel: rgba(240, 240, 240, 0.85);
    --bg-input: rgb(235, 235, 235);
    --text-main: #1a1a1f;
    --text-muted: #3f3f3f;
    --border-subtle: rgba(0, 0, 0, 0.1);
    --border-focus: rgba(249, 87, 56, 0.6);
    --glass-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.05);
    --glass-border: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-theme .node-rect {
    fill: #ffffff;
    stroke: #d0d0d5;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.05));
}

body.light-theme .node-group:hover .node-rect {
    fill: #fafafa;
    stroke: var(--text-muted);
    filter: drop-shadow(0 8px 16px rgba(0,0,0,0.1));
}

body.light-theme .entity-name, 
body.light-theme .entity-age, 
body.light-theme .entity-details-box {
    background: rgba(0, 0, 0, 0.03) !important;
    border: 1px solid var(--border-subtle) !important;
}

body.light-theme .modal-content input[type="text"],
body.light-theme .modal-content input[type="password"],
body.light-theme .modal-content textarea,
body.light-theme .modal-content select,
body.light-theme .cyber-slider {
    background-color: #ffffff;
    border-color: #cccccc;
    color: #1a1a1f;
}

body.light-theme .export-options-form select option {
    background-color: #ffffff;
    color: #1a1a1f;
}

body.light-theme .system-clock {
    background: #ffffff;
    color: var(--accent-secondary);
}

body.light-theme .header-btn {
    background: rgba(0, 0, 0, 0.03);
}
body.light-theme .header-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}

body.light-theme .handle-circle, 
body.light-theme .resize-handle {
    fill: #ffffff !important;
    stroke: var(--text-muted) !important;
}

/* =================================================== */
/* ||             MAPA & GRID (CANVAS)              || */
/* =================================================== */

#svg-container {
    flex-grow: 1;
    background-color: var(--bg-app);
    cursor: grab;
    position: relative;
    overflow: hidden;
}

#svg-container:active {
    cursor: grabbing;
}

.grid-pattern-path {
    stroke: var(--border-subtle);
    stroke-width: 0.5px;
}

/* =================================================== */
/* ||            TOOLBAR (DOCK LATERAL)             || */
/* =================================================== */

#main-controls-wrapper {
    position: absolute;
    top: 20px;
    left: 20px;
    bottom: 20px;
    z-index: 50;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#controls-container {
    pointer-events: auto;
    background: var(--bg-panel);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
    padding: 12px 8px;
    transition: transform 0.3s var(--ease-out), opacity 0.3s ease;
}

#controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* Botões da Toolbar */
#controls-container button,
#controls-container label,
.control-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 12px;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s var(--ease-out);
    position: relative;
}

#controls-container button:hover,
#controls-container label:hover,
.control-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Botões Ativos ou Especiais */
#toggle-select-mode-btn.active {
    background: var(--accent-primary) !important;
    color: white !important;
    box-shadow: 0 0 15px var(--accent-glow) !important;
}

/* Botão de Salvar (Destaque) */
#save-file-btn {
    color: var(--accent-success) !important;
}
#save-file-btn:hover {
    background: rgba(0, 255, 157, 0.1) !important;
    box-shadow: 0 0 10px rgba(0, 255, 157, 0.2) !important;
}

.separator {
    width: 20px;
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

/* --- Menu Mobile (Hambúrguer) --- */
#mobile-menu-toggle {
    pointer-events: auto;
    display: none; /* Desktop */
    width: 48px;
    height: 48px;
    background: var(--bg-panel);
    color: var(--text-main);
    border: var(--glass-border);
    border-radius: 12px;
    backdrop-filter: blur(var(--blur-strength));
}

/* Ajustes Mobile */
@media (max-width: 768px) {
    #main-controls-wrapper {
        top: auto;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: column-reverse; /* Menu abre pra cima */
        align-items: center;
    }

    #mobile-menu-toggle {
        display: flex;
        box-shadow: var(--glass-shadow);
    }

    #controls-container {
        display: none; /* Escondido por padrão no mobile */
        flex-direction: row; /* No mobile volta a ser horizontal ou grid */
        padding: 10px;
    }

    #controls-container.show {
        display: block;
        animation: slideUpFade 0.3s var(--ease-out);
    }
    
    #controls {
        display: grid;
        grid-template-columns: repeat(4, 1fr); /* Grid de ícones no mobile */
        gap: 8px;
    }
    
    .separator { display: none; }
}

@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =================================================== */
/* ||                  NÓS (NODES)                  || */
/* =================================================== */

.node-group {
    cursor: pointer;
    transition: filter 0.2s ease, opacity 0.2s ease;
    will-change: filter, opacity;
}

.node-rect {
    fill: var(--bg-panel);
    stroke: var(--border-subtle);
    stroke-width: 1.5px;
    rx: 12px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
    transition: all 0.3s var(--ease-out);
}

.node-group:hover .node-rect {
    stroke: var(--text-muted);
    fill: rgba(40, 40, 45, 0.8);
    filter: drop-shadow(0 8px 16px rgba(0,0,0,0.4));
}

.node-group.selected .node-rect {
    stroke: var(--accent-primary);
    stroke-width: 2px;
    filter: drop-shadow(0 0 15px var(--accent-glow));
}

.node-group.multi-selected .node-rect {
    stroke: var(--accent-primary);
    stroke-dasharray: 5, 5;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.node-label, .node-html-content {
    color: var(--text-main);
    font-weight: 500;
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    font-family: inherit;
}

.node-editor-textarea {
    background: transparent;
    color: var(--text-main);
    caret-color: var(--accent-primary);
    text-align: center;
    font-family: inherit;
    font-weight: 500;
}

/* --- Tipos Especiais de Nós --- */

.node-image-container {
    border-radius: 12px;
    overflow: hidden;
    border: var(--glass-border);
    background: black;
}

.image-node-label {
    background: rgba(0, 0, 0, 0.75) !important;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.1);
}

.view-image-btn {
    background: rgba(0, 0, 0, 0.75) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
}
.view-image-btn:hover {
    background: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
}

.entity-node-container {
    color: var(--text-main);
    font-family: inherit;
}

.entity-photo {
    background: var(--bg-input) !important;
    border: 1px solid var(--border-subtle) !important;
}

.entity-name, .entity-age, .entity-details-box {
    background: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid var(--border-subtle) !important;
    color: var(--text-muted) !important;
    border-radius: 6px !important;
}

.entity-field-label {
    color: var(--text-muted) !important;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =================================================== */
/* ||                  CONEXÕES                     || */
/* =================================================== */

.edge-path {
    stroke: var(--text-muted);
    stroke-width: 2px;
    fill: none;
    opacity: 0.4;
    transition: stroke 0.3s ease, opacity 0.3s ease, filter 0.3s ease;
}

.arrowhead-path {
    fill: var(--text-muted);
    opacity: 0.4;
    transition: all 0.3s ease;
}

.edge-group:hover .edge-path {
    stroke: var(--text-main);
    opacity: 1;
    filter: drop-shadow(0 0 4px var(--accent-secondary));
}
.edge-group:hover .arrowhead-path {
    fill: var(--text-main);
    opacity: 1;
}

.edge-path.selected {
    stroke: var(--accent-primary);
    stroke-width: 2.5px;
    opacity: 1;
    filter: drop-shadow(0 0 6px var(--accent-primary));
}

.link-preview-path {
    stroke: var(--text-muted);
    stroke-width: 2px;
    stroke-dasharray: 6, 4;
    fill: none !important;
    opacity: 0.8;
    pointer-events: none;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.3));
    animation: dashFlow 0.5s linear infinite;
}

@keyframes dashFlow {
    to { stroke-dashoffset: -24; }
}

.edge-path-hitbox {
    stroke: transparent;
    stroke-width: 25px;
    fill: none;
    cursor: pointer;
}

/* =================================================== */
/* ||           CONTEÚDO INTERNO DOS NÓS            || */
/* =================================================== */

/* Container HTML dentro do SVG */
.node-foreign-object {
    pointer-events: none; /* Deixa cliques passarem para o grupo */
    overflow: visible;
}

/* Centralização do Texto */
.node-html-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8px;
    pointer-events: none; 
}

.node-editor-textarea {
    width: 100%;
    height: 100%;
    resize: none;
    overflow: hidden;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    text-align: center;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    pointer-events: auto;
}

.text-sticker-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4px;
}

.text-sticker-textarea {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    overflow: hidden;
    text-align: center;
    color: var(--text-main);
    pointer-events: auto;
}

.icon-sticker-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-sticker-container i {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.node-image-container {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.node-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-node-label {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    color: var(--text-main);
    padding: 6px 8px;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity 0.2s ease;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.view-image-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
}

.node-group:hover .image-node-label,
.node-group:hover .view-image-btn {
    opacity: 1;
}

.view-image-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    transform: scale(1.1);
}

/* --- Nó de Entidade (Pessoa/Empresa) --- */

.entity-node-container {
    display: flex;
    align-items: flex-start; /* Alinha foto e info no topo */
    width: 100%;
    height: 100%;
    gap: 12px;
    padding: 12px;
    box-sizing: border-box;
    text-align: left; /* Garante texto à esquerda */
}

.entity-photo {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.entity-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.entity-photo i {
    font-size: 1.5rem;
    color: var(--text-muted);
}

.entity-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
}

.entity-info-header {
    display: flex;
    gap: 8px;
    align-items: center;
}

.entity-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.entity-field-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    font-weight: 600;
}

.entity-name, .entity-age, .entity-details-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 4px 8px;
    color: var(--text-main);
    font-size: 0.85rem;
    min-height: 24px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entity-details-box {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.3;
    min-height: 40px;
    color: var(--text-muted);
}

.company-field-cnpj {
    font-family: 'Courier New', monospace;
    letter-spacing: -0.5px;
}

/* =================================================== */
/* ||             MENUS FLUTUANTES (UI)             || */
/* =================================================== */

#context-menu-container {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 200;
    
    background: var(--bg-panel);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 12px;
    padding: 6px;
    
    display: flex;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translate(-50%, -100%) scale(0.9);
}

#context-menu-container.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -100%) scale(1);
}

#context-menu-container button {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-main);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

#context-menu-container button:hover {
    background: rgba(255, 255, 255, 0.1);
}

#context-delete-btn:hover {
    background: rgba(255, 42, 109, 0.2) !important;
    color: var(--accent-danger);
}

#add-controls-container {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 150;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#add-controls-container.visible {
    opacity: 1;
    pointer-events: auto;
}

.add-node-context-btn {
    position: absolute;
    width: 24px;
    height: 24px;
    background: var(--bg-app);
    border: 1.5px solid var(--accent-primary);
    color: var(--accent-primary);
    border-radius: 50%;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: translate(-50%, -50%);
}

.add-node-context-btn:hover {
    background: var(--accent-primary);
    color: white;
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* =================================================== */
/* ||             MODAIS E JANELAS (UI)             || */
/* =================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px); /* Desfoque no fundo do mapa */
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    animation: fadeIn 0.2s forwards;
    padding: 20px; 
    box-sizing: border-box;
}

@keyframes fadeIn { to { opacity: 1; } }

.modal-content {
    background: var(--bg-panel);
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    padding: 24px;
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    color: var(--text-main);
    position: relative;
    transform: scale(0.95);
    animation: scaleIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes scaleIn { to { transform: scale(1); } }

.modal-content h4 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    font-weight: 600;
    color: var(--text-main);
    border-left: 3px solid var(--accent-primary);
    padding-left: 10px;
    letter-spacing: 0.5px;
}

.modal-content p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.5;
}

/* --- Formulários e Inputs --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.modal-content input[type="text"],
.modal-content input[type="password"],
.modal-content textarea,
.modal-content select {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 12px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
    outline: none;
}

.modal-content input:focus,
.modal-content textarea:focus,
.modal-content select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
    background-color: rgba(0, 0, 0, 0.6);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.checkbox-group input[type="checkbox"] {
    accent-color: var(--accent-primary);
    width: 16px;
    height: 16px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions button {
    padding: 10px 20px;
    font-size: 0.9rem;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    font-weight: 500;
}

.modal-actions button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.modal-actions button.btn-primary, 
#confirm-save-btn, 
#confirm-load-btn, 
#save-entity-edit-btn,
#confirm-export-btn {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
    box-shadow: 0 4px 10px var(--accent-glow);
}

.modal-actions button.btn-primary:hover,
#confirm-save-btn:hover, 
#confirm-load-btn:hover, 
#save-entity-edit-btn:hover,
#confirm-export-btn:hover {
    background: var(--accent-primary);
    box-shadow: 0 6px 15px var(--accent-glow);
    transform: translateY(-2px);
    filter: brightness(1.2);
}

.visuals-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.visuals-selection-grid button {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    padding: 20px;
    border-radius: 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.visuals-selection-grid button i {
    font-size: 1.8rem;
    color: var(--accent-secondary);
    transition: transform 0.2s ease;
}

.visuals-selection-grid button:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-secondary);
    color: var(--text-main);
}

.visuals-selection-grid button:hover i {
    transform: scale(1.2);
    filter: drop-shadow(0 0 8px var(--accent-secondary));
}

#icon-grid {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 8px;
}

.color-palette-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.color-option:hover {
    transform: scale(1.15);
    border-color: #fff;
    box-shadow: 0 0 10px currentColor;
}

.photo-upload-label {
    display: block;
    width: 100px;
    height: 100px;
    border: 2px dashed var(--border-subtle);
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    margin: 0 auto;
    transition: border-color 0.2s;
}

.photo-upload-label:hover {
    border-color: var(--accent-primary);
}

.photo-upload-label img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-upload-label span {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0,0,0,0.7);
    font-size: 0.6rem;
    text-align: center;
    padding: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.photo-upload-label:hover span {
    opacity: 1;
}

/* =================================================== */
/* ||             MENU DE CONFIGURAÇÕES             || */
/* =================================================== */

.settings-toggles-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setting-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.setting-name i {
    color: var(--accent-secondary);
    margin-right: 6px;
    width: 16px;
    text-align: center;
}

.setting-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Animação de Auto-Save no Header --- */
.save-status.autosaving .status-dot {
    background-color: #00d2ff;
    box-shadow: 0 0 8px #00d2ff;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

.cyber-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.cyber-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    transition: .3s;
    border-radius: 24px;
}

.cyber-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    transition: .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 50%;
}

.cyber-switch input:checked + .cyber-slider {
    background-color: rgba(249, 87, 56, 0.2);
    border-color: var(--accent-primary);
}

.cyber-switch input:checked + .cyber-slider:before {
    transform: translateX(20px);
    background-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-glow);
}

.form-divider {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: 24px 0;
}

.export-options-form select {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 12px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
    outline: none;
    cursor: pointer;
    
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23a0a0a5" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px top 50%;
    padding-right: 36px;
}

.export-options-form select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
    background-color: rgba(0, 0, 0, 0.6);
}

.export-options-form select option {
    background-color: var(--bg-app);
    color: var(--text-main);
    padding: 10px;
}

/* --- MODO DE PRIVACIDADE --- */
/* Quando o body tiver essa classe, os dados sensíveis são borrados */
body.privacy-mode-active .node-html-content,
body.privacy-mode-active .entity-info,
body.privacy-mode-active .text-sticker-container,
body.privacy-mode-active .node-image,
body.privacy-mode-active .entity-photo img {
    filter: blur(5px);
    opacity: 0.8;
    user-select: none;
    pointer-events: none;
    transition: filter 0.3s ease;
}

body.hide-grid-active .grid-pattern-path {
    display: none;
}

/* =================================================== */
/* ||              NOTIFICAÇÕES (TOASTS)            || */
/* =================================================== */

#notification-container {
    position: absolute;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    padding: 20px;
}

/* Posicionamento Desktop: Topo Direito */
@media (min-width: 769px) {
    #notification-container {
        top: 0;
        right: 0;
        align-items: flex-end;
    }
}

/* Posicionamento Mobile: Base Central */
@media (max-width: 768px) {
    #notification-container {
        bottom: 0;
        left: 0;
        width: 100%;
        align-items: center;
        flex-direction: column-reverse;
    }
}

.toast {
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: var(--glass-border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    
    color: var(--text-main);
    padding: 12px 18px;
    border-radius: 12px;
    min-width: 260px;
    max-width: 340px;
    font-size: 0.9rem;
    font-weight: 500;
    
    position: relative;
    overflow: hidden;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    
    animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast i {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 5px currentColor);
}

.toast.info { border-left: 4px solid var(--accent-secondary); }
.toast.info i { color: var(--accent-secondary); }

.toast.success { border-left: 4px solid var(--accent-success); }
.toast.success i { color: var(--accent-success); }

.toast.warning { border-left: 4px solid #ffca3a; }
.toast.warning i { color: #ffca3a; }

.toast.error { border-left: 4px solid var(--accent-danger); }
.toast.error i { color: var(--accent-danger); }

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
}

.toast-progress-bar {
    height: 100%;
    width: 100%;
    background: currentColor;
    opacity: 0.7;
    transform-origin: left;
}

/* Animações */
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(50px) scale(0.9); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes fadeOut {
    to { opacity: 0; transform: scale(0.9) translateY(-10px); }
}

/* =================================================== */
/* ||             CAIXA DE SELEÇÃO (DRAG)           || */
/* =================================================== */

.selection-box {
    fill: rgba(249, 87, 56, 0.1);
    stroke: var(--accent-primary);
    stroke-width: 1px;
    stroke-dasharray: 4, 4;
    pointer-events: none;
    animation: dashFlow 0.5s linear infinite;
}

/* =================================================== */
/* ||          UTILITÁRIOS & EXPORTAÇÃO             || */
/* =================================================== */

/* Força tema claro APENAS na exportação (se selecionado) */
.forcing-light-theme {
    background-color: #ffffff !important;
    --text-main: #000000 !important;
    --text-muted: #444444 !important;
    --border-subtle: #cccccc !important;
}

.forcing-light-theme .node-rect {
    fill: #f4f4f4 !important;
    stroke: #333 !important;
    filter: none !important;
}

.forcing-light-theme text,
.forcing-light-theme input,
.forcing-light-theme textarea,
.forcing-light-theme .text-sticker-label,
.forcing-light-theme i {
    fill: #000000 !important;
    color: #000000 !important;
    text-shadow: none !important;
}

.forcing-light-theme .edge-path {
    stroke: #000 !important;
    opacity: 1 !important;
    filter: none !important;
}
.forcing-light-theme .arrowhead-path {
    fill: #000 !important;
    opacity: 1 !important;
}

.hidden { display: none !important; }

/* =================================================== */
/* ||          CORREÇÕES DE STICKERS E LINHAS       || */
/* =================================================== */

.visual-path-hitbox {
    stroke: transparent;
    stroke-width: 15px;
    fill: none;
    cursor: pointer;
    pointer-events: stroke !important;
}

/* Fix: Estilo da linha desenhada */
.visual-path {
    fill: none;
    stroke-width: 2px;
    pointer-events: none;
}

.visual-path.selected {
    stroke: var(--accent-primary) !important;
    filter: drop-shadow(0 0 6px var(--accent-primary));
}

/* Fix: Cursor do mouse ao clicar no botão de Seta/Linha */
.drawing-mode {
    cursor: crosshair !important;
}

/* Fix: Sticker de Texto (Fundo transparente por padrão) */
.text-sticker-node .node-rect {
    fill: transparent !important;
    stroke: transparent !important;
    filter: none !important;
    box-shadow: none !important;
}

/* Borda sutil apenas ao passar o mouse ou selecionar o texto */
.text-sticker-node.selected .node-rect,
.text-sticker-node:hover .node-rect {
    stroke: var(--border-subtle) !important;
    stroke-dasharray: 4, 4;
}

/* Fix: Quebra de linha correta para textos muito grandes */
.text-sticker-label {
    white-space: pre-wrap;
    word-break: break-word;
    display: inline-block;
    width: 100%;
}

/* Fix: Controladores das Linhas e Shapes */
.handle-circle, .resize-handle {
    fill: #ffffff !important;
    stroke: var(--bg-app) !important;
    stroke-width: 2px;
    transition: fill 0.2s ease, transform 0.2s ease;
    transform-box: fill-box;
    transform-origin: center;
}

.handle-circle:hover, .resize-handle:hover {
    fill: var(--accent-primary) !important;
    transform: scale(1.3);
}

.shape-node {
    transition: transform 0.05s ease;
}

#details-measurer {
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -9999 !important;
}

/* =================================================== */
/* ||               MODAL DE APOIO                  || */
/* =================================================== */

.ultimate-support-modal {
    background: rgba(255, 255, 255, 0.02) !important; 
    backdrop-filter: blur(10px); 
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2) !important;
}

/* Fundo SVG */
.support-minimal-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1; 
    opacity: 0.35;
    pointer-events: none; 
}

/* O visual dos "Nós Fantasmas" */
.bg-minimal-node {
    fill: url(#node-gradient); /* Aplica o gradiente SVG */
    stroke: var(--border-subtle);
    stroke-width: 1.5px;
}

/* O visual das Conexões */
.bg-minimal-edge {
    fill: none;
    stroke: var(--text-muted);
    stroke-width: 2px;
    opacity: 0.5;
}

/* Ícone de Coração com Glow Dinâmico */
.prominent-heart-icon {
    filter: drop-shadow(0 0 12px var(--accent-danger));
    display: inline-block;
}

/* Botão Secundário Estilo Vidro */
.btn-secondary-glass {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255,255,255,0.05) !important;
    color: var(--text-muted) !important;
}
.btn-secondary-glass:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: var(--text-main) !important;
    transform: translateY(-2px);
}

/* =================================================== */
/* Wrapper de Ações do Mapa (Zoom, Histórico, etc) */
/* =================================================== */

#map-actions-wrapper {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 50;
    pointer-events: auto;
    background: var(--bg-panel);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 12px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: opacity 0.3s ease;
}

.map-action-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.map-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.separator-vertical {
    width: 100%;
    height: 1px;
    background: var(--border-subtle);
    margin: 2px 0;
}

@media (max-width: 768px) {
    #map-actions-wrapper {
        bottom: 15px;
        right: 15px;
        padding: 5px;
        gap: 3px;
        border-radius: 10px;
    }
    .map-action-btn {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
        border-radius: 6px;
    }
}
