/* ------------------------------------------------------------------
 * Historial de versiones de edición (modal #cardHistoryDialog).
 * Línea de tiempo vertical + detalle de la versión seleccionada.
 * Tokens de tema con fallback inline (frescoTheme no define el contrato).
 * ------------------------------------------------------------------ */

.ch-modal { max-width: 920px; width: 92%; border-radius: 12px; }
.ch-content {
    padding: 0;
    background: var(--bg-base, #ffffff);
    color: var(--text-primary, #263238);
}
.ch-header {
    display: flex; align-items: center; gap: 8px;
    padding: 16px 20px; border-bottom: 1px solid var(--border-divider, #eceff1);
}
.ch-header i.material-icons { color: var(--accent-primary, #1976d2); }
.ch-header h5 { margin: 0; font-size: 1.15rem; font-weight: 600; }

.ch-body { display: flex; min-height: 320px; max-height: 60vh; }

/* Timeline */
.ch-timeline {
    width: 300px; flex-shrink: 0; overflow-y: auto;
    border-right: 1px solid var(--border-divider, #eceff1);
    padding: 12px 8px;
    background: var(--bg-nested, #fafbfc);
}
.ch-item {
    position: relative; display: flex; gap: 10px; cursor: pointer;
    padding: 10px 10px 10px 4px; border-radius: 8px; transition: background .12s ease;
}
.ch-item:hover { background: var(--bg-hover, #eef1f3); }
.ch-item.active { background: var(--accent-active-bg, #e3f2fd); }
.ch-dot {
    width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0;
    background: var(--accent-primary, #1976d2);
    box-shadow: 0 0 0 3px var(--bg-nested, #fafbfc);
}
.ch-item:not(:last-child) .ch-dot::after {
    content: ""; position: absolute; left: 8px; top: 16px; bottom: -10px;
    width: 2px; background: var(--border-default, #cfd8dc);
}
.ch-item-body { flex: 1; min-width: 0; }
.ch-item-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ch-ver { font-weight: 700; font-size: .82rem; color: var(--accent-primary, #1976d2); }
.ch-vtag {
    font-size: .66rem; padding: 0 5px; border-radius: 8px; cursor: help;
    background: var(--bg-elevated, #eceff1); color: var(--text-muted, #90a4ae);
    border: 1px solid var(--border-subtle, #e0e0e0);
}
.ch-user { font-size: .82rem; color: var(--text-primary, #37474f); }
.ch-time { font-size: .72rem; color: var(--text-muted, #90a4ae); margin-left: auto; }
.ch-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.ch-chip {
    font-size: .68rem; padding: 1px 7px; border-radius: 10px;
    background: var(--bg-elevated, #eceff1); color: var(--text-secondary, #546e7a);
    border: 1px solid var(--border-subtle, #e0e0e0);
}

/* Detalle */
.ch-detail { flex: 1; overflow-y: auto; padding: 16px 20px; }
.ch-detail-empty {
    height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--text-muted, #b0bec5); text-align: center;
}
.ch-detail-empty i.material-icons { font-size: 40px; margin-bottom: 6px; }
.ch-detail-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }

.ch-meta { margin-bottom: 18px; }
.ch-meta h6, .ch-snapshot h6 {
    font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
    font-weight: 700; color: var(--text-secondary, #546e7a); margin: 0 0 8px;
}
.ch-meta-row {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 5px 0; border-bottom: 1px dashed var(--border-divider, #eceff1); font-size: .85rem;
}
.ch-meta-label { min-width: 110px; font-weight: 600; color: var(--text-primary, #37474f); }
.ch-from { color: #c62828; text-decoration: line-through; opacity: .8; }
.ch-to { color: #2e7d32; font-weight: 600; }
.ch-meta-row i.material-icons { font-size: 15px; color: var(--text-muted, #90a4ae); }

.ch-snap-field { margin-bottom: 14px; }
.ch-snap-label { font-size: .8rem; font-weight: 600; color: var(--text-secondary, #546e7a); margin-bottom: 4px; }
.ch-snap-content {
    border: 1px solid var(--border-default, #e0e0e0); border-radius: 8px;
    padding: 10px 12px; background: var(--bg-elevated, #ffffff);
    max-height: 260px; overflow-y: auto; font-size: .9rem;
    color: var(--text-primary, #37474f);
}
.ch-snap-content img { max-width: 100%; height: auto; }

/* Campo de contenido modificado + badge */
.ch-snap-changed .ch-snap-label { color: var(--accent-primary, #1976d2); }
.ch-changed-badge {
    display: inline-block; margin-left: 8px; padding: 0 7px; border-radius: 10px;
    font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    background: var(--accent-active-bg, #e3f2fd); color: var(--accent-primary, #1976d2);
    vertical-align: middle;
}

/* Diff a nivel de palabra dentro de editores Quill */
.ch-snap-content ins.ch-ins {
    background: rgba(46, 125, 50, .18); color: #1b5e20; text-decoration: none;
    border-radius: 3px; padding: 0 1px;
}
.ch-snap-content del.ch-del {
    background: rgba(198, 40, 40, .15); color: #b71c1c; text-decoration: line-through;
    border-radius: 3px; padding: 0 1px;
}
.ch-diff-fallback { display: flex; flex-direction: column; gap: 8px; }
.ch-diff-old { opacity: .7; border-left: 3px solid #c62828; padding-left: 8px; }
.ch-diff-new { border-left: 3px solid #2e7d32; padding-left: 8px; }

/* Temas oscuros: realces de diff más legibles */
body[data-theme="black"] .ch-snap-content ins.ch-ins,
body[data-theme="medusa"] .ch-snap-content ins.ch-ins,
body[data-theme="nord"] .ch-snap-content ins.ch-ins {
    background: rgba(129, 199, 132, .22); color: #a5d6a7;
}
body[data-theme="black"] .ch-snap-content del.ch-del,
body[data-theme="medusa"] .ch-snap-content del.ch-del,
body[data-theme="nord"] .ch-snap-content del.ch-del {
    background: rgba(239, 154, 154, .18); color: #ef9a9a;
}

.ch-loading { display: flex; justify-content: center; padding: 30px 0; }
.ch-empty, .ch-error { padding: 20px; text-align: center; font-size: .85rem; }
.ch-error { color: #e53935; }

/* Temas oscuros */
body[data-theme="black"] .ch-content,
body[data-theme="medusa"] .ch-content,
body[data-theme="nord"] .ch-content {
    background: var(--bg-base, #1e1e1e); color: var(--text-primary, #e0e0e0);
}
body[data-theme="black"] .ch-from,
body[data-theme="medusa"] .ch-from,
body[data-theme="nord"] .ch-from { color: #ef9a9a; }
body[data-theme="black"] .ch-to,
body[data-theme="medusa"] .ch-to,
body[data-theme="nord"] .ch-to { color: #a5d6a7; }

@media (max-width: 640px) {
    .ch-body { flex-direction: column; max-height: 70vh; }
    .ch-timeline { width: 100%; max-height: 40vh; border-right: none; border-bottom: 1px solid var(--border-divider, #eceff1); }
}
