/* ═══════════════════════════════════════════════════════
   WBS Studio — Stylesheet
   ═══════════════════════════════════════════════════════ */

/* --- CSS VARIABLES --- */
:root {
    --bg-main: #0a0c10;
    --bg-panel: #12151c;
    --bg-panel-hover: #1a1e28;
    --bg-glass: rgba(18, 21, 28, 0.92);
    --bg-input: rgba(0,0,0,0.25);
    --border: #232838;
    --border-light: #2e3548;
    --border-focus: #6366f1;

    --text-primary: #eef0f6;
    --text-secondary: #8892a8;
    --text-muted: #586175;

    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-glass: rgba(99, 102, 241, 0.12);
    --accent-glow: rgba(99, 102, 241, 0.25);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;

    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 5px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.35);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.55);

    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ═══════════════════════════════════════════
   TOOLBAR
   ═══════════════════════════════════════════ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
    margin-right: 8px;
    user-select: none;
    letter-spacing: -0.3px;
}
.brand svg { color: var(--accent); }

.divider {
    width: 1px;
    height: 22px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}

.spacer { flex: 1; min-width: 0; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 12.5px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}
.btn:hover { background: var(--bg-panel-hover); border-color: var(--text-muted); }
.btn:active { transform: scale(0.97); }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-icon { padding: 6px 8px; }
.btn-icon svg { width: 16px; height: 16px; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-danger {
    color: var(--danger);
    border-color: transparent;
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
}

.btn-danger-solid {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}
.btn-danger-solid:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* --- Search Box --- */
.search-box {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    min-width: 180px;
    max-width: 240px;
    transition: border-color var(--transition-fast);
}
.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glass);
}
.search-box svg { color: var(--text-muted); flex-shrink: 0; }
.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 12.5px;
    outline: none;
    min-width: 0;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-clear {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}
.search-clear.visible { display: block; }

/* --- Mode Indicator --- */
.mode-indicator {
    font-size: 11px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 16px;
    background: var(--accent-glass);
    color: var(--accent);
    display: none;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    letter-spacing: 0.3px;
}
.mode-indicator.active {
    display: inline-flex;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* ═══════════════════════════════════════════
   MAIN AREA & CANVAS
   ═══════════════════════════════════════════ */
.main-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(16, 185, 129, 0.03) 0%, transparent 50%),
        var(--bg-main);
}

#network-canvas {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
    outline: none;
}

/* ═══════════════════════════════════════════
   MINIMAP
   ═══════════════════════════════════════════ */
.minimap {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    z-index: 40;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-md);
    transition: opacity var(--transition-normal);
}
.minimap.hidden { opacity: 0; pointer-events: none; }
.minimap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.minimap-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    display: flex;
}
.minimap-toggle:hover { color: var(--text-primary); }
#minimap-canvas {
    display: block;
    width: 200px;
    height: 140px;
}

/* ═══════════════════════════════════════════
   SIDE PANEL (Editor)
   ═══════════════════════════════════════════ */
.side-panel {
    position: absolute;
    right: 0; top: 0; bottom: 0;
    width: 360px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    box-shadow: -6px 0 20px rgba(0,0,0,0.35);
}
.side-panel.open { transform: translateX(0); }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.panel-title {
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close {
    width: 28px; height: 28px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}
.btn-close:hover { background: var(--border); color: var(--text-primary); }
.btn-close svg { width: 16px; height: 16px; }

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    line-height: 1.5;
}
.field-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glass);
}
.field-input:read-only { opacity: 0.5; cursor: not-allowed; }
textarea.field-input { resize: vertical; min-height: 60px; }

/* Color Picker */
.color-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--accent-glass);
}
.color-swatch svg { color: var(--text-muted); }

/* Connections Info */
.connections-info {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}
.connections-info .conn-tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--border);
    border-radius: 10px;
    font-size: 11px;
    margin: 2px 2px;
    cursor: pointer;
    transition: var(--transition-fast);
}
.connections-info .conn-tag:hover {
    background: var(--accent);
    color: white;
}

.panel-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    background: rgba(0,0,0,0.08);
}
.panel-footer .btn { flex: 1; }

.text-muted { color: var(--text-muted); }

/* ═══════════════════════════════════════════
   CONTEXT MENU
   ═══════════════════════════════════════════ */
.context-menu {
    position: fixed;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px;
    min-width: 200px;
    z-index: 200;
    display: none;
    box-shadow: var(--shadow-lg);
}

.ctx-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    font-size: 12.5px;
    font-weight: 500;
    font-family: var(--font-sans);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    text-align: left;
    transition: background var(--transition-fast);
}
.ctx-item:hover { background: var(--accent); color: white; }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: var(--danger); color: white; }
.ctx-item svg { width: 15px; height: 15px; flex-shrink: 0; }

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

/* ═══════════════════════════════════════════
   TOASTS
   ═══════════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: 56px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}

.toast {
    padding: 10px 20px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: auto;
}
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success { border-left: 3px solid var(--success); }
.toast.success svg { color: var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.error svg { color: var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }
.toast.info svg { color: var(--accent); }

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

/* ═══════════════════════════════════════════
   STATUS BAR
   ═══════════════════════════════════════════ */
.stats-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 7px 20px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.stat-item span {
    color: var(--text-primary);
    font-weight: 600;
    font-family: var(--font-mono);
    font-size: 11px;
    background: var(--border);
    padding: 1px 7px;
    border-radius: 10px;
}

.legend {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
}
.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 6px;
}

/* ═══════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.modal-overlay.open { display: flex; opacity: 1; }

.modal {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: scale(0.96);
    transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal.large { max-width: 800px; height: 80vh; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.modal-body.editor-body {
    padding: 0;
    display: flex;
    flex-direction: column;
}
.modal-body.editor-body textarea {
    flex: 1;
    width: 100%;
    min-height: 100%;
    background: #080a0e;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.65;
    padding: 20px;
    outline: none;
    resize: none;
}

.modal-input {
    width: 100%;
    padding: 10px 12px;
    margin-top: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color var(--transition-fast);
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glass); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,0.06);
}

/* --- Shortcuts Modal --- */
.shortcuts-body { padding: 16px 20px; }
.shortcut-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.shortcut-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.shortcut-row span {
    margin-left: auto;
    color: var(--text-secondary);
}
kbd {
    display: inline-block;
    padding: 2px 7px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-primary);
    line-height: 1.5;
}

/* ═══════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
