/* CSS Variables for theming */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #22c55e;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --code-bg: #0d1117;
    --shadow: rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* App container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header */
header {
    text-align: center;
    padding: 2rem 1rem;
    margin-bottom: 1rem;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

header h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 0.5rem;
}

/* Main content */
main {
    flex: 1;
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Controls panel */
.controls-panel {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    height: fit-content;
    position: sticky;
    top: 1rem;
}

.control-group {
    margin-bottom: 1.25rem;
}

.control-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.control-group select,
.control-group input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.control-group select:hover,
.control-group input[type="number"]:hover {
    border-color: var(--primary-color);
}

.control-group select:focus,
.control-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Range input styling */
.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    cursor: pointer;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: var(--primary-hover);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Range inputs group */
.range-inputs {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.range-inputs input {
    flex: 1;
}

.range-inputs span {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Checkbox group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Button group */
.button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon {
    font-size: 1rem;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    grid-column: span 2;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.secondary-btn {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.secondary-btn:hover {
    background: var(--secondary-hover);
}

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

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

/* Output panel */
.output-panel {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.output-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.output-stats {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.output-content {
    flex: 1;
    background: var(--code-bg);
    border-radius: var(--radius-sm);
    padding: 1rem;
    min-height: 400px;
    max-height: 600px;
    overflow: auto;
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

.output-content pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.placeholder-text {
    color: var(--text-muted);
    text-align: center;
    padding: 3rem;
    font-family: inherit;
}

/* Syntax highlighting */
.json-key {
    color: #7dd3fc;
}

.json-string {
    color: #86efac;
}

.json-number {
    color: #fbbf24;
}

.json-boolean {
    color: #c084fc;
}

.json-null {
    color: #f87171;
}

.json-bracket {
    color: var(--text-muted);
}

/* Visualization container */
.visualization-container {
    margin-top: 1rem;
    background: var(--code-bg);
    border-radius: var(--radius-sm);
    padding: 1rem;
    min-height: 300px;
    overflow: auto;
}

/* Tree view */
.tree-view {
    font-family: 'Fira Code', monospace;
    font-size: 0.875rem;
}

.tree-node {
    padding-left: 1.5rem;
    position: relative;
}

.tree-node::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    height: 100%;
    border-left: 1px dashed var(--border);
}

.tree-node-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
}

.tree-toggle {
    cursor: pointer;
    user-select: none;
    width: 1rem;
    text-align: center;
}

.tree-key {
    color: #7dd3fc;
}

.tree-value {
    color: #86efac;
}

/* Table view */
.table-view {
    width: 100%;
    border-collapse: collapse;
}

.table-view th,
.table-view td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table-view th {
    background: var(--surface);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table-view td {
    font-family: 'Fira Code', monospace;
    font-size: 0.875rem;
}

.table-view tr:hover td {
    background: var(--surface-hover);
}

/* Graph view */
.graph-view {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    justify-content: center;
}

.graph-node {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 50%;
    min-width: 50px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    box-shadow: 0 4px 12px var(--shadow);
    transition: transform 0.2s;
}

.graph-node:hover {
    transform: scale(1.1);
}

/* Binary tree visualization */
.binary-tree-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
}

.tree-level {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.tree-node-visual {
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    box-shadow: 0 4px 12px var(--shadow);
    position: relative;
}

.tree-node-visual.null-node {
    background: var(--surface-hover);
    color: var(--text-muted);
}

/* Linked list visualization */
.linked-list-view {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    overflow-x: auto;
}

.list-node {
    display: flex;
    align-items: center;
}

.list-node-value {
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    box-shadow: 0 4px 12px var(--shadow);
}

.list-arrow {
    color: var(--text-muted);
    font-size: 1.5rem;
    padding: 0 0.25rem;
}

.list-null {
    color: var(--text-muted);
    font-style: italic;
    padding: 0.75rem;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface);
    color: var(--text-primary);
    padding: 1rem 2rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 40px var(--shadow);
    border: 1px solid var(--border);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 1000;
}

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

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

/* Footer */
footer {
    text-align: center;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.875rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
    }

    .controls-panel {
        position: static;
    }

    .output-content {
        min-height: 300px;
    }
}

@media (max-width: 600px) {
    .app-container {
        padding: 0.75rem;
    }

    header {
        padding: 1.5rem 0.5rem;
    }

    .logo-container {
        flex-direction: column;
        gap: 0.5rem;
    }

    .controls-panel,
    .output-panel {
        padding: 1rem;
    }

    .button-group {
        grid-template-columns: 1fr;
    }

    .primary-btn {
        grid-column: span 1;
    }

    .range-inputs {
        flex-direction: column;
        gap: 0.5rem;
    }

    .range-inputs span {
        display: none;
    }

    .output-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Animation for generate button */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.primary-btn:active {
    animation: pulse 0.2s ease;
}

/* Code highlight animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.output-content pre {
    animation: fadeIn 0.3s ease;
}
