:root {
    --bg-main: #0a0f1d;
    --bg-panel: #161e31;
    --bg-terminal: #05070a;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --border-color: #1e293b;
    
    --term-text: #cbd5e1;
    --term-prompt: #4ade80;
    --term-error: #f43f5e;
    --term-warn: #fbbf24;

    --node-bg: #3b82f6;
    --node-border: #60a5fa;
    --node-text: #ffffff;
    --head-bg: #8b5cf6;
    --line-color: #334155;
    
    --shadow-glow: 0 0 15px rgba(59, 130, 246, 0.4);
    --shadow-head: 0 0 20px rgba(139, 92, 246, 0.6);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    letter-spacing: -0.01em;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-header {
    padding: 0.75rem 2rem;
    background-color: rgba(22, 30, 49, 0.8);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    z-index: 100;
}

.header-main {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#project-select {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#project-select:hover {
    border-color: var(--accent);
    background-color: #1c2641;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.app-header p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.main-content.horizontal { flex-direction: row; }
.main-content.vertical { flex-direction: column; }

.resizer {
    background-color: var(--border-color);
    position: relative;
    z-index: 50;
    transition: background-color 0.2s;
}

.resizer:hover {
    background-color: var(--accent);
}

.main-content.horizontal > .resizer { width: 4px; cursor: col-resize; height: 100%; }
.main-content.vertical > .resizer { height: 4px; cursor: row-resize; width: 100%; }

.visualization-panel {
    flex: 1;
    min-width: 200px;
    min-height: 200px;
    position: relative;
    overflow: hidden;
    background-color: var(--bg-main);
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    cursor: grab;
}

.visualization-panel.dragging { cursor: grabbing; }

.canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 3000px;
    height: 3000px;
    padding: 4rem;
    transform-origin: 0 0;
}

.git-graph-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.nodes-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.commit-node {
    position: absolute;
    width: 28px;
    height: 28px;
    background-color: var(--node-bg);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fira Code', monospace;
    font-size: 0.6rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    transform: translate(-50%, -50%);
    box-shadow: var(--shadow-glow);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    user-select: none;
}

.commit-node:hover {
    transform: translate(-50%, -50%) scale(1.4);
    color: #fff;
    border-color: #fff;
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.6);
}

.head-tag {
    position: absolute;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    transform: translate(-50%, -180%);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
    pointer-events: none;
    z-index: 20;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.head-tag::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid #ef4444;
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(16, 185, 129, 0.9);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    z-index: 1000;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.commit-node.head-node {
    width: 30px;
    height: 30px;
    background-color: var(--head-bg);
    box-shadow: var(--shadow-head);
    border: 3px solid rgba(255, 255, 255, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(139, 92, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

.commit-label {
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    background: rgba(22, 30, 49, 0.8);
    backdrop-filter: blur(8px);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0.95;
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.5);
    z-index: 5;
}

.commit-msg {
    color: var(--text-primary);
    font-weight: 500;
}

.branch-tags {
    display: flex;
    gap: 6px;
}

.branch-tag {
    background-color: rgba(59, 130, 246, 0.15);
    padding: 2px 10px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #60a5fa;
    border: 1px solid rgba(96, 165, 250, 0.3);
}

.branch-tag.head {
    background-color: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border-color: rgba(167, 139, 250, 0.3);
}

.terminal-panel {
    flex: 1;
    min-width: 300px;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-terminal);
}

.main-content.horizontal > .terminal-panel { border-left: 1px solid var(--border-color); }
.main-content.vertical > .terminal-panel { border-top: 1px solid var(--border-color); }

.terminal-header {
    height: 44px;
    background-color: var(--bg-panel);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.terminal-dots { display: flex; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background-color: #ff5f56; }
.dot.yellow { background-color: #ffbd2e; }
.dot.green { background-color: #27c93f; }

.terminal-title {
    flex: 1;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.terminal-actions { margin-left: auto; }

#toggle-layout {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    transition: all 0.2s;
}

#toggle-layout:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.1);
}

.terminal-body {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    color: var(--term-text);
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

.terminal-output { display: flex; flex-direction: column; gap: 6px; margin-bottom: 1rem; }
.terminal-output .error { color: var(--term-error); }
.terminal-output .success { color: var(--term-prompt); }
.terminal-output .warn { color: var(--term-warn); }
.terminal-output .info { color: var(--accent-hover); }

.terminal-input-line { display: flex; align-items: center; gap: 0.75rem; }
.prompt { color: var(--term-prompt); white-space: nowrap; font-weight: 500; }
#terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--term-text);
    font-family: inherit;
    font-size: inherit;
    outline: none;
}

.main-content.resizing { user-select: none; }
.main-content.resizing .visualization-panel,
.main-content.resizing .terminal-panel { pointer-events: none; }
