/* 
 * styles.css - Comprehensive styling for AI Search Algorithm Visualizer
 * Includes light/dark mode, responsive design, and smooth animations
 */

/* ===== CSS Variables (Theme) ===== */
:root {
    /* Light Mode Colors - Clean Black/White + Single Accent */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --canvas-bg: #ffffff;
    --text-primary: #111111;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --border-hover: #d1d5db;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* Single Accent Color - Professional Blue */
    --accent-primary: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-active: #2563eb;

    /* Status Colors */
    --color-success: #10b981;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;

    /* Node Colors */
    --node-empty: #ffffff;
    --node-source: #ef4444;
    --node-goal: #10b981;
    --node-visited: #8b5cf6;
    --node-path: #f59e0b;
    --node-border: #374151;

    /* Surfaces */
    --card-bg: #ffffff;
    --card-hover: #f9fafb;

    /* Spacing (8px grid system) */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border Radius - Modern rounded corners */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* Dark Mode - Pure dark, high contrast */
body.dark-mode {
    --bg-primary: #111111;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #222222;
    --canvas-bg: #0a0a0a;
    --text-primary: #ffffff;
    --text-secondary: #a3a3a3;
    --text-muted: #666666;
    --border-color: #2a2a2a;
    --border-hover: #3a3a3a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);

    --card-bg: #1a1a1a;
    --card-hover: #222222;

    --node-empty: #374151;
    --node-border: #9ca3af;
}

/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

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

/* ===== Header ===== */
.header {
    background: var(--accent-primary);
    color: white;
    padding: 12px var(--spacing-xl);
    box-shadow: var(--shadow-md);
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-lg);
}

.header-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.header-title p {
    font-size: 0.875rem;
    opacity: 0.9;
    margin: 4px 0 0 0;
}

.header-actions {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
    flex-wrap: wrap;
}

.header-actions a {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* ===== Main Content Layout ===== */
.main-content {
    display: grid;
    grid-template-columns: 300px 1fr 350px;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    flex: 1;
    overflow: hidden;
}

/* ===== Sidebars ===== */
.sidebar-left,
.sidebar-right {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    overflow-y: auto;
    padding-right: var(--spacing-sm);
}

.sidebar-left {
    scrollbar-width: thin;
}

.sidebar-right {
    scrollbar-width: thin;
}

/* Custom Scrollbar */
.sidebar-left::-webkit-scrollbar,
.sidebar-right::-webkit-scrollbar {
    width: 8px;
}

.sidebar-left::-webkit-scrollbar-track,
.sidebar-right::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

.sidebar-left::-webkit-scrollbar-thumb,
.sidebar-right::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

.sidebar-left::-webkit-scrollbar-thumb:hover,
.sidebar-right::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ===== Panel Styling ===== */
.panel {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: box-shadow var(--transition-normal);
}

.panel:hover {
    box-shadow: var(--shadow-lg);
}

.panel h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* ===== Canvas Container ===== */
.canvas-container {
    position: relative;
    background: var(--canvas-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

#graph-canvas {
    display: block;
    width: 100%;
    height: 100%;
    /* Hardware acceleration for smooth rendering */
    transform: translateZ(0);
    will-change: transform;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    /* Prevent text selection during drag */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    /* Touch action */
    touch-action: none;
    /* Default cursor */
    cursor: default;
}

.canvas-overlay {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    pointer-events: none;
}

.legend {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    display: flex;
    gap: var(--spacing-lg);
    box-shadow: 0 2px 4px var(--shadow);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
}

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

/* ===== Buttons ===== */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active:not(:disabled) {
    background: var(--accent-active);
    transform: translateY(0);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--card-hover);
    border-color: var(--border-hover);
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-icon {
    background: transparent;
    color: white;
    font-size: 1.5rem;
    padding: var(--spacing-sm);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon-sm {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 1.2rem;
}

.btn-full {
    width: 100%;
}

.btn-small {
    width: 100%;
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.8rem;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Tool Buttons ===== */
.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
}

.btn-tool {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: var(--spacing-sm);
    font-size: 0.8rem;
    text-align: center;
    border-radius: var(--radius-md);
}

.btn-tool:hover {
    border-color: var(--color-primary);
    background: var(--bg-tertiary);
}

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

/* ===== Lucide Icons Styling ===== */
[data-lucide] {
    width: 18px;
    height: 18px;
    stroke-width: 2;
    color: currentColor;
}

.btn-icon [data-lucide],
.btn-tool [data-lucide] {
    width: 18px;
    height: 18px;
}

.btn-icon-sm [data-lucide] {
    width: 16px;
    height: 16px;
}

.panel h3 [data-lucide] {
    width: 18px;
    height: 18px;
    margin-right: 4px;
}

/* ===== Animation Controls ===== */
.animation-controls {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.step-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
}

.btn-step {
    font-size: 1.5rem;
    padding: var(--spacing-md);
}

.speed-control {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.speed-control label {
    font-size: 0.875rem;
    font-weight: 500;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid var(--accent-primary);
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid var(--accent-primary);
    cursor: pointer;
    border: none;
}

/* ===== Input Fields ===== */
.select-input,
.input-field {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color var(--transition-fast);
}

.select-input:focus,
.input-field:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ===== File Operations ===== */
.file-operations,
.export-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
}

/* ===== View Controls ===== */
.view-controls {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--spacing-xs);
}

/* ===== Data Display ===== */
.data-display {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.data-row {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.data-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-value {
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 0.875rem;
    background: var(--bg-secondary);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    word-wrap: break-word;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.8;
}

/* Array styling for data display */
.array-empty {
    color: var(--text-muted);
    font-style: italic;
}

.array-bracket {
    color: var(--text-muted);
    font-weight: bold;
}

.array-item {
    color: var(--accent-primary);
    font-weight: 500;
    padding: 2px 6px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: var(--radius-sm);
    margin: 0 2px;
}

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

/* ===== Search Results ===== */
.search-results {
    font-size: 0.875rem;
    line-height: 1.6;
}

.search-results p {
    margin-bottom: var(--spacing-sm);
}

.status-pending {
    color: var(--text-secondary);
    font-style: italic;
}

.status-success {
    color: var(--color-success);
    font-weight: 600;
}

.status-failure {
    color: var(--color-danger);
    font-weight: 600;
}

.result-metric {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-xs) 0;
    border-bottom: 1px solid var(--border-color);
}

.result-metric:last-child {
    border-bottom: none;
}

/* ===== Algorithm Info ===== */
.algorithm-info {
    font-size: 0.875rem;
    line-height: 1.6;
}

.algorithm-info h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--accent-primary);
}

.algorithm-info p {
    margin-bottom: var(--spacing-sm);
}

.algorithm-info strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ===== Graph Statistics ===== */
.graph-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
}

/* ===== Example Graphs ===== */
.example-graphs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
}

/* ===== Keyboard Shortcuts ===== */
.keyboard-shortcuts .shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    font-size: 0.75rem;
}

.keyboard-shortcuts .shortcuts-list>div {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-xs) 0;
}

kbd {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    font-family: monospace;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ===== Footer ===== */
.footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: var(--spacing-md) var(--spacing-xl);
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ===== Status Messages ===== */
.status-pending {
    color: var(--text-secondary);
    font-style: italic;
}

.status-success {
    color: var(--color-success);
    font-weight: 600;
}

.status-failure {
    color: var(--color-danger);
    font-weight: 600;
}

/* ===== Responsive Design ===== */
@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 280px 1fr 320px;
    }
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 250px 1fr 300px;
    }

    .panel {
        padding: var(--spacing-md);
    }
}

@media (max-width: 992px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

    .sidebar-left,
    .sidebar-right {
        max-height: 300px;
    }

    .canvas-container {
        min-height: 400px;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .header p {
        font-size: 0.875rem;
    }

    .tool-grid,
    .file-operations,
    .export-options,
    .example-graphs {
        grid-template-columns: 1fr;
    }

    .legend {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
}

/* ===== Animations ===== */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }

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

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-slide-in {
    animation: slideIn 0.3s ease-out;
}

/* ===== Utility Classes ===== */
.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: var(--spacing-sm);
}

.mt-2 {
    margin-top: var(--spacing-md);
}

.mt-3 {
    margin-top: var(--spacing-lg);
}

.mb-1 {
    margin-bottom: var(--spacing-sm);
}

.mb-2 {
    margin-bottom: var(--spacing-md);
}

.mb-3 {
    margin-bottom: var(--spacing-lg);
}

.hidden {
    display: none !important;
}

/* ===== Modal Styles ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--bg-primary);
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

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

/* ===== Header Link Buttons ===== */
.btn-header-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: white !important;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-header-link:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.btn-header-link:active {
    transform: translateY(0);
}

.btn-header-link i {
    width: 16px;
    height: 16px;
}

/* Light mode header links */
body:not(.dark-mode) .btn-header-link {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.15);
}

body:not(.dark-mode) .btn-header-link:hover {
    background: rgba(0, 0, 0, 0.12);
    border-color: rgba(0, 0, 0, 0.25);
}

/* ===== Print Styles ===== */
@media print {

    .sidebar-left,
    .sidebar-right,
    .header-actions,
    .footer {
        display: none;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .canvas-container {
        page-break-inside: avoid;
    }
}