/* css/style.css v7.2 - Final Fixes */

/* --- 1. GLOBAL & FONTS --- */
@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;600;700&family=Share+Tech+Mono&display=swap');

:root {
    --primary: #00F0FF;       /* Cyber Blue */
    --accent: #FF003C;        /* Cyber Red */
    --bg-dark: #050508;       /* Deep Void */
    --glass: rgba(10, 15, 20, 0.65);
    --border: rgba(0, 240, 255, 0.3);
}

body, html {
    margin: 0; padding: 0; width: 100%; height: 100%;
    background-color: var(--bg-dark);
    font-family: 'Rajdhani', sans-serif;
    color: var(--primary);
    overflow: hidden;
}

/* --- 2. BACKGROUND LAYERS --- */
body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: 
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 100px 100px;
    opacity: 0.05;
    z-index: -1;
    pointer-events: none;
}

#background-iframe {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: 0; border: none;
    filter: brightness(0.3) blur(4px) grayscale(0.2);
    pointer-events: none;
    transition: filter 0.5s ease;
}

#graph-layer {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 1;
}

.ui-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10; pointer-events: none;
}

/* --- 3. MENU PANEL --- */
.menu-panel {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    left: 40px;
    width: 380px;
    height: 80vh;
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    padding: 0;
    pointer-events: auto;
    display: flex; flex-direction: column;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%);
}

.menu-header {
    padding: 20px;
    background: linear-gradient(90deg, rgba(0,240,255,0.1), transparent);
    border-bottom: 1px solid var(--border);
}

.menu-header h1 { margin: 0; font-size: 1.4rem; text-transform: uppercase; letter-spacing: 2px; color: #FFF; }
.menu-subtitle { font-family: 'Share Tech Mono', monospace; font-size: 0.8rem; color: var(--accent); opacity: 0.8; }

#tree-container {
    flex: 1; overflow-y: auto; padding: 20px;
    font-family: 'Share Tech Mono', monospace; font-size: 13px;
}
#tree-container::-webkit-scrollbar { width: 4px; }
#tree-container::-webkit-scrollbar-thumb { background: var(--primary); }

.tree-item { margin-bottom: 8px; display: flex; align-items: baseline; }
.ascii-art { color: #555; margin-right: 8px; }
.clickable-text { cursor: pointer; transition: all 0.3s; color: #889; position: relative; }
.clickable-text:hover { color: #FFF; text-shadow: 0 0 8px var(--primary); padding-left: 5px; }
.clickable-text.active { color: var(--primary); font-weight: bold; text-shadow: 0 0 10px var(--primary); }
.clickable-text.active::before { content: ">"; margin-right: 5px; color: var(--accent); }
.clickable-text.preview-mode { color: var(--accent); opacity: 0.7; }


/* --- 4. BRUTALIST INPUT (Target Input) --- */
.brutalist-input-wrapper {
    position: fixed;
    left: calc(50% - 250px); 
    top: 85%;
    width: 500px;
    pointer-events: auto;
    z-index: 60;
    background: rgba(5, 10, 15, 0.6);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.brutalist-header {
    background: var(--bg-dark);
    border-bottom: 1px solid var(--accent);
    color: var(--accent);
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    letter-spacing: 2px;
    padding: 5px 10px;
    text-align: center;
    cursor: grab;
    user-select: none;
    font-weight: bold;
}
.brutalist-header:active { cursor: grabbing; background: var(--accent); color: #000; }

#global-text-input {
    width: 100%;
    background: transparent;
    border: none;
    color: #FFF;
    font-family: 'Rajdhani', sans-serif;
    font-size: 2rem; font-weight: 600; letter-spacing: 4px;
    text-transform: uppercase; text-align: center; padding: 15px;
    outline: none; transition: all 0.3s;
}
#global-text-input:focus { background: rgba(0, 240, 255, 0.05); letter-spacing: 6px; text-shadow: 0 0 10px var(--primary); }


/* --- 5. CONTROL DECK (Right Module) --- */
.control-deck {
    position: fixed; 
    top: 100px; right: 40px; 
    width: 220px;
    background: rgba(10, 15, 20, 0.75);
    backdrop-filter: blur(12px);
    border: 1px solid var(--primary); 
    border-right: 4px solid var(--primary);
    padding: 20px; 
    pointer-events: auto; z-index: 50;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 20px 100%, 0 calc(100% - 20px));
}

.deck-header {
    color: #FFF; border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 10px; margin-bottom: 20px; font-weight: 700; letter-spacing: 1px;
    cursor: grab; user-select: none;
}
.deck-header:active { cursor: grabbing; } /* <--- ИСПРАВЛЕНО: добавлена скобка */

.export-group {
    margin-top: 20px;
    border-top: 1px dashed rgba(255,255,255,0.2);
    padding-top: 10px;
}
.export-group label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; color: var(--accent);
    display: block; margin-bottom: 5px;
    text-align: center; letter-spacing: 2px;
}
.export-buttons {
    display: flex;
    gap: 5px;
}

.btn-mini {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 5px 0;
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; cursor: pointer; transition: all 0.2s;
}
.btn-mini:hover {
    background: var(--primary); color: #000; box-shadow: 0 0 10px var(--primary);
}

.slider-group { margin-bottom: 20px; }
.slider-group label {
    display: flex; justify-content: space-between;
    font-family: 'Share Tech Mono', monospace; font-size: 10px; color: var(--primary); margin-bottom: 5px;
}

input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 4px; background: #333; border: 1px solid #555; }
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; height: 14px; width: 10px; background: var(--primary);
    margin-top: -6px; border: 1px solid #FFF; cursor: pointer;
}


/* --- 6. WINDOW (Floating Content) --- */
#window-container {
    position: absolute; 
    top: 50%; left: 50%; 
    transform: translate(-50%, -50%) scale(0.9);
    width: 800px; height: 500px;
    background: rgba(10, 15, 20, 0.85); 
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--primary);
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    z-index: 100; 
    display: none; flex-direction: column;
    animation: openWindow 0.3s forwards;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%);
    /* --- НОВЫЕ СВОЙСТВА ДЛЯ РЕСАЙЗА --- */
    resize: both; /* Разрешить изменение размера по обеим осям */
    overflow: hidden; /* Обязательно для работы resize */
    min-width: 300px; /* Минимальные размеры, чтобы не сломать верстку */
    min-height: 200px;
    /* ---------------------------------- */
}

/* Опционально: стилизация уголка ресайза под киберпанк (работает в Chrome/Edge) */
#window-container::-webkit-resizer {
    background-color: var(--accent);
    border: 2px solid var(--bg-dark);
    box-shadow: 0 0 5px var(--accent);
}

@keyframes openWindow { to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

.win-header {
    background: #0a0a0a; border-bottom: 1px solid var(--border);
    padding: 10px 20px; display: flex; justify-content: space-between; align-items: center;
    cursor: grab;
}
.win-title { font-family: 'Share Tech Mono'; color: var(--primary); }
.win-close { background: none; border: none; color: var(--accent); font-size: 20px; cursor: pointer; }

.win-content { flex: 1; display: flex; flex-direction: column; position: relative; }
.win-desc { background: transparent; padding: 15px; color: #ccc; font-size: 14px; line-height: 1.5; }
.win-iframe { flex: 1; border: none; width: 100%; }

/* D3 NODES */
rect { fill: rgba(0,0,0,0.8); stroke: #444; stroke-width: 1px; }
.node-root { stroke: var(--primary); stroke-width: 2px; }
.d3-label {
    fill: #00FFFF;
    font-family: 'Share Tech Mono', monospace; 
    font-size: 11px;
    text-anchor: middle; 
    dominant-baseline: middle; 
    pointer-events: none;
    text-shadow: 0 0 2px #000;
    opacity: 0.8;
}
rect.active-node { fill: var(--primary) !important; stroke: #FFF !important; }

/* --- FIXES & HIGHLIGHTS --- */

/* 1. Подсветка при наведении (Quick Look) - БЫЛО ПРОПУЩЕНО */
rect.preview-node {
    stroke: #FFF !important;        /* Белая обводка */
    stroke-width: 3px !important;   /* Толще */
    fill: var(--primary) !important; /* Цвет Cyber Blue */
    filter: drop-shadow(0 0 8px var(--primary)); /* Свечение */
    cursor: pointer;
}

/* 2. Подсветка при клике (Active) */
rect.active-node {
    stroke: #FFF !important;
    stroke-width: 4px !important;
    fill: var(--accent) !important; /* Красный цвет для выбранного */
    filter: drop-shadow(0 0 15px var(--accent));
}

/* Исправление для окна, чтобы оно плавно переходило в режим драга */
#window-container {
    /* ... существующие стили ... */
    /* Добавляем will-change для производительности */
    will-change: transform, top, left;
}