/* Base Styles - Research Paper Aesthetic */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ffffff;
    color: #222;
    line-height: 1.6;
}

.playground-container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 2rem 3rem;
}

/* Header - Clean and Minimal */
.playground-header {
    background: #ffffff;
    color: #222;
    padding: 2rem 0;
    border-bottom: 1px solid #ddd;
    margin-bottom: 2rem;
}

.header-content h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    color: #000;
}

.header-logo {
    height: 1.75rem;
    width: auto;
    vertical-align: middle;
}

.header-content .subtitle {
    font-size: 1rem;
    color: #555;
    margin-bottom: 1rem;
    font-weight: 400;
}

.back-link {
    display: inline-block;
    color: #0066cc;
    text-decoration: none;
    font-size: 0.95rem;
}

.back-link:hover {
    text-decoration: underline;
}

/* Example Selector */
.example-selector {
    background: #fafafa;
    padding: 1.25rem;
    border: 1px solid #e0e0e0;
    margin-bottom: 2rem;
}

.example-selector label {
    font-weight: 600;
    margin-right: 1rem;
    color: #333;
    font-size: 0.95rem;
}

.search-input {
    padding: 0.4rem 0.75rem;
    border: 1px solid #ccc;
    font-size: 0.9rem;
    min-width: 200px;
    transition: border-color 0.15s;
}

.search-input:focus {
    outline: none;
    border-color: #000;
}

.no-results {
    text-align: center;
    padding: 1.5rem;
    color: #666;
    font-size: 0.9rem;
    font-style: italic;
}

.example-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.example-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #ccc;
    background: white;
    color: #333;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 400;
    transition: all 0.15s;
}

.example-btn:hover {
    border-color: #000;
    background: #fafafa;
}

.example-btn.active {
    background: #000;
    border-color: #000;
    color: white;
}

/* Main Content Area */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: start;
}

/* Panels */
.editor-panel,
.viz-panel,
.console-panel {
    background: white;
    border: 1px solid #ddd;
    overflow: hidden;
}

.panel-header {
    background: #f8f8f8;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    font-size: 0.95rem;
    color: #333;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.editor-controls {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 0.4rem 0.9rem;
    border: 1px solid #ccc;
    font-size: 0.85rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    color: #333;
}

.btn-primary {
    border-color: #000;
    background: #000;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #333;
    border-color: #333;
}

.btn-primary:disabled {
    background: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
}

.btn-secondary {
    background: white;
    color: #333;
}

.btn-secondary:hover {
    background: #f8f8f8;
    border-color: #999;
}

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

/* Code Editor */
.code-editor {
    height: 600px;
    position: relative;
}

/* Snippets Bar (horizontal below editor) */
.snippets-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f8f8f8;
    border-top: 1px solid #ddd;
    flex-wrap: wrap;
}

.snippets-bar-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    margin-right: 0.5rem;
}

.snippet-btn-inline {
    padding: 0.4rem 0.75rem;
    background: white;
    border: 1px solid #ccc;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    color: #333;
    white-space: nowrap;
}

.snippet-btn-inline:hover {
    background: #000;
    color: white;
    border-color: #000;
}

.snippet-btn-inline:active {
    transform: scale(0.98);
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.loading-content {
    text-align: center;
    max-width: 400px;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
    border: 3px solid #e0e0e0;
    border-top: 3px solid #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-text {
    font-size: 1rem;
    font-weight: 500;
    color: #333;
    margin-bottom: 1rem;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-fill {
    height: 100%;
    background: #000;
    width: 0%;
    transition: width 0.3s;
}

.loading-hint {
    font-size: 0.85rem;
    color: #666;
}

/* Visualization Panel - Multiple Views */
.viz-view {
    display: none;
}

.viz-view.active {
    display: block;
}

.viz-canvas {
    width: 100%;
    height: 500px;
    background: #fafafa;
}

.viz-table {
    width: 100%;
    height: 500px;
    overflow: auto;
    background: white;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table thead {
    position: sticky;
    top: 0;
    background: #f8f8f8;
    z-index: 10;
}

.data-table th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #ddd;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.025em;
}

.data-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
}

.data-table tbody tr:hover {
    background: #fafafa;
}

.table-empty {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 2rem !important;
}

.viz-chart {
    width: 100%;
    height: 500px;
    background: white;
    padding: 1rem;
}

#chart-canvas {
    width: 100%;
    height: 100%;
}

.viz-info {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e0e0e0;
}

.viz-placeholder {
    color: #999;
    text-align: center;
    font-style: italic;
    font-size: 0.9rem;
}

/* Simulation Progress */
.sim-progress {
    padding: 1rem;
}

.sim-progress-bar {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    margin-bottom: 0.5rem;
}

.sim-progress-fill {
    height: 100%;
    background: #000;
    width: 0%;
    transition: width 0.3s ease;
}

.sim-progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #666;
}

.live-mode-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: #333;
    margin-left: 0.5rem;
}

.live-mode-toggle input[type="checkbox"] {
    cursor: pointer;
}

/* Visualization Controls */
.viz-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.viz-mode-switcher {
    display: flex;
    border: 1px solid #ccc;
}

.viz-mode-btn {
    padding: 0.35rem 0.75rem;
    background: white;
    border: none;
    border-right: 1px solid #ccc;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    color: #333;
}

.viz-mode-btn:last-child {
    border-right: none;
}

.viz-mode-btn:hover {
    background: #f0f0f0;
}

.viz-mode-btn.active {
    background: #000;
    color: white;
}

/* Debug Mode */

.debug-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: #333;
}

.debug-toggle input[type="checkbox"] {
    cursor: pointer;
}

.debug-panel {
    border-top: 1px solid #ddd;
    background: #fafafa;
    padding: 1rem;
}

.debug-section {
    margin-bottom: 1rem;
}

.debug-section:last-child {
    margin-bottom: 0;
}

.debug-section h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #000;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.event-log {
    background: white;
    border: 1px solid #ddd;
    padding: 0.75rem;
    max-height: 150px;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.8rem;
}

.event-log-empty {
    color: #999;
    font-style: italic;
}

.event-item {
    padding: 0.25rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.event-item:last-child {
    border-bottom: none;
}

.event-time {
    color: #666;
    margin-right: 0.5rem;
}

.event-type {
    font-weight: 600;
    color: #000;
    margin-right: 0.5rem;
}

.event-details {
    color: #555;
}

.system-state {
    background: white;
    border: 1px solid #ddd;
    padding: 0.75rem;
}

.state-item {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
}

.state-item:last-child {
    border-bottom: none;
}

.state-label {
    color: #666;
}

.state-value {
    font-weight: 600;
    color: #000;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

/* Console Output */
.console-panel {
    grid-column: 1 / -1;
}

.console-output {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    padding: 1.5rem;
    background: #1e1e1e;
    color: #d4d4d4;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.5;
}

.console-output .error {
    color: #f48771;
}

.console-output .success {
    color: #89d185;
}

.console-output .info {
    color: #6eb3f7;
}

/* Snippets Section */
.snippets-section {
    background: white;
    border: 1px solid #ddd;
    margin-top: 2rem;
    overflow: hidden;
}

.snippets-header {
    padding: 0.75rem 1rem;
    background: #f8f8f8;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    border-bottom: 1px solid #ddd;
}

.snippets-header:hover {
    background: #f0f0f0;
}

.snippets-header h3 {
    font-size: 0.95rem;
    color: #333;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.snippets-section.collapsed .snippets-header {
    border-bottom: none;
}

.snippets-content {
    padding: 1.5rem;
}

.snippets-section.collapsed .snippets-content {
    display: none;
}

.snippets-hint {
    color: #666;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    font-style: italic;
}

.snippets-content h4 {
    color: #000;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.snippets-content h4:first-of-type {
    margin-top: 0;
}

.snippet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.snippet-btn {
    padding: 0.75rem;
    background: #fafafa;
    border: 1px solid #ddd;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}

.snippet-btn:hover {
    background: #f0f0f0;
    border-color: #000;
    transform: translateY(-1px);
}

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

.snippet-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: #000;
    margin-bottom: 0.25rem;
}

.snippet-preview {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.75rem;
    color: #666;
}

/* Help Section */
.help-section {
    background: white;
    border: 1px solid #ddd;
    margin-top: 2rem;
    overflow: hidden;
}

.help-header {
    padding: 0.75rem 1rem;
    background: #f8f8f8;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    border-bottom: 1px solid #ddd;
}

.help-header:hover {
    background: #f0f0f0;
}

.help-header h3 {
    font-size: 0.95rem;
    color: #333;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.toggle-icon {
    transition: transform 0.2s;
    color: #666;
}

.help-section.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.help-section.collapsed .help-header {
    border-bottom: none;
}

.help-content {
    padding: 1.5rem;
    max-height: 500px;
    overflow-y: auto;
}

.help-section.collapsed .help-content {
    display: none;
}

.help-content h4 {
    color: #000;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.help-content h4:first-child {
    margin-top: 0;
}

.help-content code {
    background: #f5f5f5;
    padding: 0.15rem 0.4rem;
    font-size: 0.85rem;
    color: #c7254e;
    display: block;
    margin: 0.5rem 0;
    border: 1px solid #e8e8e8;
}

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

    .viz-panel {
        order: -1;
    }

    .code-editor {
        height: 400px;
    }

    .viz-canvas {
        height: 350px;
    }
}

@media (max-width: 768px) {
    .playground-container {
        padding: 1rem;
    }

    .playground-header {
        padding: 1.5rem 0;
    }

    .header-content h1 {
        font-size: 1.5rem;
    }

    .example-buttons {
        flex-direction: column;
    }

    .example-btn {
        width: 100%;
    }

    .code-editor {
        height: 400px;
    }

    .editor-controls {
        flex-direction: column;
        width: 100%;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}

/* Tutorial Overlay */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tutorial-content {
    background: white;
    max-width: 500px;
    margin: 2rem;
    border: 1px solid #ddd;
    display: flex;
    flex-direction: column;
}

.tutorial-header {
    padding: 1.5rem;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tutorial-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #000;
    margin: 0;
}

.tutorial-close {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 2rem;
    height: 2rem;
}

.tutorial-close:hover {
    color: #000;
}

.tutorial-body {
    padding: 1.5rem;
    min-height: 150px;
}

.tutorial-body p {
    font-size: 1rem;
    line-height: 1.6;
    color: #333;
    margin: 0 0 1rem 0;
}

.tutorial-highlight {
    background: #f8f8f8;
    border: 1px solid #ddd;
    padding: 1rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    margin-top: 1rem;
}

.tutorial-footer {
    padding: 1.5rem;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tutorial-progress {
    font-size: 0.9rem;
    color: #666;
}

.tutorial-btn-primary,
.tutorial-btn-secondary {
    padding: 0.6rem 1.25rem;
    border: 1px solid #ccc;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
}

.tutorial-btn-primary {
    background: #000;
    color: white;
    border-color: #000;
}

.tutorial-btn-primary:hover {
    background: #333;
}

.tutorial-btn-secondary {
    background: white;
    color: #333;
}

.tutorial-btn-secondary:hover {
    background: #f8f8f8;
}

.tutorial-restart-btn {
    padding: 0.6rem 1.25rem;
    background: #000;
    color: white;
    border: 1px solid #000;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
}

.tutorial-restart-btn:hover {
    background: #333;
}

/* Scrollbar Styling - Minimal */
.console-output::-webkit-scrollbar,
.help-content::-webkit-scrollbar {
    width: 6px;
}

.console-output::-webkit-scrollbar-track,
.help-content::-webkit-scrollbar-track {
    background: #2d2d2d;
}

.console-output::-webkit-scrollbar-thumb {
    background: #555;
}

.console-output::-webkit-scrollbar-thumb:hover {
    background: #666;
}

.help-content::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.help-content::-webkit-scrollbar-thumb {
    background: #ccc;
}
