/* ===== Polibot Log Viewer v2 ===== */

.plv2-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.65);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10002;
}

.plv2-modal {
    background: #fff;
    color: #212529;
    border-radius: 10px;
    width: 96vw;
    height: 96vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    font-size: 14px;
}

/* --- Header --- */
.plv2-header {
    border-bottom: 1px solid #dee2e6;
    padding: 12px 16px 8px;
    flex-shrink: 0;
}

.plv2-header-top {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.plv2-header-top h3 {
    margin: 0;
    font-size: 1.15em;
    white-space: nowrap;
}

.plv2-v2tag {
    font-size: 0.7em;
    background: #6f42c1;
    color: #fff;
    border-radius: 4px;
    padding: 2px 6px;
    vertical-align: middle;
}

.plv2-v1-link {
    font-size: 0.6em;
    font-weight: 400;
    margin-left: 10px;
    text-decoration: underline;
    color: #6c757d;
    vertical-align: middle;
}

.plv2-header-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.plv2-search {
    margin-left: auto;
    padding: 5px 10px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    min-width: 200px;
    font-size: 13px;
    background: #fff;
    color: inherit;
}

.plv2-copy-all {
    border: 1px solid #ced4da;
    background: none;
    color: inherit;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}
.plv2-copy-all:hover { background: #f0f0f0; }
.plv2-copy-all.plv2-copied { border-color: #28a745; color: #28a745; }

[data-bs-theme="dark"] .plv2-copy-all { border-color: #444; }
[data-bs-theme="dark"] .plv2-copy-all:hover { background: #333; }

.plv2-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    line-height: 1;
}
.plv2-close:hover { background: #f0f0f0; }

/* --- Pipeline --- */
.plv2-pipeline {
    margin-top: 8px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 11px;
}

.plv2-pipe-step {
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}
.plv2-pipe-done { background: #d1e7dd; color: #0f5132; }
.plv2-pipe-planned { background: #fff3cd; color: #664d03; }
.plv2-pipe-arrow { color: #adb5bd; }

/* --- Body layout --- */
.plv2-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

.plv2-nav {
    width: 320px;
    flex-shrink: 0;
    overflow-y: auto;
    border-right: 1px solid #dee2e6;
    background: #f8f9fa;
    padding: 6px 0;
}

.plv2-nav-item {
    padding: 7px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    border-left: 3px solid transparent;
    line-height: 1.3;
}
.plv2-nav-item:hover { background: #e9ecef; }
.plv2-nav-item.active {
    background: #e7f1ff;
    border-left-color: #0d6efd;
}

.plv2-nav-step {
    font-size: 12px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.plv2-nav-meta {
    font-size: 11px;
    color: #6c757d;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.plv2-nav-sub { padding-left: 26px; }
.plv2-nav-sub .plv2-nav-step { font-weight: 400; }
.plv2-nav-group .plv2-caret { margin-left: 4px; }

.plv2-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #adb5bd;
}
.plv2-dot-ok { background: #28a745; }
.plv2-dot-warn { background: #ffc107; }
.plv2-dot-err { background: #dc3545; }

/* --- Detail pane --- */
.plv2-detail {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    min-width: 0;
}

.plv2-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 8px;
}
.plv2-detail-head h4 { margin: 0; font-size: 1.05em; }
.plv2-detail-meta { display: flex; gap: 6px; }

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

.plv2-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6c757d;
    margin-bottom: 6px;
    cursor: default;
}
.plv2-section details > summary.plv2-section-title,
.plv2-section summary.plv2-section-title { cursor: pointer; }

.plv2-pre {
    background: #f5f5f5;
    border-radius: 6px;
    padding: 10px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 60vh;
    overflow-y: auto;
    font-size: 12px;
    margin: 0;
}

.plv2-richtext { overflow-wrap: anywhere; }
.plv2-richtext pre {
    background: #f5f5f5;
    border-radius: 6px;
    padding: 10px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.plv2-thinking {
    font-style: italic;
    color: #6c757d;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: #fbfbfd;
    border-left: 3px solid #ced4da;
    padding: 8px 12px;
    border-radius: 0 6px 6px 0;
}

.plv2-answer {
    background: #fdfdfd;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 16px;
}

.plv2-empty { color: #adb5bd; font-style: italic; }

/* --- Tabela akcji pre/postprocessingu --- */
.plv2-actions-table {
    width: 100%;
    max-width: 900px;
    border-collapse: collapse;
    font-size: 12.5px;
}
.plv2-actions-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: top;
}
.plv2-action-name { width: 35%; font-weight: 600; overflow-wrap: anywhere; }
.plv2-action-line { color: #6c757d; }
.plv2-action-line.plv2-action-hit { color: #d39e00; font-weight: 600; }
.plv2-action-src { font-weight: 600; color: inherit; }

[data-bs-theme="dark"] .plv2-actions-table td { border-bottom-color: #333; }

/* --- Raport pod odpowiedzią --- */
.plv2-report {
    margin-top: 20px;
    border-top: 1px solid #dee2e6;
    padding-top: 14px;
    max-width: 900px;
}

.plv2-time-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.plv2-time-table td { padding: 3px 6px; vertical-align: middle; }
.plv2-tt-name { width: 32%; overflow-wrap: anywhere; }
.plv2-tt-bar { width: 48%; }
.plv2-tt-time { width: 10%; text-align: right; white-space: nowrap; color: #6c757d; }
.plv2-tt-pct { width: 10%; text-align: right; white-space: nowrap; color: #6c757d; }

.plv2-bar {
    height: 12px;
    border-radius: 3px;
    background: linear-gradient(90deg, #0d6efd, #6f42c1);
    min-width: 2px;
}

.plv2-cost-table { border-collapse: collapse; font-size: 12px; }
.plv2-cost-table td { padding: 3px 14px 3px 0; }
.plv2-cost-table td:last-child { text-align: right; font-family: monospace; }
.plv2-cost-total td { font-weight: 700; border-top: 1px solid #dee2e6; }

[data-bs-theme="dark"] .plv2-report { border-top-color: #333; }
[data-bs-theme="dark"] .plv2-cost-total td { border-top-color: #444; }

/* --- Badges --- */
.plv2-badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 5px;
    background: #6c757d;
    color: #fff;
    white-space: nowrap;
}
.plv2-badge-ok { background: #28a745; }
.plv2-badge-warn { background: #d39e00; }
.plv2-badge-err { background: #dc3545; }
.plv2-badge-agent { background: #17a2b8; }

.plv2-tool-head { margin-bottom: 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.plv2-tool-error { color: #dc3545; width: 100%; }

/* Nagłówki markdown w treściach nie mogą rozsadzać layoutu */
.plv2-detail h1, .plv2-detail h2, .plv2-detail h3,
.plv2-detail h5, .plv2-detail h6 {
    font-size: 1em;
    font-weight: bold;
    margin: 0.5em 0;
}

/* ===== Dark mode ===== */
[data-bs-theme="dark"] .plv2-modal { background: #1e1e1e; color: #e0e0e0; }
[data-bs-theme="dark"] .plv2-header { border-bottom-color: #333; }
[data-bs-theme="dark"] .plv2-search { background: #2a2a2a; border-color: #444; color: #e0e0e0; }
[data-bs-theme="dark"] .plv2-close { color: #aaa; }
[data-bs-theme="dark"] .plv2-close:hover { background: #333; }
[data-bs-theme="dark"] .plv2-nav { background: #181818; border-right-color: #333; }
[data-bs-theme="dark"] .plv2-nav-item:hover { background: #262626; }
[data-bs-theme="dark"] .plv2-nav-item.active { background: #1c2c44; }
[data-bs-theme="dark"] .plv2-detail-head { border-bottom-color: #333; }
[data-bs-theme="dark"] .plv2-pre,
[data-bs-theme="dark"] .plv2-richtext pre { background: #2a2a2a; color: #e0e0e0; }
[data-bs-theme="dark"] .plv2-thinking { background: #222; border-left-color: #444; }
[data-bs-theme="dark"] .plv2-answer { background: #1e2530; border-color: #444c56; }
[data-bs-theme="dark"] .plv2-pipe-done { background: #14361f; color: #7ee2a8; }
[data-bs-theme="dark"] .plv2-pipe-planned { background: #3a3020; color: #ffd97a; }
