/* ==========================================
   Jupyter Console - CSS Styles
   Aesthetic inspired by Jupyter Notebook
   ========================================== */

:root {
    /* Color Palette - Jupyter inspired with modern touch */
    --bg-primary: #f7f7f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #fafafa;
    --bg-code: #f8f8f8;
    
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    
    --border-color: #e0e0e0;
    --border-light: #f0f0f0;
    
    --accent-primary: #f37626;
    --accent-secondary: #e56717;
    --accent-blue: #4a8cc9;
    --accent-green: #28a745;
    --accent-red: #dc3545;
    --accent-purple: #8b5cf6;
    --accent-orange: #f59e0b;
    
    --cell-input-border: #4a8cc9;
    --cell-output-bg: #ffffff;
    --cell-error-bg: #fff5f5;
    --cell-error-border: #dc3545;
    
    --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);
    
    /* Typography */
    --font-sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    
    /* Spacing */
    --header-height: 56px;
    --sidebar-width: 280px;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
}

.title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

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

.auth-section, .user-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.token-input {
    width: 320px;
    padding: 8px 14px;
    font-size: 13px;
    font-family: var(--font-mono);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-tertiary);
    transition: all 0.2s ease;
}

.token-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(243, 118, 38, 0.15);
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

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

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

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

.btn-skill {
    color: white;
    background: var(--accent-purple);
    font-size: 12px;
    padding: 6px 12px;
}

.btn-skill:hover {
    background: #7c3aed;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-skill svg {
    width: 14px;
    height: 14px;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.user-badge {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-green);
    background: rgba(40, 167, 69, 0.1);
    border-radius: 20px;
}

/* Main Content Area */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-header h2 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 4px;
}

.empty-state .hint {
    font-size: 12px;
}

/* Session Cards */
.session-card {
    padding: 14px 16px;
    margin-bottom: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.session-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.session-card.active {
    border-color: var(--accent-primary);
    background: rgba(243, 118, 38, 0.05);
}

.session-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.session-id {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.session-status.active {
    color: var(--accent-green);
}

.session-status.hibernated {
    color: var(--text-muted);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.session-status.active .status-dot {
    background: var(--accent-green);
}

.session-status.hibernated .status-dot {
    background: var(--text-muted);
}

.session-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-secondary);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Notebook Area */
.notebook-area {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.welcome-content {
    text-align: center;
    max-width: 480px;
}

.welcome-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
    color: var(--text-muted);
}

.welcome-content h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.welcome-content p {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.welcome-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    background: var(--accent-primary);
    border-radius: 50%;
}

/* Notebook Container */
.notebook-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.notebook-header {
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.notebook-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 4px;
}

.notebook-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.notebook-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.notebook-cells {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-primary);
}

/* Cell Styles - Jupyter-like */
.cell {
    margin-bottom: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.cell-input {
    display: flex;
    border-bottom: 1px solid var(--border-light);
}

.cell-prompt {
    width: 80px;
    min-width: 80px;
    padding: 12px 8px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-blue);
    text-align: right;
    background: var(--bg-tertiary);
    border-right: 3px solid var(--cell-input-border);
    user-select: none;
}

.cell-code {
    flex: 1;
    padding: 12px 16px;
    overflow-x: auto;
    overflow-y: auto;
}

.cell-code pre {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.cell-code code {
    font-family: inherit;
    background: transparent;
}

/* Output styles */
.cell-output {
    display: flex;
}

.cell-output .cell-prompt {
    color: var(--accent-red);
    border-right-color: transparent;
    background: transparent;
}

.cell-output-content {
    flex: 1;
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    background: var(--cell-output-bg);
}

/* Output types */
.output-text {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.output-html {
    overflow-x: auto;
}

.output-image img {
    max-width: 100%;
    height: auto;
}

/* Error output */
.cell-error {
    background: var(--cell-error-bg);
}

.cell-error .cell-prompt {
    color: var(--accent-red);
}

.cell-error .cell-output-content {
    background: var(--cell-error-bg);
    color: var(--accent-red);
    font-family: var(--font-mono);
}

.error-traceback {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Result output - JSON display */
.output-result {
    padding: 8px 12px;
    background: #f0f7ff;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
}

/* Empty notebook state */
.notebook-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--text-muted);
    text-align: center;
}

.notebook-empty svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.notebook-empty p {
    font-size: 14px;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgba(255, 255, 255, 0.9);
    z-index: 1000;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1001;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    min-width: 280px;
    max-width: 400px;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

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

.toast.info {
    border-left: 4px solid var(--accent-blue);
}

.toast-message {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
}

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

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

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

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

/* Highlight.js overrides for Jupyter style */
.hljs {
    background: transparent !important;
    padding: 0 !important;
}

/* Cell Details / Request-Response Section */
.cell-details {
    margin-top: 12px;
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
}

.details-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.details-toggle:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.toggle-icon {
    transition: transform 0.2s ease;
}

.toggle-icon.expanded {
    transform: rotate(90deg);
}

.elapsed-badge {
    margin-left: auto;
    padding: 2px 8px;
    background: var(--accent-blue);
    color: white;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

.details-content {
    margin-top: 8px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    max-height: 400px;
    overflow-y: auto;
}

.details-content.hidden {
    display: none;
}

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

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

.details-section h4 {
    margin: 0 0 8px 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.details-subsection {
    margin-bottom: 8px;
}

.details-label {
    display: inline-block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-purple);
}

.details-empty {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

/* JSON Tree Styles */
.json-tree {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-primary);
}

.json-item {
    position: relative;
}

.json-key {
    color: var(--accent-blue);
}

.json-string {
    color: var(--accent-green);
    word-break: break-all;
}

.json-number {
    color: var(--accent-orange);
}

.json-boolean {
    color: var(--accent-purple);
    font-weight: 600;
}

.json-null,
.json-undefined {
    color: var(--text-muted);
    font-style: italic;
}

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

.json-index {
    color: var(--text-muted);
    font-size: 10px;
}

.json-ellipsis {
    color: var(--text-muted);
    font-style: italic;
    font-size: 10px;
}

.json-unknown {
    color: var(--text-secondary);
}

.json-object,
.json-array {
    display: block;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

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

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

.modal {
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    margin: 20px;
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-description {
    margin: 0 0 20px 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    border-radius: 0 0 12px 12px;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group .required {
    color: var(--accent-red);
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.15s ease;
    box-sizing: border-box;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(243, 118, 38, 0.1);
}

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

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sidebar {
        width: 220px;
    }
    
    .token-input {
        width: 200px;
    }
    
    .cell-prompt {
        width: 60px;
        min-width: 60px;
        font-size: 11px;
    }
}

