/* ============================================ */
/* NOTEBOOK VIEWER STYLES */
/* ============================================ */

.notebook-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.notebook-modal.active {
    opacity: 1;
    pointer-events: all;
}

.notebook-modal-content {
    width: 100%;
    max-width: 1400px;
    height: 100%;
    max-height: 100vh;
    background: #1e1e1e;
    border: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.notebook-modal.active .notebook-modal-content {
    transform: translateY(0);
}

/* Document Viewer */
.document-viewer-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    background: #1e1e1e;
    position: relative;
}


/* Colab-style Header */
.notebook-header {
    background: #383838;
    /* Darker colab header */
    border-bottom: 1px solid #444;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.notebook-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #252526;
}

.notebook-title-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.notebook-title-container h2 {
    font-size: 0.95rem;
    color: #e8eaed;
    margin: 0;
    font-weight: 500;
}

.notebook-toolbar {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    background: #383838;
    border-top: 1px solid #333;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.toolbar-btn {
    background: transparent;
    border: none;
    color: #dadce0;
    font-size: 0.8rem;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'JetBrains Mono', sans-serif;
    transition: background 0.2s;
    flex-shrink: 0;
}

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

.toolbar-btn.primary-action {
    color: #fff;
    font-weight: 500;
}

.toolbar-separator {
    width: 1px;
    height: 16px;
    background: #555;
    margin: 0 4px;
}

/* Status Badge */
.notebook-status {
    font-size: 0.8rem;
    color: #aaa;
}

/* Close Button */
.close-notebook-modal {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 5px;
}

.close-notebook-modal:hover {
    color: #fff;
}

/* Status Badge */
.status-badge {
    display: none;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-left: 10px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #888;
    transition: all 0.3s ease;
}

.status-dot.active {
    background: #4caf50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
}

.status-dot.busy {
    background: #ff9800;
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.5);
}

.status-dot.not-ready {
    background: #f44336;
    box-shadow: 0 0 8px rgba(244, 67, 54, 0.5);
}

#notebook-status {
    font-size: 0.75rem;
    color: #ccc;
    font-family: 'JetBrains Mono', sans-serif;
}

/* Toolbar Label */
.toolbar-label {
    font-size: 0.85rem;
    color: #e8eaed;
    margin-left: 10px;
    opacity: 0.8;
    font-family: 'JetBrains Mono', sans-serif;
}

.notebook-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: 'JetBrains Mono', monospace;
}

/* Notebook Cells */
.notebook-cell {
    margin-bottom: 1rem;
    position: relative;
}

/* Code Cell Layout */
.cell-input {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    align-items: flex-start;
}

/* Add style matching iframe for embed */
#doc-viewer-iframe,
#doc-viewer-embed {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    /* PDF viewer often needs white bg */
}

/* Run Button (Gutter Play) */
.cell-run-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #383838;
    border: 2px solid #555;
    color: #aaa;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.75rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.cell-run-btn:hover {
    background: #444;
    color: #fff;
    border-color: #666;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.cell-run-btn i {
    margin-left: 2px;
    /* Visual center adjustment for play icon */
}

.cell-code-wrapper {
    flex: 1;
    min-width: 0;
    background: #2b2b2b;
    border-radius: 4px;
    border: 1px solid #3e3e42;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Output Area */
.cell-output-container {
    margin-left: 36px;
    padding-top: 10px;
    font-family: monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cell-output {
    margin-bottom: 5px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.output-stream {
    color: #d4d4d4;
}

.output-result {
    color: #dcdcaa;
}

.output-error {
    color: #f48771;
    background: rgba(244, 135, 113, 0.1);
    padding: 5px;
    border-radius: 3px;
}

.cell-output-container img {
    display: block;
    max-width: 100%;
    height: auto;
    background: white;
    /* Images often have transparency or black text */
    padding: 10px;
    border-radius: 8px;
    margin-top: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

/* Loading Spinner */
.notebook-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #aaa;
    gap: 15px;
}

.notebook-loading i {
    font-size: 2rem;
    color: #007bff;
}

/* Desktop scale-up */
@media (min-width: 600px) {
    .notebook-modal-content {
        width: 95%;
        height: 90%;
        max-height: 90vh;
        border: 1px solid #333;
        border-radius: 8px;
    }

    .notebook-top-bar {
        padding: 8px 16px;
    }

    .notebook-title-container h2 {
        font-size: 1.1rem;
    }

    .status-badge {
        display: flex;
    }

    .notebook-toolbar {
        padding: 4px 16px;
        gap: 10px;
        overflow-x: visible;
        white-space: normal;
    }

    .toolbar-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .notebook-body {
        padding: 2rem;
    }

    .cell-input {
        gap: 12px;
    }

    .cell-run-btn {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
    }

    .cell-output-container {
        margin-left: 50px;
        font-size: 0.9rem;
    }
}