/* Sailor host layout around the reusable embedded chat panel. */

.tl-page {
    display: flex;
    gap: 16px;
    height: calc(100vh - 100px);
}

.tl-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tl-sidebar-header {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tl-sidebar-new {
    flex-grow: 1;
}

.tl-sidebar-loading,
.tl-sidebar-empty {
    padding: 16px;
    color: #6c757d;
    text-align: center;
}

/* Inline failure notice for a sidebar action (currently "+ New chat").
   Deliberately in-place rather than a toast: the action that failed is
   right above it, and the circuit no longer dies to make the point. */
.tl-sidebar-error {
    margin: 8px 12px;
    padding: 8px 10px;
    border: 1px solid #f5c2c7;
    border-radius: 6px;
    background: #f8d7da;
    color: #842029;
    font-size: 0.8rem;
    line-height: 1.4;
}

[data-theme="dark"] .tl-sidebar-error {
    background: #3b1414;
    border-color: #7f1d1d;
    color: #fecaca;
}

.tl-sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex-grow: 1;
}

.tl-sidebar-item {
    padding: 12px 14px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: background-color 0.1s ease;
    /* flex row so the rename action can sit at the trailing edge */
    display: flex;
    align-items: center;
    gap: 8px;
}

.tl-sidebar-item:hover {
    background: #e9ecef;
}

.tl-sidebar-item.active {
    background: #cfe2ff;
    border-left: 3px solid #0d6efd;
}

/* Holds the stacked title + timestamp; min-width:0 lets the title ellipsis. */
.tl-sidebar-item-main {
    flex: 1 1 auto;
    min-width: 0;
}

.tl-sidebar-item-title {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tl-sidebar-item-time {
    color: #6c757d;
}

/* Pencil button — hidden until the row is hovered or the button is focused
   (keyboard users still reach it), so the list stays clean at rest. */
.tl-sidebar-item-rename {
    flex: 0 0 auto;
    background: none;
    border: none;
    color: #6c757d;
    padding: 4px 6px;
    border-radius: 4px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.1s ease, background-color 0.1s ease, color 0.1s ease;
}

.tl-sidebar-item:hover .tl-sidebar-item-rename,
.tl-sidebar-item-rename:focus-visible {
    opacity: 1;
}

.tl-sidebar-item-rename:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #212529;
}

/* Inline edit box shown in place of the title while renaming. */
.tl-sidebar-item-edit {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.95rem;
    padding: 4px 6px;
    border: 1px solid #0d6efd;
    border-radius: 4px;
    outline: none;
}

/* ---- Diagnostic pane (right) -------------------------------------- */

.tl-main-with-logs {
    /* Shrink the main pane when the right-pane diagnostics is open
       so the chat doesn't overflow. */
    flex-grow: 1;
    min-width: 0;
}

.tl-diagnostics {
    width: 36%;
    min-width: 320px;
    max-width: 560px;
    flex-shrink: 0;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tl-diagnostics-header {
    padding: 10px 12px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.tl-diagnostics-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tl-diag-card {
    border: 1px solid #dee2e6;
    border-left-width: 3px;
    border-radius: 4px;
    padding: 6px 8px;
    background: #fff;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.78rem;
}

.tl-diag-card.tl-diag-info { border-left-color: #6c757d; }
.tl-diag-card.tl-diag-warn { border-left-color: #ffc107; background: #fff8e1; }
.tl-diag-card.tl-diag-error { border-left-color: #dc3545; background: #fdf1f2; }

.tl-diag-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    cursor: pointer;
}

.tl-diag-time {
    color: #6c757d;
    font-size: 0.72rem;
}

.tl-diag-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
}

.tl-diag-badge-info { background: #6c757d; }
.tl-diag-badge-warn { background: #ffc107; color: #212529; }
.tl-diag-badge-error { background: #dc3545; }

.tl-diag-tool {
    color: #495057;
}

.tl-diag-toggle {
    margin-left: auto;
    color: #6c757d;
    font-size: 0.7rem;
}

.tl-diag-summary {
    margin-top: 2px;
    color: #495057;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tl-diag-summary.expanded {
    white-space: pre-wrap;
}

.tl-diag-payload {
    margin: 6px 0 0 0;
    padding: 6px 8px;
    background: #f1f3f5;
    border-radius: 4px;
    max-height: 320px;
    overflow: auto;
    font-size: 0.72rem;
    white-space: pre;
}
