/* ── Self-hosted Outfit font ────────────────────────────────────────────── */
/* latin-ext */
@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('../fonts/outfit-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('../fonts/outfit-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
    --bg:             #0C0D14;
    --canvas-bg:      #0F1019;
    --toolbar-bg:     rgba(13, 14, 22, 0.96);
    --toolbar-border: rgba(255, 255, 255, 0.07);
    --surface:        #191B28;
    --surface-hover:  #1F2133;
    --text:           #DEE1F0;
    --text-muted:     #4B5070;
    --accent:         #818CF8;
    --danger:         #EF4444;
    --toolbar-h:      52px;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    font-family: 'Outfit', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

#app { width: 100%; height: 100%; }

/* ── Boot loader ────────────────────────────────────────────────────────── */
.boot-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100vh;
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.3px;
    animation: fadeIn 0.4s ease;
}

/* ── App shell ──────────────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    outline: none;
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

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

/* ── Toolbar ────────────────────────────────────────────────────────────── */
.toolbar {
    height: var(--toolbar-h);
    background: var(--toolbar-bg);
    border-bottom: 1px solid var(--toolbar-border);
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 10px;
    flex-shrink: 0;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 100;
    user-select: none;
}

.toolbar-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.4px;
    color: var(--text);
    flex-shrink: 0;
    position: relative;
}

.about-popup {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    background: #1A1C28;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    z-index: 200;
    white-space: nowrap;
}

.about-version {
    font-size: 12px;
    font-weight: 400;
    color: rgba(255,255,255,0.5);
}

.toolbar-sep {
    width: 1px;
    height: 22px;
    background: var(--toolbar-border);
    flex-shrink: 0;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.tb-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    flex-shrink: 0;
}

.tb-btn:hover {
    background: var(--surface-hover);
    border-color: var(--toolbar-border);
}

.tb-btn:active {
    background: var(--surface);
    transform: scale(0.97);
}

.tb-btn.icon-btn {
    padding: 0 8px;
    min-width: 30px;
    justify-content: center;
}

.zoom-label {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 34px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    padding: 0 2px;
}

/* ── Color palette ──────────────────────────────────────────────────────── */
.color-palette {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.color-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.15s;
    flex-shrink: 0;
}

.color-dot:hover {
    transform: scale(1.25);
}

.color-dot.active {
    transform: scale(1.15);
}

/* ── Toolbar hint ───────────────────────────────────────────────────────── */
.toolbar-hint {
    margin-left: auto;
    font-size: 11.5px;
    color: var(--text-muted);
    letter-spacing: 0.1px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Canvas ─────────────────────────────────────────────────────────────── */
.canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: var(--canvas-bg);
    /* Dot grid is set dynamically via inline style */
    background-image: radial-gradient(circle, #1E2136 1.5px, transparent 1.5px);
    transition: background-size 0s, background-position 0s;
}

.mindmap-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: default;
    user-select: none;
}

.mindmap-svg.grabbing {
    cursor: grabbing;
}

/* ── SVG node styles ────────────────────────────────────────────────────── */
.node-group {
    cursor: pointer;
}

.node-group .node-body {
    transition: fill 0.15s, stroke 0.15s;
}

.node-group:hover .node-body {
    filter: brightness(1.12);
}

.action-btn {
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.15s;
}

.action-btn:hover {
    opacity: 1;
}

/* ── Edit overlay ───────────────────────────────────────────────────────── */
.edit-overlay {
    position: absolute;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all;
}

.node-edit-input {
    width: 100%;
    height: 100%;
    background: rgba(15, 16, 25, 0.92);
    border: 1.5px solid;
    outline: none;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    text-align: center;
    padding: 0 12px;
    caret-color: var(--accent);
    backdrop-filter: blur(8px);
}

/* ── Unsaved-changes modal ──────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-dialog {
    background: #13141F;
    border: 1px solid var(--toolbar-border);
    border-radius: 12px;
    padding: 24px;
    width: 340px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.modal-body {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

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

.modal-btn {
    height: 32px;
    padding: 0 14px;
    border-radius: 7px;
    border: none;
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.12s;
}

.modal-btn:hover { opacity: 0.85; }

.modal-btn--cancel {
    background: var(--surface-hover);
    color: var(--text);
}

.modal-btn--danger {
    background: var(--danger);
    color: #fff;
}

/* ── Dirty indicator ────────────────────────────────────────────────────── */
.dirty-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #F59E0B;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
    animation: pulse-dot 2s ease-in-out infinite;
    visibility: hidden;
}
.dirty-dot.visible {
    visibility: visible;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

/* ── Split save button ──────────────────────────────────────────────────── */
.tb-split-btn {
    display: inline-flex;
    align-items: center;
    border-radius: 7px;
    border: 1px solid transparent;
    overflow: hidden;
    transition: border-color 0.12s;
    flex-shrink: 0;
}

.tb-split-btn:hover {
    border-color: var(--toolbar-border);
}

.tb-split-btn .tb-btn {
    border-radius: 0;
    border: none;
}

.tb-split-main {
    padding-right: 8px;
}

.tb-split-arrow {
    padding: 0 6px;
    border-left: 1px solid var(--toolbar-border) !important;
    min-width: unset;
}

/* ── Recent files dropdown ──────────────────────────────────────────────── */
.tb-open-wrap {
    position: relative;
    flex-shrink: 0;
}

.recent-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: #13141F;
    border: 1px solid var(--toolbar-border);
    border-radius: 10px;
    padding: 5px;
    min-width: 230px;
    max-width: 320px;
    z-index: 500;
    box-shadow: 0 12px 32px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.recent-browse-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 32px;
    padding: 0 10px;
    background: transparent;
    border: none;
    border-radius: 7px;
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
}

.recent-browse-btn:hover {
    background: var(--surface-hover);
}

.recent-divider {
    height: 1px;
    background: var(--toolbar-border);
    margin: 3px 0;
    flex-shrink: 0;
}

.recent-empty {
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 7px;
    padding: 0 4px 0 10px;
    height: 34px;
    transition: background 0.12s;
}

.recent-item:hover {
    background: var(--surface-hover);
}

.recent-item-name {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0;
}

.recent-item-date {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.recent-item-remove {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.12s, background 0.12s;
    padding: 0;
}

.recent-item-remove:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.12);
}

/* ── Context menu ───────────────────────────────────────────────────────── */
.ctx-menu {
    position: absolute;
    z-index: 100;
    background: #1A1C28;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 4px;
    min-width: 140px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.ctx-item {
    display: block;
    width: 100%;
    padding: 7px 12px;
    text-align: left;
    background: none;
    border: none;
    border-radius: 5px;
    color: rgba(255,255,255,0.85);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    cursor: pointer;
}

.ctx-item:hover {
    background: rgba(255,255,255,0.08);
}

.ctx-item--danger { color: #EF4444; }
.ctx-item--danger:hover { background: rgba(239,68,68,0.12); }

.ctx-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 3px 0;
}

/* ── Link badge (node URL indicator) ───────────────────────────────────── */
.link-badge {
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.15s;
}

.link-badge:hover {
    opacity: 1;
}

/* ── Task badge (status indicator) ─────────────────────────────────────── */
.task-badge {
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.15s;
}

.task-badge:hover {
    opacity: 1;
}

@keyframes task-pulse {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 0.5; }
}

.task-in-progress {
    animation: task-pulse 2s ease-in-out infinite;
}

/* ── Link dialog input ──────────────────────────────────────────────────── */
.link-url-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--toolbar-border);
    border-radius: 6px;
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    padding: 7px 10px;
    outline: none;
    transition: border-color 0.15s;
}

.link-url-input:focus {
    border-color: var(--accent);
}

.modal-btn--primary {
    background: var(--accent);
    color: #fff;
}

/* ── Blazor error UI ────────────────────────────────────────────────────── */
#blazor-error-ui {
    background: #2a1a1a;
    bottom: 0; right: 0;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.5);
    color: #e0c4c4;
    display: none;
    font-size: 13px;
    padding: 10px 16px;
    position: fixed;
    z-index: 1000;
    border-top: 1px solid #5a2020;
    font-family: 'Outfit', sans-serif;
}

#blazor-error-ui .dismiss { cursor: pointer; float: right; margin-left: 12px; }

/* ── Guide panel ───────────────────────────────────────────────────────── */
.guide-panel {
    position: fixed;
    top: var(--toolbar-h);
    right: 0;
    bottom: 0;
    width: 360px;
    background: #13141F;
    border-left: 1px solid var(--toolbar-border);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
    z-index: 500;
    display: flex;
    flex-direction: column;
    animation: guide-slide-in 0.2s ease-out;
}

@keyframes guide-slide-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.guide-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--toolbar-border);
    flex-shrink: 0;
}

.guide-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    flex-shrink: 0;
}

.guide-tabs {
    display: flex;
    gap: 2px;
    background: var(--surface);
    border-radius: 7px;
    padding: 2px;
}

.guide-tab {
    height: 26px;
    padding: 0 12px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.guide-tab:hover { color: var(--text); }
.guide-tab.active { background: var(--accent); color: #fff; }

.guide-close {
    margin-left: auto;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}

.guide-close:hover { background: var(--surface-hover); color: var(--text); }

.guide-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
}

.guide-body::-webkit-scrollbar       { width: 6px; }
.guide-body::-webkit-scrollbar-track  { background: transparent; }
.guide-body::-webkit-scrollbar-thumb  { background: var(--surface-hover); border-radius: 3px; }

.guide-section { margin-bottom: 20px; }

.guide-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
}

.guide-item {
    margin-bottom: 6px;
    color: rgba(222, 225, 240, 0.78);
    font-size: 13px;
}

kbd {
    display: inline-block;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: var(--surface);
    border: 1px solid var(--toolbar-border);
    border-radius: 4px;
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    line-height: 20px;
    white-space: nowrap;
}

.guide-shortcuts { width: 100%; border-collapse: collapse; }
.guide-shortcuts td { padding: 5px 0; font-size: 13px; vertical-align: middle; }
.guide-shortcuts td:first-child { width: 120px; padding-right: 10px; white-space: nowrap; }
.guide-shortcuts td:last-child { color: rgba(222, 225, 240, 0.7); }
.guide-shortcuts tr + tr td { border-top: 1px solid rgba(255, 255, 255, 0.04); }

.collapse-badge { cursor: pointer; opacity: 0.85; transition: opacity 0.15s; }
.collapse-badge:hover { opacity: 1; }

.guide-toggle-btn.active {
    background: var(--surface-hover);
    border-color: var(--toolbar-border);
    color: var(--accent);
}
