/*
    Concept Map – Utility Page
*/

:root {
    --primary: #076FB7;
    --primary-light: #2A8CD4;
    --accent: #D3B574;
    --accent-hover: #b89a57;
    --dark-bg: #0D1117;
    --card-bg: #161B22;
    --card-border: rgba(211, 181, 116, 0.15);
    --text-main: #c9d1d9;
    --text-white: #ffffff;
    --text-muted: #8b949e;
    --error: #f85149;
    --transition: all 0.2s ease;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--dark-bg);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image:
        linear-gradient(rgba(7, 111, 183, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(7, 111, 183, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.18;
    pointer-events: none;
    z-index: 0;
    animation: driftGlow 18s ease-in-out infinite alternate;
}

.glow-1 {
    width: 500px;
    height: 500px;
    background: var(--primary);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.glow-2 {
    width: 400px;
    height: 400px;
    background: var(--accent);
    bottom: -80px;
    left: -80px;
    animation-delay: -9s;
    opacity: 0.1;
}

@keyframes driftGlow {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(-40px, 40px) scale(1.1);
    }

    100% {
        transform: translate(40px, -20px) scale(0.95);
    }
}

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    height: 90px;
}

.site-header-inner {
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--accent);
}

.back-link i {
    font-size: 0.9rem;
    opacity: 0.7;
    transition: var(--transition);
}

.back-link:hover i {
    transform: translateX(-3px);
    opacity: 1;
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-white);
}

.logo-dot {
    color: var(--accent);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 5px 14px;
    margin-left: 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.breadcrumb i {
    color: var(--accent);
    font-size: 0.8rem;
}

.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 24px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: var(--shadow-lg);
}

.tb-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.group-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    margin-left: 2px;
}

.tb-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tb-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tb-btn:hover,
.tb-btn.active {
    background: rgba(7, 111, 183, 0.15);
    border-color: var(--primary);
    color: var(--text-white);
}

.tb-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none;
    color: #fff;
    font-weight: 600;
}

.tb-btn.primary:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(7, 111, 183, 0.3);
}

.tb-btn.small {
    padding: 0;
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
    justify-content: center;
}

/* Colori icone gruppo Struttura */
#add-node-btn i {
    color: #4dabf7;
}

#add-circle-btn i {
    color: #ff8787;
}

#add-oval-btn i {
    color: #b197fc;
}

#add-title-btn i {
    color: #ced4da;
}

#add-sticky-btn i {
    color: #fcc419;
}

#add-link-btn i {
    color: #69db7c;
}

#insert-emoji-btn i {
    color: #fcc419;
}

#add-node-btn:hover i,
#add-circle-btn:hover i,
#add-oval-btn:hover i,
#add-title-btn:hover i,
#add-link-btn:hover i,
#insert-emoji-btn:hover i {
    filter: brightness(1.2);
}

.icon-clear {
    color: #f85149;
}

.icon-import {
    color: #2ea44f;
}

.icon-export {
    color: #0969da;
}

.icon-png {
    color: #D3B574;
}

.tb-btn:hover .icon-clear,
.tb-btn:hover .icon-import,
.tb-btn:hover .icon-export,
.tb-btn:hover .icon-png {
    filter: brightness(1.2);
}

.tb-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-white);
    border-radius: 6px;
    padding: 4px 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

.tb-select:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tb-select option {
    background: var(--card-bg);
    color: var(--text-main);
}

.divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 4px;
}

.color-picker-wrap {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}

.color-picker-wrap.small {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

.color-picker-wrap:hover {
    border-color: var(--primary);
    transform: scale(1.1);
}

/* ── Tooltip ────────────────────────────────────── */
.custom-tooltip {
    position: fixed;
    background: rgba(13, 17, 23, 0.95);
    color: var(--text-white);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    pointer-events: none;
    z-index: 10000;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s, transform 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

.custom-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.tb-color {
    padding: 0;
    width: 150%;
    height: 150%;
    position: absolute;
    top: -25%;
    left: -25%;
    cursor: pointer;
    border: none;
}

/* ── App Wrapper & Canvas ────────────────────────── */
.app-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    padding-top: 90px;
    /* offset for header */
}

.canvas-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: auto;
    background-color: #0d1117;
    /* Default dark */
    /* Optional: una lieve griglia interna, indipendente dallo sfondo animato */
    background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
    background-size: 20px 20px;
    transition: background-color 0.3s ease;
}

.canvas-container.light-theme {
    background-color: #f8f9fa;
    background-image: radial-gradient(rgba(0, 0, 0, 0.1) 1px, transparent 1px);
}

.canvas-container.light-theme .empty-state h2 {
    color: #333;
}

.canvas-container.light-theme .empty-state p {
    color: #666;
}

.canvas-container.light-theme .map-link {
    stroke: #999;
}

.canvas-container.light-theme .node.title {
    color: #333;
}

#canvas-content {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
}

#links-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: visible;
}

#nodes-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* ── Link Styles ─────────────────────────────────── */
.map-link {
    stroke: var(--text-muted);
    stroke-width: 2px;
    fill: none;
    stroke-dasharray: 4;
    transition: stroke 0.2s;
}

.map-link:hover {
    stroke: var(--accent);
    stroke-width: 3px;
    stroke-dasharray: 0;
}

.link-delete-btn {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--error);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    z-index: 100;
    pointer-events: auto;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, background 0.2s;
}

.link-delete-btn:hover {
    background: #FF5252;
    transform: scale(1.1);
}

/* ── Node Styles ─────────────────────────────────── */
.node {
    position: absolute;
    background: var(--primary);
    color: #fff;
    min-width: 120px;
    min-height: 60px;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    pointer-events: auto;
    cursor: grab;
    user-select: none;
    border: 2px solid transparent;
    transition: box-shadow 0.2s, transform 0.1s;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.node.circle {
    border-radius: 50%;
}

.node.oval {
    border-radius: 100px;
}

.node.title {
    background: transparent;
    box-shadow: none;
    font-size: 1.8rem;
    font-weight: 800;
    min-width: 200px;
    min-height: auto;
    border-color: transparent;
}

.node.title.selected {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
}

.node.sticky {
    background: #fff9c4;
    color: #333;
    min-width: 150px;
    min-height: 150px;
    border-radius: 2px;
    box-shadow: 2px 5px 15px rgba(0, 0, 0, 0.2);
    padding: 20px;
    transform: rotate(-1deg);
    position: relative;
    border: none;
}

.node.sticky::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 0;
    border-width: 0 0 25px 25px;
    border-style: solid;
    border-color: transparent transparent rgba(0, 0, 0, 0.1) transparent;
    transition: var(--transition);
}

.node.sticky.selected {
    box-shadow: 0 0 0 2px var(--accent), 5px 10px 25px rgba(0, 0, 0, 0.3);
    transform: rotate(0deg) scale(1.02);
}

.node.sticky .node-content {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    line-height: 1.4;
}

.node.emoji {
    background: transparent !important;
    box-shadow: none;
    font-size: 3rem;
    min-width: 50px;
    min-height: 50px;
    padding: 0;
    border-color: transparent !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.node.emoji.selected {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    filter: drop-shadow(0 0 8px var(--primary));
}

.node.emoji .node-content {
    padding: 0;
    min-height: auto;
    width: auto;
    display: inline-block;
    pointer-events: none;
    user-select: none;
}

.node:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.node.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(211, 181, 116, 0.4), 0 12px 30px rgba(0, 0, 0, 0.6);
    z-index: 10;
}

.node-content {
    outline: none;
    cursor: text;
    user-select: text;
    min-height: 20px;
    width: 100%;
    padding: 5px;
}

.node-content:not(.emoji .node-content):empty::before {
    content: "Testo nodo...";
    opacity: 0.6;
}

.delete-node {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: var(--error);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    z-index: 11;
}

.duplicate-node {
    position: absolute;
    top: -10px;
    right: 20px;
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    z-index: 11;
}

.node:hover .delete-node,
.node:hover .duplicate-node {
    opacity: 1;
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    z-index: 10;
    border-bottom-right-radius: 8px;
}

.resize-handle::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 8px 8px;
    border-color: transparent transparent rgba(255, 255, 255, 0.4) transparent;
}

/* To draw links state */
.canvas-container.linking {
    cursor: crosshair !important;
}

.canvas-container.linking .node {
    cursor: crosshair;
}

.canvas-container.linking .node:hover {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent);
}

/* ── Zoom Controls ──────────────────────────────── */
.zoom-controls {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(22, 27, 34, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    padding: 6px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: background-color 0.3s, border-color 0.3s;
}

.light-theme+.zoom-controls {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.light-theme+.zoom-controls .zoom-btn,
.light-theme+.zoom-controls .zoom-display,
.light-theme+.zoom-controls .zoom-display input,
.light-theme+.zoom-controls .tb-select {
    color: #333;
}

.light-theme+.zoom-controls .zoom-display {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.05);
}

.zoom-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.zoom-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
}

.zoom-display {
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.zoom-display input {
    background: transparent;
    border: none;
    color: var(--text-white);
    width: 30px;
    text-align: right;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    outline: none;
}

.zoom-display span {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* ── Empty State ────────────────────────────────── */
.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    z-index: 1000;
    /* Sopra a tutto */
    transition: opacity 0.3s ease;
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.empty-state.hidden {
    opacity: 0;
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--primary);
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-white);
    margin-bottom: 10px;
    opacity: 0.8;
}

.empty-state p {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ── Custom Modal ───────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-icon {
    font-size: 3rem;
    color: var(--error);
    margin-bottom: 20px;
}

.modal-content h3 {
    font-size: 1.5rem;
    color: var(--text-white);
    margin-bottom: 15px;
}

.modal-content p {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 30px;
    white-space: pre-wrap;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.tb-btn.danger {
    background: var(--error);
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.tb-btn.danger:hover {
    background: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 71, 71, 0.3);
}

/* ── Emoji Modal ───────────────────────────────── */
.emoji-modal-content {
    max-width: 350px;
    padding: 20px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    margin-bottom: 0;
    font-size: 1.25rem;
}

.close-modal-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.close-modal-btn:hover {
    color: var(--text-white);
    transform: scale(1.1);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
}

.emoji-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    font-size: 1.8rem;
    padding: 10px 0;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
}

.emoji-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px) scale(1.1);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}