:root {
    --primary: #f59e0b;
    --primary-dark: #d97706;
    --primary-light: rgba(245, 158, 11, 0.15);
    --bg-dark: #090d16;
    --card-bg: rgba(17, 24, 39, 0.75);
    --toolbar-bg: rgba(9, 13, 22, 0.95);
    --border: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.25);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Outfit', 'Tajawal', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; 
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.5rem;
    background: var(--toolbar-bg);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #10b981, #3b82f6);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary);
}

.lang-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
}

.lang-select option {
    background: #111827;
    color: #fff;
}

/* Main Workspace */
.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Toolbar Panel */
.toolbar-panel {
    width: 280px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1.5rem;
    overflow-y: auto;
    z-index: 10;
}

[dir="rtl"] .toolbar-panel {
    border-right: 1px solid var(--border);
    border-left: none;
}
[dir="ltr"] .toolbar-panel {
    border-left: 1px solid var(--border);
    border-right: none;
}

.tool-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tool-section-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.tool-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    transition: all 0.2s;
    font-family: inherit;
}

.tool-btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: #fff;
}

.tool-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-hover);
}

.tool-icon {
    font-size: 1.2rem;
}

/* Full Width Button */
.full-width-btn {
    grid-column: span 2;
    flex-direction: row;
    justify-content: center;
}

/* Select */
.prop-select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #fff;
    padding: 0.5rem;
    outline: none;
    font-family: inherit;
}
.prop-select option {
    background: #111827;
}

/* Action Buttons */
.action-btn {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #10b981, #3b82f6);
    color: #fff;
}
.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Canvas Area */
.canvas-container-wrapper {
    flex: 1;
    position: relative;
    background-color: #f8f9fa; /* Light canvas background like mindmeister */
    background-image: radial-gradient(#d1d5db 1px, transparent 1px);
    background-size: 20px 20px;
}

#network-canvas {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

/* Custom Vis.js Manipulation UI hiding */
div.vis-network div.vis-manipulation {
    display: none !important; 
}

/* Node Editor Popup */
.node-editor-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.node-editor-overlay.active {
    display: flex;
}

.node-editor-modal {
    background: var(--toolbar-bg);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: 14px;
    width: 100%;
    max-width: min(92vw, 360px);
    box-sizing: border-box;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.form-input {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    color: #fff;
    padding: 0.75rem;
    border-radius: 6px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}
.form-input:focus {
    border-color: var(--primary);
}
.form-color {
    width: 100%;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}
.modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

@media (max-width: 768px) {
    .workspace {
        flex-direction: column-reverse;
        height: calc(100dvh - 60px);
    }
    .toolbar-panel {
        width: 100% !important;
        max-height: 180px;
        flex-direction: row;
        flex-wrap: wrap;
        overflow-x: auto;
        overflow-y: auto;
        padding: 0.65rem;
        gap: 0.75rem;
        border-top: 1px solid var(--border);
        border-right: none !important;
        border-left: none !important;
    }
    .tool-section {
        flex-direction: row;
        align-items: center;
        gap: 0.4rem;
    }
    .tool-section-title {
        display: none;
    }
    .tool-grid {
        display: flex;
        flex-wrap: nowrap;
        gap: 0.35rem;
    }
    .tool-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        flex-shrink: 0;
    }
    #network-canvas {
        flex: 1;
        width: 100vw;
    }
}
