/* Replay snapshot feature styles */

.replay-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.replay-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface-elevated, #1e1e2e);
    color: var(--text-primary, #fff);
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.12));
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    font-size: 14px;
    pointer-events: auto;
    animation: replay-toast-in 0.25s ease;
}

.replay-toast--error {
    border-color: #e74c3c;
}

.replay-toast--hide {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s, transform 0.3s;
}

.replay-toast-action {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: inherit;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.replay-toast-action:hover {
    background: rgba(255,255,255,0.08);
}

@keyframes replay-toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.replay-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s;
}

.replay-btn-primary {
    background: var(--color-primary, var(--accent, #6366f1));
    color: #fff;
}

.replay-btn-secondary {
    background: var(--surface-muted, rgba(255,255,255,0.06));
    color: var(--text-primary, inherit);
    border-color: var(--border-subtle, rgba(255,255,255,0.12));
}

.replay-btn-muted {
    background: transparent;
    color: var(--text-secondary, #888);
    border-color: var(--border-subtle, rgba(255,255,255,0.08));
}

.replay-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent, #6366f1);
    margin-right: 4px;
}

.replay-badge--error {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

.replay-privacy-note {
    font-size: 11px;
    color: var(--text-secondary, #888);
    padding: 8px 10px;
    background: var(--surface-muted, rgba(255,255,255,0.04));
    border-radius: 8px;
    margin-top: 8px;
    margin-bottom: 0;
}

.snapshot-library-toolbar {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px 12px;
    margin-bottom: 12px;
}

.snapshot-library-toolbar--meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
    margin-bottom: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

/* Search + sort row */
.snapshot-library-search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 220px;
    min-width: 0;
}

.snapshot-library-search-icon {
    position: absolute;
    left: 10px;
    display: inline-flex;
    color: var(--text-secondary, #888);
    pointer-events: none;
}

.snapshot-library-search-input {
    width: 100%;
    padding: 9px 30px 9px 32px;
    font-size: 13px;
    color: var(--text-primary, inherit);
    background: var(--surface-muted, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
    border-radius: 9px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.snapshot-library-search-input:focus {
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.snapshot-library-search-input::-webkit-search-cancel-button {
    display: none;
}

.snapshot-library-search-clear {
    position: absolute;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary, #888);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.snapshot-library-search-clear:hover {
    background: var(--surface-elevated, rgba(255, 255, 255, 0.08));
    color: var(--text-primary, inherit);
}

.snapshot-library-sort {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.snapshot-library-sort-label {
    font-size: 12px;
    color: var(--text-secondary, #888);
}

.snapshot-library-sort-select {
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text-primary, inherit);
    background: var(--surface-muted, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
    border-radius: 9px;
    cursor: pointer;
    outline: none;
}

.snapshot-library-sort-select:focus {
    border-color: rgba(99, 102, 241, 0.6);
}

.snapshot-library-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #888);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.snapshot-library-toolbar-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.snapshot-library-toolbar-actions .replay-btn {
    padding: 5px 10px;
    font-size: 12px;
}

/* Time-bucketed groups */
.snapshot-library-group + .snapshot-library-group {
    margin-top: 18px;
}

.snapshot-library-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #888);
    margin-bottom: 10px;
}

.snapshot-library-group-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--surface-elevated, rgba(255, 255, 255, 0.06));
    color: var(--text-secondary, #888);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0;
}

.snapshot-library-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.snapshot-library-group .snapshot-library-card + .snapshot-library-card {
    margin-top: 12px;
}

.snapshot-library-card {
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
    border-radius: 12px;
    padding: 16px;
    background: var(--surface-muted, rgba(255,255,255,0.03));
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    cursor: pointer;
    outline: none;
}

.snapshot-library-card:hover {
    border-color: rgba(99, 102, 241, 0.35);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.snapshot-library-card:focus-visible {
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.snapshot-library-card:active {
    transform: translateY(1px);
}

.snapshot-library-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 6px;
}

.snapshot-library-card-title-block {
    min-width: 0;
}

.snapshot-library-card-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.3;
}

.snapshot-library-card-relative {
    font-size: 12px;
    color: var(--text-secondary, #888);
    margin-top: 2px;
}

.snapshot-library-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.snapshot-library-card-session {
    font-size: 12px;
    color: var(--text-secondary, #888);
    margin-bottom: 8px;
}

.snapshot-library-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.snapshot-library-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    color: var(--text-secondary, #888);
    background: var(--surface-elevated, rgba(255,255,255,0.05));
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
}

.snapshot-library-stat-pill-value {
    font-weight: 600;
    color: var(--text-primary, inherit);
}

.snapshot-library-card-summary {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    line-height: 1.4;
}

.snapshot-library-card-preview {
    font-size: 12px;
    color: var(--text-secondary, #888);
    margin-bottom: 4px;
    line-height: 1.45;
}

.snapshot-library-card-preview-label {
    font-weight: 600;
    color: var(--text-primary, inherit);
    opacity: 0.75;
}

.snapshot-library-card-journey {
    font-size: 12px;
    color: var(--text-secondary, #888);
    margin-bottom: 4px;
}

.snapshot-library-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
}

.snapshot-library-action-view {
    flex: 0 0 auto;
}

.snapshot-library-icon-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.snapshot-library-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary, #888);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.snapshot-library-icon-btn:hover {
    background: var(--surface-elevated, rgba(255, 255, 255, 0.06));
    color: var(--text-primary, inherit);
    border-color: rgba(99, 102, 241, 0.4);
}

.snapshot-library-icon-btn--danger:hover {
    color: #e74c3c;
    border-color: rgba(231, 76, 60, 0.5);
    background: rgba(231, 76, 60, 0.08);
}

.replay-badge--journey {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
}

.snapshot-library-empty,
.snapshot-library-loading,
.replay-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-secondary, #888);
    font-size: 14px;
}

.snapshot-library-empty-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.snapshot-library-empty-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, inherit);
    margin: 0 0 6px;
}

.snapshot-library-empty-text {
    font-size: 13px;
    margin: 0;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

#replay-capture-indicator,
.replay-logging-indicator {
    display: none;
    font-size: 12px;
    font-weight: 500;
    color: #b45309;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(245, 158, 11, 0.45);
    background: rgba(245, 158, 11, 0.12);
    white-space: nowrap;
    cursor: pointer;
    line-height: 1.3;
    font-family: inherit;
}

#replay-capture-indicator.is-visible,
.replay-logging-indicator.is-visible {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.replay-logging-indicator.is-enabled::before {
    content: '⚠';
    font-size: 11px;
    line-height: 1;
}

.replay-logging-indicator.is-disabled {
    color: var(--text-secondary, #888);
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(148, 163, 184, 0.1);
}

.replay-logging-indicator.is-disabled::before {
    content: none;
}

.replay-logging-indicator:hover {
    filter: brightness(0.97);
}

.replay-logging-indicator:focus-visible {
    outline: 2px solid rgba(245, 158, 11, 0.55);
    outline-offset: 2px;
}

.replay-library-export-btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

.conversation-replay-viewer {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.replay-viewer-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

.replay-viewer-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    font-size: 13px;
    margin-bottom: 0;
}

.replay-viewer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.replay-redact-label {
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary, #888);
    margin-right: auto;
}

.replay-tab-bar {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    margin-bottom: 14px;
    padding-bottom: 0;
}

.replay-tab-bar::-webkit-scrollbar {
    display: none;
}

.replay-tab {
    flex-shrink: 0;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #888);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.replay-tab.is-active {
    background: transparent;
    color: var(--color-primary, var(--accent, #6366f1));
    border-bottom-color: var(--color-primary, var(--accent, #6366f1));
}

.replay-tab-panels {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.replay-tab-panel {
    display: none;
}

.replay-tab-panel.is-active {
    display: block;
}

.replay-overview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.replay-stat-card {
    padding: 10px 8px;
    border-radius: 8px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    background: var(--bg-card, var(--surface-muted, rgba(255,255,255,0.04)));
    text-align: center;
}

.replay-stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
}

.replay-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
    color: var(--text-secondary, #888);
}

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

.replay-section h3,
.replay-section h4 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #888);
    margin: 0 0 8px;
}

.replay-section p {
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}

.replay-turn-card {
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.replay-turn-card summary {
    cursor: pointer;
    font-weight: 500;
}

.replay-turn-meta {
    font-size: 12px;
    color: var(--text-secondary, #888);
    margin-left: 8px;
}

.replay-turn-body {
    margin-top: 10px;
    font-size: 13px;
}

.replay-muted {
    color: var(--text-secondary, #888);
    font-size: 13px;
}

.replay-mri-layout {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
    min-height: 200px;
}

@media (max-width: 640px) {
    .replay-mri-layout {
        grid-template-columns: 1fr;
    }
}

.replay-mri-turn-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.replay-mri-turn-btn {
    text-align: left;
    padding: 8px 10px;
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: inherit;
}

.replay-mri-turn-btn.is-active {
    background: var(--accent, #6366f1);
    color: #fff;
    border-color: transparent;
}

.replay-mri-detail pre,
.replay-raw-pre {
    background: var(--surface-muted, rgba(0,0,0,0.2));
    padding: 10px;
    border-radius: 6px;
    overflow: auto;
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    max-height: 300px;
}

.replay-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.replay-table th,
.replay-table td {
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
    padding: 6px 8px;
    text-align: left;
}

.replay-msg {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.replay-msg--user {
    background: rgba(99, 102, 241, 0.12);
    margin-left: 20%;
}

.replay-msg--assistant {
    background: var(--surface-muted, rgba(255,255,255,0.04));
    margin-right: 20%;
}

.replay-msg-role {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary, #888);
    margin-bottom: 4px;
}

.replay-msg-time {
    font-size: 11px;
    color: var(--text-secondary, #888);
    margin-top: 4px;
}

.replay-save-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.replay-save-btn,
.replay-library-link {
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.12));
    background: var(--surface-muted, rgba(255,255,255,0.04));
    color: inherit;
}

.replay-save-btn:hover,
.replay-library-link:hover {
    background: rgba(255,255,255,0.08);
}

.replay-raw-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

/* ===== Drawer polish: Snapshot Library & Conversation Replay ===== */

.snapshot-library-inner {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.snapshot-library-card {
    padding: 14px 16px;
}

.snapshot-library-card-badges .replay-badge {
    font-size: 10px;
    padding: 2px 7px;
    background: var(--color-primary-light, rgba(99, 102, 241, 0.15));
    color: var(--color-primary, var(--accent, #6366f1));
}

.snapshot-library-card-summary {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.4;
    color: var(--text-primary, inherit);
}

.snapshot-library-card-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 2px;
}

.snapshot-library-card-stats {
    font-size: 11px;
    color: var(--text-secondary, #888);
    line-height: 1.4;
}

.snapshot-library-card-preview {
    font-size: 12px;
    color: var(--text-muted, #94A3B8);
    font-style: italic;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.snapshot-library-card-actions {
    margin-top: 10px;
    padding-top: 10px;
}

.snapshot-library-card-hint {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-primary, var(--accent, #6366f1));
    opacity: 0.85;
}

.snapshot-library-icon-btn {
    width: 30px;
    height: 30px;
}

.replay-viewer-date {
    font-weight: 600;
    color: var(--text-primary, inherit);
}

.replay-viewer-session {
    font-size: 12px;
    color: var(--text-secondary, #888);
    font-family: 'JetBrains Mono', monospace;
}

.replay-viewer-actions .replay-btn {
    padding: 6px 12px;
    font-size: 12px;
}

@media (max-width: 640px) {
    .snapshot-library-toolbar {
        grid-template-columns: 1fr;
    }

    .snapshot-library-toolbar--meta {
        flex-direction: column;
        align-items: stretch;
    }

    .snapshot-library-toolbar-actions {
        justify-content: stretch;
    }

    .snapshot-library-toolbar-actions .replay-btn {
        flex: 1;
        text-align: center;
    }

    .replay-overview-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .replay-redact-label {
        width: 100%;
        margin-right: 0;
    }
}
