/* jupyter-viewer.css — tool-specific styles only */

/* ----------------------------------------------------------------
   Page layout
---------------------------------------------------------------- */
.nb-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 1.5rem 1rem 2rem;
    flex: 1;
}

/*override */
.tool-main {
    max-width: 860px !important;
}


/* ----------------------------------------------------------------
   Drop zone
---------------------------------------------------------------- */
.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: 2px dashed var(--color-border, #ccc);
    border-radius: var(--radius-lg, 10px);
    padding: 3rem 2rem;
    cursor: pointer;
    transition: border-color 0.18s, background 0.18s;
    background: var(--color-surface, #fff);
    text-align: center;
    min-height: 200px;
    user-select: none;
    width: 100%;
    position: relative;
}
.drop-zone:hover,
.drop-zone:focus,
.drop-zone.dragover {
    border-color: var(--color-primary, #4a90e2);
    background: rgba(74, 144, 226, 0.05);
    outline: none;
}
.drop-zone.dragover { border-style: solid; }
.drop-zone input[type="file"] { display: none; }
.drop-zone-icon {
    color: var(--color-text-muted, #aaa);
    width: 48px;
    height: 48px;
    margin-bottom: 0.35rem;
}
.drop-zone-text {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text);
}
.drop-zone-sub {
    font-size: 0.84rem;
    color: var(--color-text-muted);
}

/* ----------------------------------------------------------------
   Notebook workspace
---------------------------------------------------------------- */
.nb-workspace {
    width: 100%;
    max-width: 860px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ----------------------------------------------------------------
   Toolbar
---------------------------------------------------------------- */
.nb-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-lg, 8px);
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
    /* position: sticky; */
    top: 37px; /* leaves room for the tab bar above */
    z-index: 10;
}
.nb-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}
.nb-filename {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}
.nb-cell-count {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}
.nb-toolbar-right {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* small toolbar buttons */
.sm-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
}
.secondary-btn {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border, #ccc);
}
.secondary-btn:hover {
    background: var(--color-border, #e0e0e0);
}

/* ----------------------------------------------------------------
   Cells container
---------------------------------------------------------------- */
.nb-cells {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ----------------------------------------------------------------
   Cell wrapper
---------------------------------------------------------------- */
.nb-cell {
    position: relative;
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-lg, 8px);
    overflow: hidden;
    margin-bottom: 0.6rem;
    background: var(--color-surface, #fff);
    transition: box-shadow 0.15s;
}
.nb-cell:focus-within {
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.25);
}

/* ----------------------------------------------------------------
   Cell header bar
---------------------------------------------------------------- */
.cell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem;
    border-bottom: 1px solid var(--color-border, #eee);
    background: var(--color-bg, #f9f9f9);
    font-size: 0.75rem;
}
.cell-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}
.badge-code   { color: #6a5af9; }
.badge-md     { color: #2d9f5c; }
.cell-number  {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    margin-right: 0.1rem;
}
.cell-header-actions {
    display: flex;
    gap: 0.35rem;
}
.cell-action-btn {
    background: none;
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-sm, 4px);
    padding: 0.15rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: var(--font-main);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.cell-action-btn:hover {
    background: var(--color-primary, #4a90e2);
    border-color: var(--color-primary, #4a90e2);
    color: #fff;
}
.cell-action-btn.active {
    background: var(--color-primary, #4a90e2);
    border-color: var(--color-primary, #4a90e2);
    color: #fff;
}

/* ----------------------------------------------------------------
   Cell body
---------------------------------------------------------------- */
.cell-body {
    padding: 0.75rem 1rem;
}

/* ----------------------------------------------------------------
   Markdown rendered output
---------------------------------------------------------------- */
.cell-rendered {
    line-height: 1.7;
    font-size: 0.95rem;
    color: var(--color-text);
    overflow-wrap: break-word;
}
.cell-rendered h1,
.cell-rendered h2,
.cell-rendered h3,
.cell-rendered h4 {
    margin-top: 1rem;
    margin-bottom: 0.4rem;
    line-height: 1.3;
    color: var(--color-text);
}
.cell-rendered h1 { font-size: 1.6rem; border-bottom: 2px solid var(--color-border); padding-bottom: 0.3rem; }
.cell-rendered h2 { font-size: 1.3rem; border-bottom: 1px solid var(--color-border); padding-bottom: 0.2rem; }
.cell-rendered h3 { font-size: 1.1rem; }
.cell-rendered h4 { font-size: 1rem; }
.cell-rendered p  { margin: 0.5em 0; }
.cell-rendered a  { color: var(--color-primary); }
.cell-rendered ul,
.cell-rendered ol { padding-left: 1.5rem; margin: 0.4em 0; }
.cell-rendered li { margin: 0.15em 0; }
.cell-rendered blockquote {
    margin: 0.5rem 0;
    padding: 0.5rem 1rem;
    border-left: 4px solid var(--color-primary, #4a90e2);
    background: rgba(74, 144, 226, 0.06);
    color: var(--color-text-muted);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.cell-rendered code {
    background: #f3f3f3;
    border-radius: var(--radius-sm);
    padding: 0.1em 0.4em;
    font-family: var(--font-mono);
    font-size: 0.88em;
}
.cell-rendered pre {
    background: #f6f8fa;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}
.cell-rendered pre code {
    background: none;
    padding: 0;
    font-size: 0.88rem;
}
.cell-rendered table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.9rem;
    margin: 0.5rem 0;
    overflow-x: auto;
    display: block;
}
.cell-rendered th,
.cell-rendered td {
    border: 1px solid var(--color-border);
    padding: 0.4rem 0.7rem;
    text-align: left;
}
.cell-rendered th {
    background: var(--color-bg, #f9f9f9);
    font-weight: 700;
}
.cell-rendered img { max-width: 100%; border-radius: var(--radius-md); }
.cell-rendered hr  { border: none; border-top: 1px solid var(--color-border); margin: 1rem 0; }

/* ----------------------------------------------------------------
   Code cell
---------------------------------------------------------------- */
.code-cell-body {
    padding: 0;
}
.code-cell-source {
    margin: 0;
    padding: 0.85rem 1rem;
    background: #f6f8fa;
    border: none;
    border-radius: 0;
    font-size: 0.88rem;
    font-family: var(--font-mono);
    overflow-x: auto;
    line-height: 1.55;
    white-space: pre;
}
.code-cell-source code {
    font-family: inherit;
    font-size: inherit;
    background: none;
    padding: 0;
}

/* ----------------------------------------------------------------
   Edit textarea
---------------------------------------------------------------- */
.cell-editor {
    display: none;
    width: 100%;
    min-height: 100px;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.55;
    padding: 0.85rem 1rem;
    border: none;
    border-top: 1px solid var(--color-primary, #4a90e2);
    border-radius: 0;
    resize: vertical;
    background: #fff;
    color: var(--color-text);
    outline: none;
    box-sizing: border-box;
}
.cell-editor:focus {
    background: #fffef0;
}
.cell-editor.visible {
    display: block;
}

/* ----------------------------------------------------------------
   Admonitions  (:::{note}, :::{warning}, etc.)
---------------------------------------------------------------- */
.admonition {
    border-radius: var(--radius-md, 6px);
    padding: 0.7rem 1rem;
    margin: 0.5rem 0;
    border-left: 4px solid var(--color-primary, #4a90e2);
    font-size: 0.9rem;
    background: #e8f4fd;
    color: #1a4a7a;
}
.admonition-title {
    font-weight: 700;
    margin-bottom: 0.3rem;
    text-transform: capitalize;
}
/* Generic :::{admonition} + named types */
.admonition.note, .admonition.hint, .admonition.admonition {
    background: #e8f4fd; border-color: #4a90e2; color: #1a4a7a;
}
.admonition.warning, .admonition.caution, .admonition.attention {
    background: #fff8e1; border-color: #f0b429; color: #7a5700;
}
.admonition.danger, .admonition.error {
    background: #fdecea; border-color: #e74c3c; color: #7a1a1a;
}
.admonition.tip, .admonition.important {
    background: #edfbf0; border-color: #2ecc71; color: #1a5a2a;
}
.admonition.seealso {
    background: #f3f0ff; border-color: #6a5af9; color: #2a1a6a;
}

/* ----------------------------------------------------------------
   Math display (temml / MathML)
---------------------------------------------------------------- */
.math-display {
    display: block;
    text-align: center;
    margin: 0.75rem 0;
    overflow-x: auto;
    font-size: 1.05rem;
}
.math-inline {
    display: inline;
}
math[display="block"] {
    display: block;
    text-align: center;
    margin: 0.75rem auto;
    overflow-x: auto;
}

/* ----------------------------------------------------------------
   Front matter block (shown collapsed by default)
---------------------------------------------------------------- */
.frontmatter-cell {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 0.6rem;
    background: var(--color-bg, #f9f9f9);
}
.frontmatter-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}
.frontmatter-toggle:hover { color: var(--color-primary); }
.frontmatter-arrow { font-size: 0.7rem; transition: transform 0.2s; }
.frontmatter-arrow.open { transform: rotate(90deg); }
.frontmatter-pre {
    display: none;
    margin: 0;
    padding: 0.75rem 1rem;
    background: #f6f8fa;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.5;
    border-top: 1px solid var(--color-border);
    white-space: pre;
    overflow-x: auto;
}
.frontmatter-pre.open { display: block; }

/* ----------------------------------------------------------------
   Tags / metadata chips on cells
---------------------------------------------------------------- */
.cell-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.2rem 0.75rem 0.3rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}
.cell-tag {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    background: var(--color-border);
    color: var(--color-text-muted);
    font-family: var(--font-mono);
}

/* ----------------------------------------------------------------
   Responsive
---------------------------------------------------------------- */
@media (max-width: 600px) {
    .nb-toolbar { flex-direction: column; align-items: flex-start; }
    .nb-toolbar-right { width: 100%; justify-content: flex-end; }
    .cell-body { padding: 0.6rem 0.75rem; }
    .code-cell-source { font-size: 0.82rem; }
}

/* ----------------------------------------------------------------
   Landing layout
---------------------------------------------------------------- */
.nb-landing {
    width: 100%;
    max-width: 900px;
}

.landing-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: stretch;
}

/* ----------------------------------------------------------------
   Paste zone
---------------------------------------------------------------- */
.paste-zone {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border: 2px dashed var(--color-border, #ccc);
    border-radius: var(--radius-lg, 10px);
    padding: 1rem;
    background: var(--color-surface, #fff);
    min-height: 200px;
}

.paste-zone-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.paste-zone-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.paste-filename {
    flex: 1;
    min-width: 100px;
    padding: 0.3rem 0.6rem;
    font-size: 0.82rem;
    font-family: var(--font-mono);
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-md, 6px);
    background: var(--color-bg, #f9f9f9);
    color: var(--color-text);
    outline: none;
}
.paste-filename:focus { border-color: var(--color-primary); }

.paste-textarea {
    flex: 1;
    min-height: 190px;
    resize: vertical;
    padding: 0.65rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.83rem;
    line-height: 1.5;
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-md, 6px);
    background: var(--color-bg, #f9f9f9);
    color: var(--color-text);
    outline: none;
}
.paste-textarea:focus { border-color: var(--color-primary); }

/* ----------------------------------------------------------------
   Tab bar
---------------------------------------------------------------- */
.nb-tabbar {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    overflow-x: auto;
    background: var(--color-bg, #f9f9f9);
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-lg, 8px) var(--radius-lg, 8px) 0 0;
    height: 37px;
    position: sticky;
    top: 0;
    z-index: 11;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.nb-tabbar::-webkit-scrollbar { display: none; }

.nb-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.85rem;
    height: 100%;
    border: none;
    border-right: 1px solid var(--color-border, #ddd);
    background: var(--color-bg, #f9f9f9);
    color: var(--color-text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    font-family: var(--font-main);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    position: relative;
}
.nb-tab:hover { background: var(--color-surface, #fff); color: var(--color-text); }
.nb-tab.active {
    background: var(--color-surface, #fff);
    color: var(--color-text);
    border-bottom: 2px solid var(--color-primary, #4a90e2);
    margin-bottom: -1px;
}

.tab-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 3px;
    background: none;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}
.nb-tab:hover .tab-close,
.nb-tab.active .tab-close { opacity: 1; }
.tab-close:hover { background: rgba(0,0,0,0.1); color: #c0392b; }

.tab-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.85rem;
    height: 100%;
    border: none;
    background: none;
    color: var(--color-text-muted);
    font-size: 1.15rem;
    font-weight: 400;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}
.tab-add-btn:hover { background: var(--color-surface); color: var(--color-primary); }

/* Spacer fills remaining space in tab bar so + button doesn't hug left */
.tabbar-spacer { flex: 1; }

/* ----------------------------------------------------------------
   Add-notebook overlay
---------------------------------------------------------------- */
.add-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1.5rem;
}

.add-overlay-card {
    position: relative;
    background: var(--color-surface, #fff);
    border-radius: var(--radius-lg, 10px);
    padding: 1.5rem;
    width: 100%;
    max-width: 860px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.add-overlay-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 1rem;
}

.add-overlay-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: var(--color-border, #ddd);
    color: var(--color-text);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.add-overlay-close:hover { background: #c0392b; color: #fff; }

/* ----------------------------------------------------------------
   Responsive additions
---------------------------------------------------------------- */
@media (max-width: 640px) {
    .landing-panels { grid-template-columns: 1fr; }
    .nb-tabbar { top: 0; }
    .nb-toolbar { top: 37px; }
    .drop-zone { min-height: 140px; padding: 1.5rem 1rem; }
    .paste-textarea { min-height: 130px; }
}

