/**
 * Shidoku CSP Solver Styles
 *
 * Visualization-specific styles only. Common styles are in visualizations.css.
 * Colors reference shared --viz-* variables where applicable.
 */

/* ============================================
   Shidoku-Specific CSS Custom Properties
   ============================================ */
:root {
    /* Map to shared variables */
    --shidoku-bg: var(--viz-bg);
    --shidoku-border: var(--viz-border);
    --shidoku-cell-bg: var(--viz-bg);
    --shidoku-text: var(--viz-text);
    --shidoku-domain-text: var(--viz-text-muted);
    --shidoku-hover-bg: var(--viz-hover-bg);

    /* Shidoku-specific: box borders, cell states */
    --shidoku-box-border: #000000;
    --shidoku-fixed-bg: #e9ecef;
    --shidoku-fixed-text: #495057;
    --shidoku-assigned-bg: #d4edda;
    --shidoku-assigned-border: #28a745;
    --shidoku-examining-bg: #fff3cd;
    --shidoku-examining-border: #ffc107;
    --shidoku-trying-bg: #cce5ff;
    --shidoku-trying-border: #007bff;
    --shidoku-conflict-bg: #f8d7da;
    --shidoku-conflict-border: #dc3545;
    --shidoku-pruned-color: #dc3545;
}

[data-theme="gruvbox-dark"] {
    --shidoku-box-border: #ebdbb2;
    --shidoku-fixed-bg: #3c3836;
    --shidoku-fixed-text: #d5c4a1;
    --shidoku-assigned-bg: rgba(184, 187, 38, 0.3);
    --shidoku-assigned-border: #b8bb26;
    --shidoku-examining-bg: rgba(250, 189, 47, 0.3);
    --shidoku-examining-border: #fabd2f;
    --shidoku-trying-bg: rgba(131, 165, 152, 0.3);
    --shidoku-trying-border: #83a598;
    --shidoku-conflict-bg: rgba(251, 73, 52, 0.3);
    --shidoku-conflict-border: #fb4934;
    --shidoku-pruned-color: #fb4934;
}

/* Grid Container */
.shidoku-grid-wrapper {
    position: relative;
    display: inline-block;
    margin: 20px auto;
}

.shidoku-grid {
    display: inline-grid;
    grid-template-columns: repeat(4, 70px);
    grid-template-rows: repeat(4, 70px);
    gap: 2px;
    background-color: var(--shidoku-border);
    border: 3px solid var(--shidoku-box-border);
    padding: 2px;
    position: relative;
}

/* SVG overlay for arc lines */
.arc-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.arc-line {
    stroke: var(--shidoku-arc-line, #ff6b35);
    stroke-width: 3;
    stroke-linecap: round;
    fill: none;
    opacity: 0.9;
}

.arc-line-glow {
    stroke: var(--shidoku-arc-glow, #ff6b35);
    stroke-width: 8;
    stroke-linecap: round;
    fill: none;
    opacity: 0.3;
    filter: blur(2px);
}

.arc-arrow {
    fill: var(--shidoku-arc-line, #ff6b35);
    opacity: 0.9;
}

[data-theme="gruvbox-dark"] {
    --shidoku-arc-line: #fe8019;
    --shidoku-arc-glow: #fe8019;
}

/* 2x2 Box borders */
.shidoku-grid::after {
    content: '';
    position: absolute;
    pointer-events: none;
}

/* Individual Cells */
.shidoku-cell {
    width: 70px;
    height: 70px;
    background-color: var(--shidoku-cell-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    color: var(--shidoku-text);
    cursor: pointer;
    position: relative;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    box-sizing: border-box;
}

.shidoku-cell:hover:not(.fixed):not(.solving) {
    background-color: var(--shidoku-hover-bg);
}

/* Box borders - thicker borders between 2x2 boxes */
.shidoku-cell:nth-child(2),
.shidoku-cell:nth-child(6),
.shidoku-cell:nth-child(10),
.shidoku-cell:nth-child(14) {
    border-right: 3px solid var(--shidoku-box-border);
}

.shidoku-cell:nth-child(5),
.shidoku-cell:nth-child(6),
.shidoku-cell:nth-child(7),
.shidoku-cell:nth-child(8) {
    border-bottom: 3px solid var(--shidoku-box-border);
}

/* Cell States */
.shidoku-cell.fixed {
    background-color: var(--shidoku-fixed-bg);
    color: var(--shidoku-fixed-text);
    cursor: default;
}

.shidoku-cell.assigned {
    background-color: var(--shidoku-assigned-bg);
    border: 2px solid var(--shidoku-assigned-border);
}

.shidoku-cell.examining {
    background-color: var(--shidoku-examining-bg);
    border: 2px solid var(--shidoku-examining-border);
    animation: pulse 0.5s ease-in-out;
}

.shidoku-cell.trying-cell {
    background-color: var(--shidoku-trying-bg);
    border: 2px solid var(--shidoku-trying-border);
}

.shidoku-cell.provisional-cell {
    background-color: var(--shidoku-examining-bg);
    border: 2px solid var(--shidoku-examining-border);
}

.shidoku-cell.conflict-cell {
    background-color: var(--shidoku-conflict-bg);
    border: 2px solid var(--shidoku-conflict-border);
    animation: conflict-pulse 0.6s ease-out;
}

@keyframes conflict-pulse {
    0% {
        box-shadow: 0 0 0 0 var(--shidoku-conflict-border);
    }
    50% {
        box-shadow: 0 0 20px 8px var(--shidoku-conflict-border);
    }
    100% {
        box-shadow: 0 0 0 0 var(--shidoku-conflict-border);
    }
}

/* Conflict value in mini-grid - red highlight with pulse */
.domain-value.conflict-value {
    background-color: var(--shidoku-conflict-bg);
    border: 2px solid var(--shidoku-conflict-border);
    font-size: 20px;
    font-weight: bold;
    color: var(--shidoku-conflict-border);
    border-radius: 4px;
    transform: scale(1.3);
    z-index: 1;
    animation: conflict-value-pulse 0.6s ease-out;
}

/* Conflict value in fixed cells - red highlight with pulse */
.assigned-value.conflict-value {
    color: var(--shidoku-conflict-border);
    animation: conflict-value-pulse 0.6s ease-out;
}

@keyframes conflict-value-pulse {
    0% {
        box-shadow: 0 0 0 0 var(--shidoku-conflict-border);
    }
    50% {
        box-shadow: 0 0 12px 4px var(--shidoku-conflict-border);
    }
    100% {
        box-shadow: 0 0 0 0 var(--shidoku-conflict-border);
    }
}

.shidoku-cell.conflict {
    background-color: var(--shidoku-conflict-bg);
    border: 2px solid var(--shidoku-conflict-border);
}

/* Arc source cell (Xi in arc check) */
.shidoku-cell.arc-source {
    background-color: var(--shidoku-arc-check-bg, rgba(255, 107, 53, 0.2));
    border: 3px solid var(--shidoku-arc-line, #ff6b35);
    box-shadow: 0 0 12px var(--shidoku-arc-line, #ff6b35);
}

/* Arc target cell (Xj in arc check) */
.shidoku-cell.arc-target {
    background-color: var(--shidoku-support-bg, rgba(40, 167, 69, 0.2));
    border: 3px solid var(--shidoku-support-border, #28a745);
    box-shadow: 0 0 12px var(--shidoku-support-border, #28a745);
}

.shidoku-cell.solving {
    cursor: default;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Domain mini-grid display */
.domain-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    width: 100%;
    height: 100%;
    padding: 4px;
    box-sizing: border-box;
}

.domain-value {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: normal;
    color: var(--shidoku-domain-text);
    border-radius: 3px;
    transition: all 0.15s ease;
    cursor: pointer;
}

/* Hover state for clickable domain values */
.shidoku-cell:not(.fixed):not(.solving) .domain-value:not(.pruned):not(.user-selected):hover {
    background-color: var(--shidoku-hover-bg);
    color: var(--shidoku-text);
    transform: scale(1.15);
    font-weight: bold;
}

.domain-value.pruned {
    color: var(--shidoku-pruned-color);
    text-decoration: line-through;
    opacity: 0.6;
}

.domain-value.highlight {
    color: var(--shidoku-examining-border);
    font-weight: bold;
}

/* User-selected value in custom puzzle input - blue highlight */
.domain-value.user-selected {
    background-color: var(--shidoku-trying-bg);
    border: 2px solid var(--shidoku-trying-border);
    font-size: 20px;
    font-weight: bold;
    color: var(--shidoku-trying-border);
    border-radius: 4px;
    transform: scale(1.3);
    z-index: 1;
}

/* Value currently being tried - blue highlight, enlarged toward center, with pulse */
.domain-value.trying {
    background-color: var(--shidoku-trying-bg);
    border: 2px solid var(--shidoku-trying-border);
    font-size: 20px;
    font-weight: bold;
    color: var(--shidoku-trying-border);
    border-radius: 4px;
    transform: scale(1.3);
    z-index: 1;
    animation: trying-pulse 0.6s ease-in-out infinite;
}

@keyframes trying-pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--shidoku-trying-border); }
    50% { box-shadow: 0 0 8px 2px var(--shidoku-trying-border); }
}

/* Provisional assignment - yellow highlight, enlarged (not the current try) */
.domain-value.provisional {
    background-color: var(--shidoku-examining-bg);
    border: 2px solid var(--shidoku-examining-border);
    font-size: 20px;
    font-weight: bold;
    color: var(--shidoku-examining-border);
    border-radius: 4px;
    transform: scale(1.3);
    z-index: 1;
}

/* Other values shrink when one is being tried */
.domain-value.shrunk {
    font-size: 10px;
    opacity: 0.6;
}

/* Value that was tried and failed (backtracked) */
.domain-value.failed-attempt {
    color: var(--shidoku-conflict-border);
    text-decoration: line-through;
    opacity: 0.5;
    font-size: 10px;
}

/* Confirmed assignment in solved puzzle - green highlight, enlarged */
.domain-value.assigned-mini {
    background-color: var(--shidoku-assigned-bg);
    border: 2px solid var(--shidoku-assigned-border);
    font-size: 20px;
    font-weight: bold;
    color: var(--shidoku-assigned-border);
    border-radius: 4px;
    transform: scale(1.3);
    z-index: 1;
}

/* Value being checked in arc consistency */
.domain-value.checking {
    background-color: var(--shidoku-arc-check-bg, rgba(255, 107, 53, 0.3));
    border: 2px solid var(--shidoku-arc-line, #ff6b35);
    color: var(--shidoku-arc-line, #ff6b35);
    font-weight: bold;
    animation: value-pulse 0.6s ease-in-out infinite;
    border-radius: 4px;
    margin: 1px;
}

/* Value providing support in peer cell */
.domain-value.support {
    background-color: var(--shidoku-support-bg, rgba(40, 167, 69, 0.3));
    border: 2px solid var(--shidoku-support-border, #28a745);
    color: var(--shidoku-support-border, #28a745);
    font-weight: bold;
    border-radius: 4px;
    margin: 1px;
}

/* Value with no support (about to be pruned) */
.domain-value.no-support {
    background-color: var(--shidoku-conflict-bg);
    border: 2px solid var(--shidoku-conflict-border);
    color: var(--shidoku-conflict-border);
    font-weight: bold;
    border-radius: 4px;
    margin: 1px;
}

@keyframes value-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 var(--shidoku-arc-line, #ff6b35);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 8px 2px var(--shidoku-arc-line, #ff6b35);
    }
}

[data-theme="gruvbox-dark"] {
    --shidoku-arc-check-bg: rgba(254, 128, 25, 0.3);
    --shidoku-support-bg: rgba(184, 187, 38, 0.3);
    --shidoku-support-border: #b8bb26;
}

/* Assigned value display (single large number) */
.assigned-value {
    font-size: 32px;
    font-weight: bold;
}

/* Grid Legend */
.grid-legend {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    font-size: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border: 1px solid var(--shidoku-border);
    border-radius: 2px;
}

.legend-fixed {
    background-color: var(--shidoku-fixed-bg);
}

.legend-assigned {
    background-color: var(--shidoku-assigned-bg);
    border-color: var(--shidoku-assigned-border);
}

.legend-examining {
    background-color: var(--shidoku-examining-bg);
    border-color: var(--shidoku-examining-border);
}

.legend-conflict {
    background-color: var(--shidoku-conflict-bg);
    border-color: var(--shidoku-conflict-border);
}

.legend-arc-source {
    background-color: var(--shidoku-arc-check-bg, rgba(255, 107, 53, 0.3));
    border: 2px solid var(--shidoku-arc-line, #ff6b35);
}

.legend-arc-target {
    background-color: var(--shidoku-support-bg, rgba(40, 167, 69, 0.3));
    border: 2px solid var(--shidoku-support-border, #28a745);
}

/* Speed Control */
.speed-control {
    margin-top: 15px;
}

.speed-control input[type="range"] {
    width: 100%;
    margin: 10px 0 5px 0;
}

.speed-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--shidoku-domain-text);
}

/* Metrics Table - uses shared .metrics-table from visualizations.css */
.metric-value {
    font-family: var(--viz-mono-font);
    font-weight: bold;
    min-width: 60px;
}

/* Sample Puzzles */
.sample-puzzles {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.sample-puzzles-inline {
    margin-top: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.sample-puzzles-inline label {
    margin: 0;
    font-size: 12px;
    color: var(--shidoku-domain-text);
}

/* Info Panel Tabs - uses shared .info-panel-tabs from visualizations.css */
.info-panel-tabs .btn.active {
    background-color: var(--shidoku-examining-bg);
    border-color: var(--shidoku-examining-border);
    color: var(--shidoku-text);
}

[data-theme="gruvbox-dark"] .info-panel-tabs .btn.active {
    background-color: rgba(250, 189, 47, 0.3);
    border-color: #fabd2f;
    color: #ebdbb2;
}

/* Puzzle Header Tabs (Load Puzzle buttons) */
.puzzle-header-tabs {
    display: flex;
    width: 100%;
}

.puzzle-header-tabs .btn {
    flex: 1;
    border-radius: 0;
}

.puzzle-header-tabs .btn:hover {
    background-color: var(--shidoku-examining-bg);
    border-color: var(--shidoku-examining-border);
}

.puzzle-header-tabs .btn.active {
    background-color: var(--shidoku-examining-bg);
    border-color: var(--shidoku-examining-border);
    color: var(--shidoku-text);
}

[data-theme="gruvbox-dark"] .puzzle-header-tabs .btn:hover {
    background-color: rgba(250, 189, 47, 0.3);
    border-color: #fabd2f;
}

[data-theme="gruvbox-dark"] .puzzle-header-tabs .btn.active {
    background-color: rgba(250, 189, 47, 0.3);
    border-color: #fabd2f;
    color: #ebdbb2;
}

/* Info panel body - uses shared .info-panel-body from visualizations.css */
.info-panel-body {
    min-height: 450px;
}

/* About Tab */
#tab-about h4 {
    margin-top: 15px;
    margin-bottom: 10px;
}

#tab-about h4:first-child {
    margin-top: 0;
}

.algorithm-list {
    padding-left: 20px;
    margin-bottom: 15px;
}

.algorithm-list li {
    margin-bottom: 5px;
}

/* Tree Tab - adjust container height */
#tab-tree .search-tree-container {
    height: 360px;
}

.tree-legend-bar {
    display: flex;
    gap: 12px;
    font-size: 11px;
}

/* Log Tab */
.log-header {
    margin-bottom: 10px;
    min-height: 24px;
}

#tab-log .execution-log {
    max-height: 390px;
}

/* Compact Panel styling for bottom row */
.compact-panel {
    padding: 10px 15px !important;
}

.compact-panel .checkbox,
.compact-panel .radio {
    margin-top: 5px;
    margin-bottom: 5px;
}

.compact-panel .checkbox label,
.compact-panel .radio label {
    font-size: 13px;
}

/* Disabled checkbox styling (for always-on backtracking) */
.disabled-checkbox label {
    opacity: 0.7;
    cursor: default;
}

.disabled-checkbox input[disabled] {
    cursor: default;
}

/* Playback buttons - extends shared .playback-controls from visualizations.css */
.playback-buttons {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.playback-buttons .btn {
    flex: 1;
    padding: 6px 8px;
}

/* Metrics table compact */
.compact-panel .metrics-table {
    margin-bottom: 0;
    font-size: 12px;
}

.compact-panel .metrics-table td {
    padding: 4px 6px;
}

.compact-panel .metrics-table td:nth-child(odd) {
    white-space: nowrap;
}

.compact-panel .metrics-table .metric-value {
    min-width: 40px;
}

/* Execution Log - extends shared .execution-log from visualizations.css */
.execution-log {
    background-color: var(--shidoku-cell-bg);
    border-color: var(--shidoku-border);
}

.log-entry {
    flex-direction: column;
    gap: 4px;
}

.log-entry.log-info {
    background-color: rgba(131, 165, 152, 0.15);
    color: #83a598;
}

.log-entry.log-ac3 {
    background-color: rgba(250, 189, 47, 0.15);
    color: #d79921;
}

.log-entry.log-assign {
    background-color: rgba(184, 187, 38, 0.15);
    color: #98971a;
}

.log-entry.log-backtrack {
    background-color: rgba(251, 73, 52, 0.15);
    color: #cc241d;
}

.log-entry.log-prune {
    background-color: rgba(214, 93, 14, 0.15);
    color: #d65d0e;
}

.log-entry.log-success {
    background-color: rgba(184, 187, 38, 0.25);
    color: #98971a;
    font-weight: bold;
}

.log-entry.log-failure {
    background-color: rgba(251, 73, 52, 0.25);
    color: #cc241d;
    font-weight: bold;
}

[data-theme="gruvbox-dark"] .log-entry.log-info {
    color: #83a598;
}

[data-theme="gruvbox-dark"] .log-entry.log-ac3 {
    color: #fabd2f;
}

[data-theme="gruvbox-dark"] .log-entry.log-assign {
    color: #b8bb26;
}

[data-theme="gruvbox-dark"] .log-entry.log-backtrack {
    color: #fb4934;
}

[data-theme="gruvbox-dark"] .log-entry.log-prune {
    color: #fe8019;
}

[data-theme="gruvbox-dark"] .log-entry.log-success {
    color: #b8bb26;
}

[data-theme="gruvbox-dark"] .log-entry.log-failure {
    color: #fb4934;
}

/* Cell Input Mode */
.shidoku-cell.input-mode {
    outline: 3px solid #007bff;
    outline-offset: -3px;
}

[data-theme="gruvbox-dark"] .shidoku-cell.input-mode {
    outline-color: #83a598;
}

/* Button States */
.btn-toolbar {
    margin-bottom: 10px;
}

.btn-toolbar .btn-group {
    margin-right: 5px;
    margin-bottom: 5px;
}

/* Panel body spacing */
.panel-body .form-group:last-child {
    margin-bottom: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .shidoku-grid {
        grid-template-columns: repeat(4, 60px);
        grid-template-rows: repeat(4, 60px);
    }

    .shidoku-cell {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }

    .domain-value {
        font-size: 12px;
    }

    .assigned-value {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .shidoku-grid {
        grid-template-columns: repeat(4, 50px);
        grid-template-rows: repeat(4, 50px);
    }

    .shidoku-cell {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }

    .domain-value {
        font-size: 10px;
    }

    .assigned-value {
        font-size: 24px;
    }

    .grid-legend {
        font-size: 10px;
        gap: 10px;
    }
}

/* ============================================
   Search Tree Visualization
   ============================================ */

.search-tree-container {
    position: relative;
    width: 100%;
    height: 350px;
    overflow: hidden;
    background-color: var(--shidoku-cell-bg);
    border: 1px solid var(--shidoku-border);
    border-radius: 4px;
}

.search-tree-svg {
    width: 100%;
    height: 100%;
    cursor: grab;
}

.search-tree-svg:active {
    cursor: grabbing;
}

/* Tree node styling */
.tree-node {
    cursor: pointer;
}

.tree-node:hover .tree-grid-bg {
    filter: brightness(1.1);
}

.tree-node-label {
    font-family: var(--viz-mono-font);
    font-size: 9px;
    text-anchor: middle;
    fill: var(--shidoku-domain-text);
    pointer-events: none;
}

/* Mini-grid background/border based on node status */
.tree-grid-bg {
    fill: var(--shidoku-cell-bg);
    stroke: var(--shidoku-border);
    stroke-width: 2;
}

.tree-grid-bg.exploring {
    stroke: var(--shidoku-examining-border);
    stroke-width: 2;
}

.tree-grid-bg.current {
    stroke: var(--shidoku-examining-border);
    stroke-width: 3;
    filter: drop-shadow(0 0 6px var(--shidoku-examining-border));
}

.tree-grid-bg.on-solution-path {
    stroke: var(--shidoku-assigned-border);
    stroke-width: 3;
    filter: drop-shadow(0 0 4px var(--shidoku-assigned-border));
}

.tree-grid-bg.backtracked {
    stroke: var(--shidoku-conflict-border);
    stroke-width: 2;
    opacity: 0.7;
}

/* Mini-grid cells */
.tree-grid-cell {
    fill: var(--shidoku-cell-bg);
    stroke: var(--shidoku-border);
    stroke-width: 0.5;
}

/* Exploring cell (attempted assignment) - YELLOW */
.tree-grid-cell-exploring {
    fill: var(--shidoku-examining-bg);
    stroke: var(--shidoku-examining-border);
    stroke-width: 1.5;
}

/* Success cell (on solution path) - GREEN */
.tree-grid-cell-success {
    fill: var(--shidoku-assigned-bg);
    stroke: var(--shidoku-assigned-border);
    stroke-width: 1.5;
}

/* Failed cell (conflict/backtracked) - RED */
.tree-grid-cell-failed {
    fill: var(--shidoku-conflict-bg);
    stroke: var(--shidoku-conflict-border);
    stroke-width: 1.5;
}

/* 2x2 box borders in mini-grid */
.tree-grid-box-border {
    stroke: var(--shidoku-box-border);
    stroke-width: 1.5;
}

/* Values in mini-grid */
.tree-grid-value {
    font-family: var(--viz-mono-font);
    font-size: 9px;
    text-anchor: middle;
    fill: var(--shidoku-text);
    pointer-events: none;
}

.tree-grid-value-exploring {
    font-weight: bold;
    fill: var(--shidoku-examining-border);
}

.tree-grid-value-success {
    font-weight: bold;
    fill: var(--shidoku-assigned-border);
}

.tree-grid-value-failed {
    font-weight: bold;
    fill: var(--shidoku-conflict-border);
}

/* Root node styling */
.tree-grid-bg.root {
    stroke: var(--shidoku-box-border);
    stroke-width: 2;
}

/* Tree edges */
.tree-edge {
    fill: none;
    stroke: var(--shidoku-border);
    stroke-width: 2;
    opacity: 0.6;
}

.tree-edge.active {
    stroke: var(--shidoku-examining-border);
    stroke-width: 3;
    opacity: 1;
}

.tree-edge.success {
    stroke: var(--shidoku-assigned-border);
    stroke-width: 3;
    opacity: 1;
}

.tree-edge.backtracked {
    stroke: var(--shidoku-conflict-border);
    stroke-width: 2;
    opacity: 0.5;
    stroke-dasharray: 4 2;
}

/* Tree tooltip */
.tree-tooltip {
    position: absolute;
    padding: 8px 12px;
    background-color: var(--shidoku-fixed-bg);
    border: 1px solid var(--shidoku-border);
    border-radius: 4px;
    font-family: var(--viz-mono-font);
    font-size: 11px;
    color: var(--shidoku-text);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    max-width: 200px;
}

.tree-tooltip.visible {
    opacity: 1;
}

.tree-tooltip-title {
    font-weight: bold;
    margin-bottom: 4px;
    color: var(--shidoku-examining-border);
}

.tree-tooltip-info {
    color: var(--shidoku-domain-text);
}

/* Tree controls */
.tree-controls {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tree-controls-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tree-zoom-control {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--shidoku-domain-text);
}

.tree-zoom-control input[type="range"] {
    width: 80px;
    height: 4px;
    cursor: pointer;
}

.tree-info {
    margin-left: auto;
    font-size: 12px;
    color: var(--shidoku-domain-text);
}

/* Tree legend */
.tree-legend {
    display: flex;
    gap: 12px;
    font-size: 11px;
}

.tree-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--shidoku-domain-text);
}

.tree-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid;
}

.tree-dot-current {
    background-color: var(--shidoku-examining-bg);
    border-color: var(--shidoku-examining-border);
    box-shadow: 0 0 4px var(--shidoku-examining-border);
}

.tree-dot-success {
    background-color: var(--shidoku-assigned-bg);
    border-color: var(--shidoku-assigned-border);
}

.tree-dot-backtracked {
    background-color: var(--shidoku-conflict-bg);
    border-color: var(--shidoku-conflict-border);
}

.tree-dot-unexplored {
    background-color: var(--shidoku-cell-bg);
    border-color: var(--shidoku-border);
}

/* Root node special styling */
.tree-node-circle.root {
    fill: var(--shidoku-fixed-bg);
    stroke: var(--shidoku-box-border);
    stroke-width: 3;
}

/* Empty state message */
.tree-empty-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--shidoku-domain-text);
    font-size: 14px;
    text-align: center;
}

/* Dark theme adjustments */
[data-theme="gruvbox-dark"] .tree-tooltip {
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

[data-theme="gruvbox-dark"] .search-tree-container {
    background-color: #1d2021;
}

/* ============================================
   Execution Log Mini-Grid
   ============================================ */

.log-entry-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.log-mini-grid {
    display: grid;
    grid-template-columns: repeat(4, 18px);
    grid-template-rows: repeat(4, 18px);
    gap: 1px;
    background-color: var(--shidoku-border);
    border: 2px solid var(--shidoku-box-border);
    margin-left: 24px;
    margin-bottom: 4px;
    width: fit-content;
}

.log-grid-cell {
    width: 18px;
    height: 18px;
    background-color: var(--shidoku-cell-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--viz-mono-font);
    font-size: 10px;
    font-weight: bold;
    color: var(--shidoku-text);
    box-sizing: border-box;
}

/* Exploring cell (attempted assignment) - YELLOW */
.log-grid-cell-exploring {
    background-color: var(--shidoku-examining-bg);
    border: 1px solid var(--shidoku-examining-border);
    color: var(--shidoku-examining-border);
}

/* Success cell (on solution path) - GREEN */
.log-grid-cell-success {
    background-color: var(--shidoku-assigned-bg);
    border: 1px solid var(--shidoku-assigned-border);
    color: var(--shidoku-assigned-border);
}

/* Failed cell (conflict/backtracked) - RED */
.log-grid-cell-failed {
    background-color: var(--shidoku-conflict-bg);
    border: 1px solid var(--shidoku-conflict-border);
    color: var(--shidoku-conflict-border);
}

/* 2x2 box borders */
.log-grid-cell-box-right {
    border-right: 2px solid var(--shidoku-box-border);
}

.log-grid-cell-box-bottom {
    border-bottom: 2px solid var(--shidoku-box-border);
}

/* ============================================
   Algorithm Comparison Tab
   ============================================ */

.compare-table-container {
    max-height: 420px;
    overflow-y: auto;
}

/* Comparison Table */
#comparison-table {
    margin-bottom: 0;
    font-size: 12px;
    border-collapse: separate;
    border-spacing: 0;
}

#comparison-table th {
    background-color: var(--shidoku-fixed-bg);
    text-align: center;
    color: var(--shidoku-text);
    padding: 6px 8px;
    position: sticky;
    top: 0;
    z-index: 1;
}

#comparison-table td {
    text-align: center;
    font-family: var(--viz-mono-font);
    color: var(--shidoku-text);
    padding: 5px 8px;
}

#comparison-table td:first-child {
    text-align: left;
    font-family: inherit;
    white-space: nowrap;
}

/* Highlight best values */
#comparison-table td.best-value {
    background-color: var(--shidoku-assigned-bg);
    font-weight: bold;
    color: var(--shidoku-assigned-border);
    border: 1px solid var(--shidoku-assigned-border);
}

/* Algorithm couldn't find solution */
#comparison-table td.no-solution-value {
    background-color: var(--shidoku-examining-bg);
    color: var(--shidoku-examining-border);
    font-weight: bold;
    font-family: inherit;
    border: 1px solid var(--shidoku-examining-border);
    text-align: center;
}

/* N/A cells for non-applicable metrics */
#comparison-table td.na-value {
    color: var(--shidoku-domain-text);
    font-style: italic;
    font-family: inherit;
    border: 1px solid var(--shidoku-domain-text);
}

/* Clickable algorithm names */
#comparison-table td.algorithm-name {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

#comparison-table td.algorithm-name:hover {
    background-color: var(--shidoku-hover-bg);
    text-decoration: underline;
}

/* Selected row highlighting */
#comparison-table tr.selected-row {
    outline: 2px solid var(--shidoku-trying-border);
    outline-offset: -2px;
}

#comparison-table tr.selected-row td.algorithm-name {
    background-color: var(--shidoku-trying-bg);
    font-weight: bold;
}

/* Dark theme adjustments for comparison table */
[data-theme="gruvbox-dark"] #comparison-table th {
    border-color: var(--shidoku-border);
}

[data-theme="gruvbox-dark"] #comparison-table td {
    border-color: var(--shidoku-border);
}
