/* === WIDGETS.CSS === public/assets/css/widgets.css — компоненты таблиц, карточек, детали, ~250 строк */

/* Tooltip */
.has-tooltip { cursor: help; }

#zk-tooltip {
    position: fixed;
    z-index: 9999;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    line-height: 1.6;
    padding: 8px 12px;
    border-radius: 6px;
    width: 240px;
    box-shadow: 0 4px 20px rgba(0,0,0,.35);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s;
}

/* Call list item */
.call-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.1s;
}
.call-item:hover  { background: var(--card-bg-hover); }
.call-item.active { background: color-mix(in oklch, var(--color-accent) 10%, transparent); border-left: 2px solid var(--color-accent); }

.call-item-row1 {
    display: flex;
    align-items: center;
    gap: 6px;
}
.call-manager {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1 1 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.call-date {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
.call-item-row2 {
    display: flex;
    align-items: center;
    gap: 6px;
}
.call-filename {
    font-size: 11px;
    color: var(--text-muted);
    flex: 1 1 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Detail panel */
.detail-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 12px;
    flex-direction: column;
    gap: 8px;
}

.detail-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}
.detail-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1 1 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.detail-meta {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Field rows */
.field-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 3px 0;
    border-bottom: 1px solid color-mix(in oklch, var(--border-color) 50%, transparent);
    font-size: 12px;
}
.field-label {
    flex: 0 0 110px;
    color: var(--text-muted);
    font-size: 11px;
}
.field-value {
    flex: 1 1 0;
    color: var(--text-primary);
    word-break: break-word;
}

/* Transcript */
.transcript-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}
.transcript-text::-webkit-scrollbar { width: 3px; }
.transcript-text::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

/* Script checks */
.checks-list { display: flex; flex-direction: column; gap: 4px; }
.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding: 3px 0;
}
.check-icon { flex: 0 0 16px; text-align: center; }
.check-ok   { color: var(--color-success); }
.check-fail { color: var(--color-danger); }
.check-key  { flex: 1 1 0; color: var(--text-secondary); }
.check-score { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.check-evidence { font-size: 11px; color: var(--text-muted); margin-left: 24px; font-style: italic; }

/* Progress bar */
.score-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
}
.score-bar-track {
    flex: 1 1 0;
    height: 5px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}
.score-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--color-success);
    transition: width 0.4s var(--ease-out-quart);
}
.score-bar-fill.warn { background: var(--color-warning); }
.score-bar-fill.danger { background: var(--color-danger); }
.score-val { font-size: 12px; font-weight: 700; color: var(--text-primary); white-space: nowrap; min-width: 36px; text-align: right; }

/* Mistakes list */
.mistake-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.1s;
}
.mistake-row:hover { background: var(--card-bg-hover); }
.mistake-row-top {
    display: flex;
    align-items: center;
    gap: 8px;
}
.mistake-type {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1 1 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mistake-manager {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
.mistake-date { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.mistake-evidence {
    font-size: 11px;
    color: var(--text-secondary);
    font-style: italic;
    margin-left: 0;
    line-height: 1.5;
}
.mistake-rec {
    font-size: 11px;
    color: var(--color-info);
    line-height: 1.5;
}

/* Metrics table */
.metrics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.metrics-table th {
    text-align: left;
    padding: 6px 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
}
.metrics-table td {
    padding: 6px 10px;
    border-bottom: 1px solid color-mix(in oklch, var(--border-color) 50%, transparent);
    color: var(--text-primary);
    white-space: nowrap;
}
.metrics-table tr:hover td { background: var(--card-bg-hover); }
.metrics-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Speech ratio bar — compact (список) */
.speech-bar {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    width: 100px;
    background: var(--border-color);
    margin-bottom: 3px;
}
.speech-manager { background: var(--color-info); }
.speech-client  { background: var(--color-warning); }

/* Speech ratio bar — wide (детали) */
.speech-bar-wide {
    display: flex;
    height: 20px;
    border-radius: 4px;
    overflow: hidden;
    width: 160px;
    background: var(--border-color);
}
.speech-bar-wide .speech-manager,
.speech-bar-wide .speech-client {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    min-width: 0;
    overflow: hidden;
}
.speech-bar-wide .speech-manager { background: var(--color-info); }
.speech-bar-wide .speech-client  { background: var(--color-warning); }

/* Objections list */
.objections-list {
    margin: 0;
    padding: 0 0 0 16px;
}
.objections-list li {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 3px 0;
    border-bottom: 1px solid color-mix(in oklch, var(--border-color) 40%, transparent);
}
.objections-list li:last-child { border-bottom: none; }
.metrics-table .manager-cell { font-weight: 600; }

/* Score cell coloring */
.score-good  { color: var(--color-success); font-weight: 600; }
.score-ok    { color: var(--color-warning); font-weight: 600; }
.score-bad   { color: var(--color-danger);  font-weight: 600; }

/* Chart container */
.chart-wrap {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
    overflow: hidden;
}
/* Dialog по ролям */
.dialog-wrap { display: flex; flex-direction: column; gap: 6px; }
.dialog-row { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 1.5; }
.dialog-role { flex: 0 0 120px; font-weight: 600; font-size: 11px; padding-top: 2px; white-space: nowrap; }
.dialog-text { flex: 1; color: var(--text-primary); }
.dialog-manager .dialog-role { color: var(--color-accent); }
.dialog-client .dialog-role { color: var(--text-muted); }
.dialog-manager .dialog-text { background: var(--bg-secondary); padding: 4px 8px; border-radius: 6px; }

.chart-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* ===== ANALYTICS TAB ===== */
.analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
    overflow-y: auto;
    flex: 1 1 0;
}
.analytics-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
    overflow: hidden;
}
.analytics-card.wide {
    grid-column: 1 / -1;
}
.analytics-card-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Conflict badge — пульсирующий */
.badge-conflict {
    background: var(--color-danger);
    color: #fff;
    animation: conflict-pulse 1.8s ease-in-out infinite;
    font-weight: 700;
}
@keyframes conflict-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.55; }
}

/* Category badge */
.badge-category {
    background: color-mix(in oklch, var(--color-info) 15%, transparent);
    color: var(--color-info);
    border: 1px solid color-mix(in oklch, var(--color-info) 30%, transparent);
    font-size: 10px;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Call duration в списке */
.call-duration {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

/* ---- Модалка неактивности ---- */
.idle-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    backdrop-filter: blur(3px);
}
.idle-modal-overlay.visible {
    opacity: 1;
    pointer-events: all;
}
.idle-modal-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 32px 36px;
    width: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    box-shadow: 0 24px 60px rgba(0,0,0,.4);
    transform: translateY(10px);
    transition: transform 0.2s;
}
.idle-modal-overlay.visible .idle-modal-box {
    transform: translateY(0);
}
.idle-modal-icon {
    color: var(--color-warning);
    display: flex;
}
.idle-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
}
.idle-modal-sub {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.7;
}
.idle-countdown {
    display: inline-block;
    font-size: 28px;
    font-weight: 700;
    color: var(--color-danger);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin: 4px 0;
}
.idle-modal-btn {
    margin-top: 4px;
    padding: 10px 32px;
    background: var(--color-accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.idle-modal-btn:hover { opacity: 0.85; }

/* Audio speed control */
.audio-speed-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 7px;
}
.audio-speed-label {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
.audio-speed-slider {
    flex: 1;
    height: 4px;
    accent-color: var(--color-accent);
    cursor: pointer;
}
.audio-speed-val {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-accent);
    min-width: 28px;
    text-align: right;
}
