/* ============================================================
   v6 AI Versions — pill button + popover panel
   ============================================================
*/

@layer v6-components {

  /* Pill button next to the AI quick-actions chevron */
  .v6-versions__pill {
    position: relative;
    margin-left: 6px;
  }
  .v6-versions__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: rgba(139, 92, 246, 0.30);
    border-radius: 999px;
    color: var(--accent-primary, #8b5cf6);
    font-family: var(--font-mono, monospace);
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    margin-left: 4px;
  }

  /* ============================================================
     Popover
     ============================================================ */
  .v6-versions__menu {
    position: fixed;
    z-index: var(--z-popover, 1000);
    width: 420px;
    max-height: 480px;
    display: flex;
    flex-direction: column;

    background: var(--v6-panel, var(--surface-300, #18181b));
    border: 1px solid var(--v6-border-strong, rgba(255, 255, 255, 0.14));
    border-radius: var(--radius-lg, 8px);
    box-shadow: var(--shadow-4, 0 24px 64px rgba(0,0,0,0.7));
    overflow: hidden;

    opacity: 0;
    transform: scale(0.96) translateY(-2px);
    transform-origin: top right;
    transition: opacity var(--duration-fast, 120ms) var(--ease-out-quart),
                transform var(--duration-fast, 120ms) var(--ease-out-quart);
  }
  .v6-versions__menu--visible {
    opacity: 1;
    transform: scale(1) translateY(0);
  }

  .v6-versions__menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--v6-border-faint, rgba(255,255,255,0.04));
    font-size: 11px;
    color: var(--text-secondary, #a1a1aa);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  .v6-versions__menu-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
  }
  .v6-versions__menu-list::-webkit-scrollbar { width: 8px; }
  .v6-versions__menu-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.10);
    border-radius: 4px;
  }

  .v6-versions__menu-footer {
    padding: 8px 12px;
    border-top: 1px solid var(--v6-border-faint, rgba(255,255,255,0.04));
    background: var(--surface-200, #111113);
  }
  .v6-versions__menu-hint {
    font-size: 10px;
    color: var(--text-muted, #71717a);
    line-height: 1.4;
  }

  /* ============================================================
     Empty state
     ============================================================ */
  .v6-versions__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 24px;
    text-align: center;
    color: var(--text-muted, #71717a);
  }
  .v6-versions__empty .v6-icon {
    color: var(--text-muted, #71717a);
    opacity: 0.5;
  }
  .v6-versions__empty p {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
  }
  .v6-versions__empty strong {
    color: var(--text-secondary, #a1a1aa);
    font-weight: 600;
  }

  /* ============================================================
     Snapshot row
     ============================================================ */
  .v6-versions__row {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    margin-bottom: 4px;
    background: var(--surface-400, #1f1f23);
    border: 1px solid var(--v6-border-faint, rgba(255, 255, 255, 0.04));
    border-radius: var(--radius-sm, 4px);
    transition: background var(--duration-fast, 120ms),
                border-color var(--duration-fast, 120ms);
  }
  .v6-versions__row:hover {
    background: var(--surface-500, #27272b);
    border-color: var(--v6-border, rgba(255, 255, 255, 0.08));
  }

  /* Mini preview — same structure as the library card preview */
  .v6-versions__preview {
    width: 80px;
    height: 44px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.40);
    border-radius: 3px;
    overflow: hidden;
  }
  .v6-versions__preview-empty {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.30);
  }
  .v6-versions__preview-grid {
    display: flex;
    flex-direction: column;
    gap: 1px;
    height: 100%;
  }
  .v6-versions__preview-row {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 1px;
    flex: 1;
    min-height: 0;
  }
  .v6-versions__preview-cell {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 1px;
  }
  .v6-versions__preview-cell--active {
    background: var(--row-color, var(--accent-primary, #8b5cf6));
    opacity: 0.85;
  }

  /* Body */
  .v6-versions__body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .v6-versions__row-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
  }
  .v6-versions__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary, #fafafa);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .v6-versions__time {
    font-family: var(--font-mono, monospace);
    font-size: 10px;
    color: var(--text-muted, #71717a);
    flex-shrink: 0;
  }

  .v6-versions__row-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
  .v6-versions__axis {
    display: inline-block;
    padding: 1px 6px;
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 999px;
    font-family: var(--font-mono, monospace);
    font-size: 9px;
    color: var(--accent-primary, #8b5cf6);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .v6-versions__delta {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 999px;
    font-family: var(--font-mono, monospace);
    font-size: 9px;
    font-weight: 700;
  }
  .v6-versions__delta--up {
    color: var(--accent-success, #22c55e);
    background: rgba(34, 197, 94, 0.10);
    border: 1px solid rgba(34, 197, 94, 0.25);
  }
  .v6-versions__delta--down {
    color: var(--accent-warning, #f59e0b);
    background: rgba(245, 158, 11, 0.10);
    border: 1px solid rgba(245, 158, 11, 0.25);
  }

  .v6-versions__notes {
    font-size: 10px;
    color: var(--text-muted, #71717a);
    font-style: italic;
    line-height: 1.3;
    margin-top: 2px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  /* Actions */
  .v6-versions__row-actions {
    display: inline-flex;
    gap: 4px;
    flex-shrink: 0;
  }
}
