/* Git Rebase Visualizer — Dark Git Aesthetics */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-glass: rgba(22, 27, 34, 0.85);
    --border: #30363d;
    --border-subtle: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-orange: #d29922;
    --accent-red: #f85149;
    --accent-purple: #bc8cff;
    --accent-cyan: #39d4cf;
    --accent-pink: #ff7eb3;
    --branch-main: #58a6ff;
    --branch-feature: #3fb950;
    --branch-hotfix: #f85149;
    --branch-dev: #bc8cff;
    --commit-radius: 12px;
    --ui-radius: 8px;
    --glass-blur: blur(12px);
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── Header ─── */
header {
    background: var(--bg-glass);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

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

.header-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ─── Layout ─── */
.app-layout {
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    height: calc(100vh - 57px);
    overflow: hidden;
}

.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.main-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.right-panel {
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ─── Sidebar Sections ─── */
.sidebar-section {
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--ui-radius);
    border: 1px solid var(--border);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-glass);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.btn-primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #0d1117;
}

.btn-primary:hover {
    background: #79b8ff;
    color: #0d1117;
    border-color: #79b8ff;
}

.btn-danger {
    background: transparent;
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.btn-danger:hover {
    background: var(--accent-red);
    color: white;
}

.btn-success {
    background: transparent;
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.btn-success:hover {
    background: var(--accent-green);
    color: #0d1117;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 11px;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    padding: 6px;
    width: 30px;
    height: 30px;
    justify-content: center;
}

.btn-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ─── Op Buttons (large colored controls) ─── */
.op-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.op-btn {
    padding: 10px 8px;
    border-radius: var(--ui-radius);
    border: 1px solid transparent;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.op-btn .op-icon {
    font-size: 18px;
}

.op-btn .op-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.op-btn-rebase {
    background: rgba(88, 166, 255, 0.12);
    border-color: rgba(88, 166, 255, 0.3);
    color: var(--accent-blue);
}

.op-btn-rebase:hover,
.op-btn-rebase.active {
    background: rgba(88, 166, 255, 0.25);
    border-color: var(--accent-blue);
}

.op-btn-merge {
    background: rgba(63, 185, 80, 0.12);
    border-color: rgba(63, 185, 80, 0.3);
    color: var(--accent-green);
}

.op-btn-merge:hover,
.op-btn-merge.active {
    background: rgba(63, 185, 80, 0.25);
    border-color: var(--accent-green);
}

.op-btn-cherry {
    background: rgba(188, 140, 255, 0.12);
    border-color: rgba(188, 140, 255, 0.3);
    color: var(--accent-purple);
}

.op-btn-cherry:hover,
.op-btn-cherry.active {
    background: rgba(188, 140, 255, 0.25);
    border-color: var(--accent-purple);
}

.op-btn-squash {
    background: rgba(210, 153, 34, 0.12);
    border-color: rgba(210, 153, 34, 0.3);
    color: var(--accent-orange);
}

.op-btn-squash:hover,
.op-btn-squash.active {
    background: rgba(210, 153, 34, 0.25);
    border-color: var(--accent-orange);
}

/* ─── Toolbar ─── */
.graph-toolbar {
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 2px;
}

.branch-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid;
}

.branch-badge:hover {
    opacity: 0.8;
    transform: scale(0.97);
}

.branch-badge.active {
    opacity: 1;
    box-shadow: 0 0 0 2px;
}

.branch-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

/* ─── SVG Graph Canvas ─── */
.graph-container {
    flex: 1;
    overflow: auto;
    position: relative;
    background:
        radial-gradient(circle at 20% 20%, rgba(88, 166, 255, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(63, 185, 80, 0.03) 0%, transparent 50%),
        var(--bg-primary);
}

#graph-svg {
    display: block;
    transition: var(--transition);
    cursor: default;
}

/* Commit circles */
.commit-circle {
    cursor: pointer;
    transition: all 0.25s ease;
}

.commit-circle:hover .commit-ring {
    r: 14;
}

.commit-circle.selected .commit-ring {
    stroke-width: 3;
    filter: drop-shadow(0 0 8px currentColor);
}

.commit-circle.dragging {
    opacity: 0.7;
}

.commit-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    fill: var(--text-secondary);
    pointer-events: none;
    user-select: none;
}

.commit-msg {
    font-family: 'Inter', monospace;
    font-size: 9.5px;
    fill: var(--text-muted);
    pointer-events: none;
}

.branch-line {
    stroke-width: 2.5;
    fill: none;
    stroke-linecap: round;
}

.branch-arrow {
    stroke-width: 2;
}

.branch-label-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
}

.merge-line {
    stroke-dasharray: 4, 3;
    stroke-width: 2;
    fill: none;
    opacity: 0.7;
}

.conflict-marker {
    fill: var(--accent-red);
    opacity: 0.3;
}

/* Drag target highlight */
.drop-zone-highlight {
    stroke-dasharray: 5, 4;
    stroke-width: 2;
    fill: none;
    animation: dash-animate 1s linear infinite;
}

@keyframes dash-animate {
    to {
        stroke-dashoffset: -9;
    }
}

/* Animated commit move */
@keyframes commit-fly {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.commit-animating {
    animation: commit-fly 0.5s ease;
}

/* ─── Rebase Planner Table ─── */
.planner-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.planner-table th {
    text-align: left;
    padding: 6px 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.planner-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.planner-table tr:last-child td {
    border-bottom: none;
}

.planner-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.planner-op-select {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
}

.planner-op-select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.planner-hash {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-orange);
    font-size: 11px;
}

/* ─── Right Panel ─── */
.panel-tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.panel-tab {
    flex: 1;
    padding: 10px 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: 'Inter', sans-serif;
}

.panel-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.panel-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

.panel-body {
    padding: 14px;
    flex: 1;
}

.panel-section {
    margin-bottom: 16px;
}

.panel-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* ─── Git Command Output ─── */
.git-output {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--ui-radius);
    padding: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
    color: var(--accent-green);
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre;
    min-height: 80px;
    position: relative;
}

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

.git-output .git-cmd {
    color: var(--accent-cyan);
}

.git-output .git-branch {
    color: var(--accent-blue);
}

.git-output .git-hash {
    color: var(--accent-orange);
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 4px;
    padding: 3px 7px;
    font-size: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.copy-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* ─── Branch Manager ─── */
.branch-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.branch-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--ui-radius);
    border: 1px solid var(--border-subtle);
    background: var(--bg-primary);
    cursor: pointer;
    transition: var(--transition);
}

.branch-item:hover {
    border-color: var(--border);
    background: var(--bg-tertiary);
}

.branch-item.current {
    border-color: rgba(88, 166, 255, 0.4);
    background: rgba(88, 166, 255, 0.05);
}

.branch-item-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.branch-item-name {
    flex: 1;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 500;
}

.branch-item-action {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
    border-radius: 4px;
    transition: var(--transition);
    line-height: 1;
}

.branch-item-action:hover {
    color: var(--accent-red);
    background: rgba(248, 81, 73, 0.1);
}

/* ─── Commit Detail Card ─── */
.commit-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--ui-radius);
    padding: 12px;
    font-size: 12px;
}

.commit-card-hash {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-orange);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.commit-card-msg {
    color: var(--text-primary);
    margin-bottom: 6px;
    font-size: 13px;
    line-height: 1.4;
}

.commit-card-meta {
    color: var(--text-muted);
    font-size: 11px;
}

/* ─── Comparison View ─── */
.compare-view {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    flex: 1;
    overflow: hidden;
}

.compare-view.visible {
    display: grid;
}

.compare-pane {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--border);
}

.compare-pane:last-child {
    border-right: none;
}

.compare-label {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
}

.compare-svg-wrap {
    flex: 1;
    overflow: auto;
}

/* ─── Forms / Inputs ─── */
.form-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.form-input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--ui-radius);
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

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

.form-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: block;
}

/* ─── Mode indicator ─── */
.mode-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid;
    transition: var(--transition);
}

.mode-indicator.mode-normal {
    color: var(--text-muted);
    border-color: var(--border);
    background: var(--bg-tertiary);
}

.mode-indicator.mode-rebase {
    color: var(--accent-blue);
    border-color: rgba(88, 166, 255, 0.4);
    background: rgba(88, 166, 255, 0.08);
}

.mode-indicator.mode-cherry {
    color: var(--accent-purple);
    border-color: rgba(188, 140, 255, 0.4);
    background: rgba(188, 140, 255, 0.08);
}

.mode-indicator.mode-squash {
    color: var(--accent-orange);
    border-color: rgba(210, 153, 34, 0.4);
    background: rgba(210, 153, 34, 0.08);
}

.mode-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse-dot 2s ease infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ─── Toast / Notification ─── */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--bg-glass);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--ui-radius);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-primary);
    animation: toast-in 0.3s ease;
    pointer-events: all;
    max-width: 300px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.toast-success {
    border-color: rgba(63, 185, 80, 0.5);
}

.toast.toast-error {
    border-color: rgba(248, 81, 73, 0.5);
}

.toast.toast-info {
    border-color: rgba(88, 166, 255, 0.5);
}

@keyframes toast-in {
    from {
        transform: translateX(30px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toast-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(30px);
        opacity: 0;
    }
}

/* ─── Conflict Indicators ─── */
.conflict-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    background: rgba(248, 81, 73, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

/* ─── Scrollbars ─── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ─── Selection ─── */
::selection {
    background: rgba(88, 166, 255, 0.3);
    color: var(--text-primary);
}

/* ─── Empty State ─── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 36px;
    opacity: 0.4;
}

.empty-state-text {
    font-size: 13px;
}

/* ─── Instruction Banner ─── */
.instruction {
    padding: 8px 14px;
    background: rgba(88, 166, 255, 0.08);
    border-bottom: 1px solid rgba(88, 166, 255, 0.2);
    font-size: 12px;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ─── Tag / HEAD pointer ─── */
.head-pointer-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 700;
    fill: var(--accent-cyan);
}

/* ─── Tabs (hidden panes) ─── */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: auto;
    }

    .sidebar,
    .right-panel {
        max-height: 280px;
    }
}