/* Sistema de Mapas / Diagramas Interativos - MT2 Godot */

/* ---------- Seletor de Diagramas (Público e Admin) ---------- */
.map-section {
    margin-top: 78px;
}

.map-diagram-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.map-diagram-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1px solid rgba(226, 214, 191, .14);
    border-radius: 5px;
    background: #17181d;
    color: #a9a59f;
    font-family: var(--font-display, 'Manrope', sans-serif);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .2s, color .2s, background .2s, transform .15s;
}

.map-diagram-tab:hover {
    color: #f1eee8;
    border-color: rgba(197, 164, 107, .35);
}

.map-diagram-tab.active {
    background: linear-gradient(135deg, rgba(197, 164, 107, .16), rgba(197, 164, 107, .05));
    border-color: rgba(197, 164, 107, .55);
    color: #e0c18b;
}

.map-diagram-tab small {
    padding: 2px 6px;
    border-radius: 99px;
    background: rgba(255, 255, 255, .06);
    color: #99979a;
    font-size: 10px;
    font-weight: 600;
}

.map-diagram-desc {
    margin: 0 0 16px;
    color: #a9a59f;
    font-size: 13px;
    line-height: 1.6;
}

/* ---------- Viewport do Mapa (Arrastável / Zoom) ---------- */
.map-viewport {
    position: relative;
    width: 100%;
    height: min(68vh, 620px);
    min-height: 380px;
    overflow: hidden;
    border: 1px solid rgba(197, 164, 107, .22);
    border-radius: 8px;
    background-color: #111216;
    background-image:
        radial-gradient(ellipse at 50% 45%, rgba(197, 164, 107, .06), transparent 62%),
        radial-gradient(rgba(226, 214, 191, .11) 1px, transparent 1px);
    background-size: 100% 100%, 28px 28px;
    box-shadow: inset 0 0 60px rgba(0, 0, 0, .45), 0 18px 45px rgba(0, 0, 0, .25);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;
}

.map-viewport.is-panning {
    cursor: grabbing;
}

.map-world {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
}

.map-edges-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    overflow: visible;
    pointer-events: none;
}

.map-edge-path {
    fill: none;
    stroke: rgba(197, 164, 107, .55);
    stroke-width: 2.2;
    stroke-linecap: round;
    transition: stroke .2s, stroke-width .2s;
}

.map-edge-path.is-dashed {
    stroke-dasharray: 8 6;
}

.map-edge-path.is-dotted {
    stroke-dasharray: 2 6;
}

.map-edge-path.is-highlighted {
    stroke: #e0c18b;
    stroke-width: 3;
    filter: drop-shadow(0 0 6px rgba(224, 193, 139, .45));
}

.map-edge-label-bg {
    fill: #17181d;
    stroke: rgba(197, 164, 107, .35);
    stroke-width: 1;
}

.map-edge-label-text {
    fill: #dfd9cf;
    font-family: var(--font-body, 'DM Sans', sans-serif);
    font-size: 10px;
    font-weight: 600;
    text-anchor: middle;
    dominant-baseline: central;
}

/* ---------- Nós / Itens do Mapa ---------- */
.map-node {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    width: 120px;
    cursor: pointer;
    z-index: 2;
    outline: none;
    --node-accent: #c5a46b;
}

.map-node-avatar {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 14px;
    border: 2px solid var(--node-accent);
    background: linear-gradient(145deg, #212229, #14151a);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .5), 0 0 0 3px rgba(16, 17, 21, .75);
    overflow: hidden;
    display: grid;
    place-items: center;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.map-node-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.map-node-placeholder {
    color: var(--node-accent);
    font-size: 24px;
    font-weight: 800;
    font-family: var(--font-display, 'Manrope', sans-serif);
}

.map-node:hover .map-node-avatar,
.map-node:focus-visible .map-node-avatar,
.map-node.is-selected .map-node-avatar {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .6), 0 0 18px color-mix(in srgb, var(--node-accent) 45%, transparent);
}

.map-node.is-connecting-source .map-node-avatar {
    box-shadow: 0 0 0 4px rgba(224, 193, 139, .55), 0 0 22px rgba(224, 193, 139, .5);
    animation: mapPulse 1.2s infinite ease-in-out;
}

@keyframes mapPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

.map-node-label {
    max-width: 140px;
    padding: 4px 9px;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 5px;
    background: rgba(18, 19, 24, .92);
    color: #f1eee8;
    font-family: var(--font-display, 'Manrope', sans-serif);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
}

.map-node-sub {
    margin-top: -3px;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(197, 164, 107, .14);
    color: #e0c18b;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .04em;
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Controles Flutuantes do Mapa ---------- */
.map-controls {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 10;
    display: flex;
    gap: 6px;
    padding: 5px;
    border: 1px solid rgba(226, 214, 191, .14);
    border-radius: 6px;
    background: rgba(18, 19, 24, .88);
    backdrop-filter: blur(10px);
}

.map-ctrl-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 9px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 4px;
    background: #22232a;
    color: #e6e1d8;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, border-color .15s, color .15s;
}

.map-ctrl-btn:hover {
    border-color: rgba(197, 164, 107, .45);
    color: #e0c18b;
}

.map-hint-pill {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 9;
    padding: 6px 11px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 99px;
    background: rgba(18, 19, 24, .82);
    color: #a9a59f;
    font-size: 10px;
    font-weight: 600;
    backdrop-filter: blur(8px);
    pointer-events: none;
}

/* ---------- Tooltip (Hover no Desktop) ---------- */
.map-tooltip {
    position: absolute;
    z-index: 25;
    width: min(280px, calc(100% - 24px));
    padding: 12px;
    border: 1px solid rgba(197, 164, 107, .45);
    border-radius: 7px;
    background: rgba(20, 21, 27, .96);
    box-shadow: 0 16px 38px rgba(0, 0, 0, .55);
    backdrop-filter: blur(12px);
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .15s ease, transform .15s ease;
}

.map-tooltip.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.map-tooltip-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.map-tooltip-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid rgba(197, 164, 107, .35);
    flex-shrink: 0;
}

.map-tooltip-sub {
    display: inline-block;
    color: #c5a46b;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.map-tooltip-title {
    margin: 2px 0 0;
    color: #f1eee8;
    font-family: var(--font-display, 'Manrope', sans-serif);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
}

.map-tooltip-desc {
    margin: 6px 0 0;
    color: #b4b0aa;
    font-size: 11px;
    line-height: 1.5;
    white-space: pre-line;
    max-height: 120px;
    overflow: hidden;
}

/* ---------- Card/Drawer de Detalhes (Clique / Mobile) ---------- */
.map-info-drawer {
    position: absolute;
    left: 14px;
    bottom: 14px;
    z-index: 30;
    width: min(360px, calc(100% - 28px));
    max-height: calc(100% - 28px);
    overflow-y: auto;
    padding: 16px;
    border: 1px solid rgba(197, 164, 107, .45);
    border-radius: 8px;
    background: rgba(20, 21, 27, .97);
    box-shadow: 0 20px 46px rgba(0, 0, 0, .65);
    backdrop-filter: blur(14px);
    display: none;
}

.map-info-drawer.is-open {
    display: block;
    animation: drawerIn .18s ease;
}

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

.map-drawer-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 50%;
    background: #24252d;
    color: #e6e1d8;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.map-drawer-head {
    display: flex;
    gap: 12px;
    align-items: center;
    padding-right: 30px;
}

.map-drawer-img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid rgba(197, 164, 107, .4);
    flex-shrink: 0;
}

.map-drawer-head h4 {
    margin: 2px 0 0;
    color: #f1eee8;
    font-family: var(--font-display, 'Manrope', sans-serif);
    font-size: 16px;
    font-weight: 700;
}

.map-drawer-desc {
    margin: 12px 0 0;
    color: #c5c1ba;
    font-size: 12.5px;
    line-height: 1.65;
    white-space: pre-line;
}

.map-drawer-links {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.map-drawer-links small {
    display: block;
    margin-bottom: 7px;
    color: #8e8c91;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.map-drawer-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.map-drawer-chip {
    padding: 5px 9px;
    border: 1px solid rgba(197, 164, 107, .28);
    border-radius: 4px;
    background: rgba(197, 164, 107, .08);
    color: #e0c18b;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.map-drawer-chip:hover {
    background: rgba(197, 164, 107, .18);
}

/* ---------- Admin: Construtor de Diagramas ---------- */
.admin-map-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #17181d;
}

.admin-map-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    flex: 1 1 320px;
}

.admin-map-selector select {
    min-width: 210px;
    min-height: 38px;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 4px;
    background: #111216;
    color: var(--text);
    font-size: 12px;
}

.admin-map-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.admin-map-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 16px;
    align-items: start;
}

.admin-map-canvas-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-canvas-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #17181d;
}

.admin-canvas-bar-left {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.btn-map-tool {
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #23242b;
    color: #d7d2ca;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-map-tool:hover {
    border-color: rgba(197, 164, 107, .45);
    color: var(--gold-hi);
}

.btn-map-tool.is-active {
    border-color: var(--gold);
    background: rgba(197, 164, 107, .18);
    color: var(--gold-hi);
}

.admin-map-inspector {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: linear-gradient(145deg, rgba(29, 30, 36, .98), rgba(23, 24, 29, .98));
}

.admin-map-inspector h3 {
    margin: 0 0 12px;
    font: 700 14px var(--font-display);
}

.inspector-empty {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.6;
}

.color-swatches {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
}

.color-swatch.active {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px rgba(197, 164, 107, .6);
}

.node-img-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.node-img-preview img {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--line);
}

.edge-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.edge-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 9px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 4px;
    background: #131418;
    font-size: 11px;
}

.edge-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.edge-item-controls {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
}

.edge-item-controls input,
.edge-item-controls select {
    min-height: 30px;
    padding: 4px 8px;
    font-size: 10px;
}

.connect-banner {
    padding: 8px 12px;
    border: 1px solid rgba(197, 164, 107, .45);
    border-radius: 4px;
    background: rgba(197, 164, 107, .12);
    color: var(--gold-hi);
    font-size: 11px;
    font-weight: 600;
}

/* ---------- Responsividade Mobile ---------- */
@media (max-width: 960px) {
    .admin-map-workspace {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .map-viewport {
        height: min(64vh, 450px);
        min-height: 320px;
    }

    .map-node {
        width: 104px;
    }

    .map-node-avatar {
        width: 60px;
        height: 60px;
        border-radius: 12px;
    }

    .map-node-label {
        font-size: 10px;
        max-width: 115px;
    }

    .map-hint-pill {
        display: none;
    }

    .map-info-drawer {
        left: 8px;
        right: 8px;
        bottom: 8px;
        width: auto;
        max-height: 62%;
    }
}
