/* Tool Panels - Inline document embeds
 *
 * Design: Documents sitting on the page
 * - White surface with subtle shadow
 * - Tufte typography inside
 * - Quiet interactions
 */

/* ============================================
   BASE PANEL - The document surface
   ============================================ */

.tool-panel {
    margin: 1.4rem 0;
    padding: 1.25rem 1.5rem;
    background: #fff;
    border: 1px solid #e8e8e4;
    border-radius: 3px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    font-family: et-book, Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: 1.1rem;
    line-height: 1.6;
}

/* Hide scrollbars but keep scrolling */
.tool-panel {
    scrollbar-width: none; /* Firefox */
}

.tool-panel ::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

/* ============================================
   PANEL HEADER
   ============================================ */

.tool-panel-header {
    padding: 0;
    margin-bottom: 0.5rem;
    background: transparent;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    cursor: pointer;
    user-select: none;
}

.tool-panel-title {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tool-panel-title .tool-icon {
    font-size: 0.9rem;
    opacity: 0.6;
}

.tool-panel-title .file-path {
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.95rem;
    color: #111;
}

.tool-panel-title .tool-type {
    font-variant: small-caps;
    font-size: 1rem;
    letter-spacing: 0.05em;
    color: #888;
}

/* ============================================
   PANEL ACTIONS - Text links, not buttons
   ============================================ */

.tool-panel-actions {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

.tool-panel-actions button {
    padding: 0;
    font-family: et-book, Palatino, Georgia, serif;
    font-size: 0.9rem;
    color: #888;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: color 0.15s ease;
}

.tool-panel-actions button:hover {
    color: #111;
}

/* ============================================
   COLLAPSE TOGGLE
   ============================================ */

.tool-panel-toggle {
    font-size: 0.75rem;
    color: #aaa;
    transition: transform 0.2s ease;
    display: inline-block;
}

.tool-panel.collapsed .tool-panel-toggle {
    transform: rotate(-90deg);
}

/* ============================================
   PANEL CONTENT
   ============================================ */

.tool-panel-content {
    padding: 0;
    max-height: 400px;
    overflow-y: auto;
}

.tool-panel.collapsed .tool-panel-content {
    display: none;
}

/* ============================================
   CODE BLOCKS - For file panels
   ============================================ */

.code-block {
    background: #f9f9f7;
    border-radius: 2px;
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    overflow-x: auto;
}

.code-block pre {
    margin: 0;
    padding: 0.75rem;
    white-space: pre;
}

.code-line {
    display: block;
}

.line-number {
    display: inline-block;
    width: 3em;
    padding-right: 1em;
    text-align: right;
    color: #aaa;
    user-select: none;
    border-right: 1px solid #e8e8e6;
    margin-right: 1em;
}

/* ============================================
   DIFF BLOCKS - For edit panels
   ============================================ */

.diff-block {
    background: #f9f9f7;
    border-radius: 2px;
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    overflow-x: auto;
}

.diff-line {
    display: block;
    padding: 0 0.75rem;
}

.diff-line.added {
    background: #eef9ee;
}

.diff-line.removed {
    background: #fcf0f0;
}

.diff-line.context {
    background: transparent;
}

.diff-line .diff-marker {
    display: inline-block;
    width: 1.5em;
    color: #888;
    user-select: none;
}

.diff-line.added .diff-marker {
    color: #4a8;
}

.diff-line.removed .diff-marker {
    color: #b66;
}

/* ============================================
   SUMMARY & NOTICES
   ============================================ */

.tool-panel-summary {
    font-size: 0.95rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.truncation-notice {
    font-size: 0.9rem;
    color: #888;
    font-style: italic;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid #eee;
}

/* ============================================
   ERROR STATE
   ============================================ */

.tool-panel.error {
    box-shadow: 0 1px 4px rgba(180, 100, 100, 0.15);
}

.tool-panel.error .tool-panel-header {
    color: #a55;
}

/* ============================================
   SKEIN PANELS - Document folios
   ============================================ */

.skein-panel {
    /* Inherits base .tool-panel styles */
}

.skein-panel .folio-id {
    font-family: et-book, Palatino, Georgia, serif;
    font-size: 1.05rem;
    color: #333;
}

.skein-panel .folio-site {
    font-size: 0.9rem;
    color: #888;
    font-style: italic;
}

/* Folio type - small caps label, not a badge */
.folio-type-badge {
    display: block;
    font-family: et-book, Palatino, Georgia, serif;
    font-variant: small-caps;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    color: #666;
    margin-bottom: 0.25rem;
    background: none;
    padding: 0;
    border-radius: 0;
}

/* Subtle color hints for type - just text color, no background */
.folio-type-badge.issue {
    color: #966;
}

.folio-type-badge.finding {
    color: #668;
}

.folio-type-badge.friction {
    color: #986;
}

.folio-type-badge.notion {
    color: #886;
}

.folio-type-badge.summary {
    color: #686;
}

.folio-type-badge.brief {
    color: #768;
}

.folio-type-badge.question {
    color: #668;
}

.folio-type-badge.answer {
    color: #686;
}

/* Brief handoff box */
.skein-brief .handoff-box {
    background: #f8f8f8;
    border-radius: 2px;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
}

.skein-brief .handoff-box code {
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.95rem;
    color: #555;
}

/* SKEIN Show panel */
.skein-show .folio-status {
    font-size: 0.9rem;
    font-style: italic;
    margin-left: 0.5rem;
    color: #888;
}

.skein-show .folio-status.open {
    color: #686;
}

.skein-show .folio-status.closed {
    color: #999;
}

.skein-show .folio-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 0.75rem;
}

.skein-show .meta-item {
    display: inline-block;
}

.skein-show .folio-content {
    background: #f9f9f7;
    border-radius: 2px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

/* SKEIN Folios list panel */
.skein-folios .site-id {
    font-family: et-book, Palatino, Georgia, serif;
    font-size: 1.05rem;
    color: #333;
}

.skein-folios .folio-count {
    font-size: 0.9rem;
    color: #888;
    font-style: italic;
    margin-left: 0.5rem;
}

.folio-group {
    margin-bottom: 1rem;
}

.folio-group-header {
    font-variant: small-caps;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    color: #666;
    margin-bottom: 0.35rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #eee;
}

.folio-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.folio-item {
    display: flex;
    flex-direction: column;
    padding: 0.4rem 0;
    border-bottom: 1px dotted #e8e8e6;
}

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

.folio-item-id {
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.8rem;
    color: #888;
}

.folio-item-title {
    font-size: 0.95rem;
    color: #333;
    margin-top: 0.15rem;
}

.folio-item.closed .folio-item-id,
.folio-item.closed .folio-item-title {
    color: #aaa;
    text-decoration: line-through;
}

.folio-more {
    font-size: 0.9rem;
    color: #888;
    font-style: italic;
    padding-top: 0.35rem;
}

.empty-state {
    font-size: 0.95rem;
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

/* ============================================
   BASH PANELS - Terminal transcript as document
   ============================================ */

.bash-panel {
    /* Inherits base .tool-panel styles */
}

.bash-panel .tool-panel-header {
    margin-bottom: 0;
}

.bash-panel .tool-panel-title {
    gap: 0.35rem;
}

/* The prompt character */
.bash-prompt {
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.95rem;
    color: #888;
    user-select: none;
}

/* The command itself */
.bash-command {
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.95rem;
    color: #333;
    word-break: break-all;
}

/* Command output */
.bash-output {
    margin: 0.75rem 0 0.5rem 0;
    padding: 0.75rem;
    background: #f9f9f7;
    border-radius: 2px;
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

/* Exit status indicator */
.bash-exit {
    display: inline-block;
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.bash-exit.success {
    color: #4a8;
}

.bash-exit.error {
    color: #b55;
}

/* Error state - subtle red tint */
.bash-panel.bash-error {
    border-left: 3px solid #c66;
}

.bash-panel.bash-error .bash-output {
    background: #fdf8f8;
}

/* ============================================
   BASH APPROVAL STATES
   ============================================ */

/* Approval required - amber/yellow tint */
.bash-panel.bash-approval {
    border-left: 3px solid #c90;
    background: #fffdf5;
}

.bash-panel.bash-approval .bash-command {
    color: #664400;
}

/* Destructive commands - red warning */
.bash-panel.bash-destructive {
    border-left: 3px solid #c44;
    background: #fef8f8;
}

.bash-panel.bash-destructive .bash-command {
    color: #733;
}

/* Tier badge (approval required / destructive) */
.bash-tier-badge {
    font-family: et-book, Palatino, Georgia, serif;
    font-variant: small-caps;
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    color: #996600;
    margin-left: 0.5rem;
}

.bash-panel.bash-destructive .bash-tier-badge {
    color: #933;
}

/* Approval notice box */
.bash-approval-notice {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.approval-status {
    color: #886600;
}

.approval-flag {
    font-size: 0.8rem;
    color: #888;
    font-style: italic;
}

.bash-request-id {
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.35rem;
}

/* Approval action buttons */
.bash-approval-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
}

.approval-btn {
    padding: 0.4rem 1.25rem;
    font-family: et-book, Palatino, Georgia, serif;
    font-size: 0.9rem;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.approval-btn.approve {
    background: #f0faf0;
    border: 1px solid #4a8;
    color: #2a6;
}

.approval-btn.approve:hover {
    background: #e0f5e0;
    border-color: #3a7;
}

.approval-btn.reject {
    background: #faf5f5;
    border: 1px solid #b88;
    color: #966;
}

.approval-btn.reject:hover {
    background: #f5e8e8;
    border-color: #a77;
}

.approval-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Approved state */
.bash-panel.bash-approved {
    border-left: 3px solid #4a8;
    background: #f8fcf8;
}

.bash-panel.bash-approved .approval-status {
    color: #3a7;
}

/* Rejected state */
.bash-panel.bash-rejected {
    border-left: 3px solid #999;
    background: #fafafa;
}

.bash-panel.bash-rejected .approval-status {
    color: #888;
}

.bash-panel.bash-rejected .bash-command {
    text-decoration: line-through;
    color: #999;
}

/* ============================================
   CAST PANELS - Primus-style with margin figure
   ============================================ */

.cast-panel {
    position: relative;
    margin: 1.4rem 0;
    font-family: et-book, Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

/* Name styled like Primus */
.cast-name {
    font-weight: normal;
    font-style: italic;
    font-size: 1.8rem;
    line-height: 1;
    color: #111;
    margin-bottom: 0;
}

/* Content styled like message-content */
.cast-content {
    font-size: 1.4rem;
    line-height: 2rem;
    color: #111;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Meta line - subtle */
.cast-meta {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #999;
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

/* Margin figure - card in right margin */
.cast-figure {
    position: absolute;
    left: calc(100% + 2rem);
    top: 0;
    width: 140px;
    margin: 0;
    text-align: center;
}

.cast-figure img {
    width: 140px;
    height: auto;
    border-radius: 3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cast-card-link {
    display: block;
}

.cast-card-link:hover img {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cast-figure figcaption {
    font-size: 0.9rem;
    font-style: italic;
    line-height: 1.4;
    color: #666;
    margin-top: 0.5rem;
}

/* Status colors */
.cast-panel.cast-complete .cast-figure figcaption {
    color: #4a8;
}

.cast-panel.cast-failed .cast-figure img {
    filter: grayscale(40%);
    opacity: 0.8;
}

.cast-panel.cast-failed .cast-figure figcaption {
    color: #b55;
}

.cast-panel.cast-working .cast-figure figcaption {
    color: #c90;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .tool-panel {
        margin: 1rem 0;
        padding: 0.75rem 1rem;
    }

    .tool-panel-content {
        max-height: 250px;
    }

    .tool-panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    .tool-panel-actions {
        width: 100%;
        justify-content: flex-start;
        margin-top: 0.25rem;
    }

    .tool-panel-actions button {
        opacity: 1; /* Always visible on mobile */
    }

    /* Cast panels - hide margin figure on mobile */
    .cast-figure {
        display: none;
    }

    .cast-name {
        font-size: 1.4rem;
    }

    .cast-content {
        font-size: 1.2rem;
        line-height: 1.6rem;
    }
}

/* ============================================
   MANTLE CHANGE PANEL - Card display on mantle switch
   ============================================ */

.mantle-change-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin: 1.5rem auto;
    padding: 1.5rem 2rem;
    max-width: fit-content;
}

.mantle-info {
    text-align: left;
}

.mantle-title {
    font-family: et-book, Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: 2rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.mantle-description {
    font-family: et-book, Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: 1.1rem;
    font-style: italic;
    line-height: 1.5;
    color: #666;
    max-width: 300px;
}

.mantle-figure {
    flex-shrink: 0;
    margin: 0;
}

.mantle-figure img {
    width: 100px;
    height: auto;
    border-radius: 3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ============================================
   COMMAND RESULTS
   ============================================ */

.command-result {
    margin: 0.75rem 0;
    padding: 0.75rem 1rem;
    background: #f8f8f4;
    border-left: 3px solid #888;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    border-radius: 0 3px 3px 0;
}

.command-result.command-error {
    border-left-color: #c00;
    background: #fef8f8;
}

.command-echo {
    color: #666;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.command-output {
    color: #333;
    white-space: pre-wrap;
    word-break: break-word;
}

.command-output pre {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    white-space: pre-wrap;
    word-break: break-word;
}

.command-error .command-output {
    color: #900;
}
