/**
 * Custom Components
 * Project-specific UI components and patterns
 */

/* ========================================
   UTILITIES
   ======================================== */

.font-mono {
  font-family: var(--rauda-font-mono);
}

.text-rauda-danger  { color: var(--rauda-danger); }
.text-rauda-warning { color: var(--rauda-warning); }
.text-rauda-success { color: var(--rauda-success); }
.text-rauda-black   { color: var(--rauda-black); }


/* ========================================
   FILTER BAR
   ======================================== */

/* Ported from the prototype's components.css for the tests list toolbar.
   Token names are mapped to this app's set: the prototype defines
   --rauda-border as var(--rauda-grey), and its --rauda-text-muted /
   --rauda-text are not defined at all (they fell back to inherited colours
   there), so they resolve here to --rauda-grey-text / --rauda-blue-text. */

.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--rauda-space-2);
  flex-wrap: wrap;
}

.filter-bar .btn,
.filter-bar .form-control {
  height: 32px;
  font-size: var(--rauda-text-sm);
}

.filter-bar .input-icon {
  max-width: 200px;
}

.filter-bar .btn-outline-secondary {
  --tblr-btn-border-color: var(--rauda-grey);
  --tblr-btn-hover-border-color: var(--rauda-grey);
  --tblr-btn-active-border-color: var(--rauda-grey);
}

.filter-date-menu {
  min-width: 220px;
}

.filter-date-range {
  display: flex;
  flex-direction: column;
  gap: var(--rauda-space-2);
  padding: var(--rauda-space-2) var(--rauda-space-3);
}

.filter-date-label {
  font-size: var(--rauda-text-sm);
  color: var(--rauda-grey-text);
  margin-bottom: 0;
}

.filter-date-back {
  color: var(--rauda-grey-text);
  font-size: var(--rauda-text-sm);
}

/* Reserves width so the count doesn't shift the filters as the number changes. */
.test-count {
  min-width: 5.5rem;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}


/* ========================================
   TABLE SEARCH
   ======================================== */

.table-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 220px;
}

.table-search-icon {
  position: absolute;
  left: 9px;
  color: var(--rauda-grey-text);
  font-size: 1rem;
  pointer-events: none;
}

.table-search-input {
  width: 100%;
  padding-left: 32px;
  padding-right: 30px;
  --tblr-border-color: var(--rauda-grey);
}

.table-search-clear {
  position: absolute;
  right: 5px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  border-radius: 50%;
  color: var(--rauda-grey-text);
  cursor: pointer;
  padding: 0;
  font-size: 0.75rem;
  transition: color var(--rauda-transition-fast), background var(--rauda-transition-fast);
}

.table-search-clear:hover {
  color: var(--rauda-blue-text);
  background: var(--rauda-grey);
}

/* ========================================
   TIME RANGE TABS
   ======================================== */

.time-tabs {
  display: inline-flex;
  background-color: var(--rauda-grey-light);
  border-radius: var(--rauda-radius-md);
  padding: 2px;
}

.time-tabs .time-tab {
  padding: var(--rauda-space-1) 0.625rem;
  font-size: var(--rauda-text-sm);
  font-weight: 500;
  color: var(--rauda-grey-text);
  background: transparent;
  border: none;
  border-radius: var(--rauda-radius-sm);
  cursor: pointer;
  transition: all var(--rauda-transition-fast);
}

.time-tabs .time-tab:hover {
  color: var(--rauda-black);
}

.time-tabs .time-tab.active {
  background-color: var(--rauda-white);
  color: var(--rauda-black);
  box-shadow: var(--rauda-shadow-sm);
}

/* ========================================
   QUALITY BAR (Agent list)
   ======================================== */

.quality-bar {
  width: 120px;
  height: 8px;
  background-color: var(--rauda-grey-light);
  border-radius: var(--rauda-radius-md);
  overflow: hidden;
}

.quality-bar-fill {
  height: 100%;
  border-radius: var(--rauda-radius-md);
  transition: width var(--rauda-transition-slow);
}

.quality-bar-fill.danger {
  background-color: var(--rauda-danger);
}

.quality-bar-fill.warning {
  background-color: var(--rauda-warning);
}

.quality-bar-fill.success {
  background-color: var(--rauda-success);
}

/* ========================================
   STATUS ICONS (Agent list)
   ======================================== */

.status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--rauda-radius-md);
  font-size: 14px;
}

.status-icon.danger {
  background-color: rgba(214, 57, 57, 0.1);
  color: var(--rauda-danger);
}

.status-icon.warning {
  background-color: rgba(247, 103, 7, 0.1);
  color: var(--rauda-warning);
}

.status-icon.top {
  background-color: rgba(47, 179, 68, 0.15);
  color: var(--rauda-success);
}

/* ========================================
   PERFORMANCE BADGES
   ======================================== */

.badge-at-risk {
  background-color: rgba(214, 57, 57, 0.1);
  color: var(--rauda-danger);
}

.badge-warning {
  background-color: rgba(247, 103, 7, 0.1);
  color: var(--rauda-warning);
}

.badge-good {
  background-color: rgba(47, 179, 68, 0.1);
  color: var(--rauda-success);
}

.badge-excellent {
  background-color: rgba(47, 179, 68, 0.2);
  color: var(--rauda-success);
}

/* ========================================
   RISK PERCENTAGE
   ======================================== */

.risk-percent {
  color: var(--rauda-grey-text);
}

/* ========================================
   SORTABLE COLUMNS
   ======================================== */

.sortable {
  cursor: pointer;
  user-select: none;
}

.sortable:hover {
  color: var(--rauda-accent);
}

.sortable .sort-icon {
  opacity: 0.3;
  margin-left: var(--rauda-space-1);
}

.sortable.active .sort-icon {
  opacity: 1;
  color: var(--rauda-accent);
}

/* ========================================
   STAT CARDS (Dashboard)
   ======================================== */

.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  padding: var(--rauda-space-3);
}

.stat-label {
  font-size: var(--rauda-text-xs);
  font-weight: 600;
  color: var(--rauda-grey-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--rauda-space-1);
}

.stat-sublabel {
  font-size: var(--rauda-text-xs);
  color: var(--rauda-grey-text);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  font-size: var(--rauda-text-3xl);
  font-weight: 700;
  line-height: 1;
  color: var(--rauda-black);
}

.stat-unit {
  font-size: var(--rauda-text-md);
  font-weight: 600;
  color: var(--rauda-grey-text);
}

.stat-context {
  font-size: var(--rauda-text-sm);
  color: var(--rauda-grey-text);
  margin-top: var(--rauda-space-2);
}

.stat-link {
  font-size: var(--rauda-text-sm);
  color: var(--rauda-accent);
  text-decoration: none;
  margin-top: var(--rauda-space-2);
  display: inline-flex;
  align-items: center;
  gap: var(--rauda-space-1);
}

.stat-link:hover {
  text-decoration: underline;
}

/* ========================================
   RISK STAT (Dashboard)
   ======================================== */

.risk-stat {
  display: flex;
  align-items: center;
  gap: var(--rauda-space-2);
}

.risk-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--rauda-danger);
}

/* ========================================
   SECTION DIVIDER (Dashboard row labels)
   ======================================== */

.section-divider {
  margin: var(--rauda-space-8) 0 var(--rauda-space-4) 0;
}

/* ========================================
   SECTION HEADER (Dashboard cards)
   ======================================== */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--rauda-space-6) var(--rauda-space-6) var(--rauda-space-3) var(--rauda-space-6);
}

.section-title,
h3.section-title {
  font-size: var(--rauda-text-md) !important;
  font-weight: 400 !important;
  color: var(--rauda-grey-text) !important;
  margin: 0;
  line-height: 1.5;
}

/* Card body variant for charts - minimal padding */
.card-body-chart {
  padding: 0 var(--rauda-space-4) !important;
}

.section-link {
  font-size: var(--rauda-text-base);
  color: var(--rauda-accent);
  text-decoration: none;
}

.section-link:hover {
  text-decoration: underline;
}

/* ========================================
   CALL ITEMS (Dashboard list)
   ======================================== */

.call-item {
  padding: var(--rauda-space-3) 0;
  border-bottom: 1px solid var(--rauda-grey-light);
}

.call-item:last-child {
  border-bottom: none;
}

.call-score {
  width: 40px;
  height: 40px;
  border-radius: var(--rauda-radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--rauda-text-base);
}

.call-score.danger {
  background-color: rgba(214, 57, 57, 0.1);
  color: var(--rauda-danger);
}

.call-score.warning {
  background-color: rgba(247, 103, 7, 0.1);
  color: var(--rauda-warning);
}

/* ========================================
   VARIATION BADGES
   ======================================== */

.variation {
  display: inline-flex;
  align-items: center;
  font-size: var(--rauda-text-base);
  font-weight: 500;
  padding: var(--rauda-space-1) var(--rauda-space-2);
  border-radius: var(--rauda-radius-md);
}

.variation.positive {
  background-color: rgba(47, 179, 68, 0.1);
  color: var(--rauda-success);
}

.variation.negative {
  background-color: rgba(214, 57, 57, 0.1);
  color: var(--rauda-danger);
}

.variation.neutral {
  background-color: rgba(90, 107, 136, 0.1);
  color: var(--rauda-grey-text);
}

/* ========================================
   DATA CARD (Reusable metric card)
   ======================================== */

.data-card {
  background-color: var(--rauda-white);
  border: 1px solid var(--rauda-grey-light);
  border-radius: var(--rauda-radius-xl);
  padding: var(--rauda-space-6);
  display: flex;
  flex-direction: column;
  gap: var(--rauda-space-6);
  width: 100%;
  height: 100%;
}

.data-card-title {
  font-size: var(--rauda-text-md);
  font-weight: 400;
  line-height: 1.5;
  color: var(--rauda-grey-text);
  margin: 0;
}

.data-card-content {
  display: flex;
  flex-direction: column;
}

.data-card-value {
  margin: 0;
  line-height: 1;
}

.data-card-number {
  font-family: var(--rauda-font-mono);
  font-size: var(--rauda-text-3xl);
  font-weight: 400;
  line-height: 1.3;
  color: var(--rauda-blue-text);
}

.data-card-unit {
  font-family: var(--rauda-font-mono);
  font-size: var(--rauda-text-md);
  font-weight: 400;
  line-height: 1.5;
  color: var(--rauda-grey-text);
}

.data-card-context {
  font-size: var(--rauda-text-base);
  font-weight: 400;
  line-height: 1.5;
  color: var(--rauda-grey-text);
  margin: 0;
  margin-top: var(--rauda-space-1);
}

.data-card-bar {
  margin-top: var(--rauda-space-2);
  margin-bottom: var(--rauda-space-1);
}

.data-card-bar .quality-bar {
  width: 100%;
}

/* Data Card Small Variant */
.data-card-sm {
  gap: var(--rauda-space-2);
}

.data-card-sm .data-card-title {
  color: var(--rauda-blue-text);
}

.data-card-sm .data-card-number {
  font-size: var(--rauda-text-2xl);
  line-height: 1.5;
}

/* ========================================
   AGENT META (Agent detail header)
   ======================================== */

.agent-meta {
  display: flex;
  flex-direction: column;
  gap: var(--rauda-space-1);
}

.agent-meta-item {
  font-size: var(--rauda-text-base);
  color: var(--rauda-grey-text);
}

.agent-meta-item strong {
  color: var(--rauda-black);
  font-weight: 500;
}

/* ========================================
   COLLAPSIBLE SECTIONS
   ======================================== */

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--rauda-space-4) var(--rauda-space-6);
  cursor: pointer;
  border-bottom: 1px solid var(--rauda-grey-light);
  transition: background-color var(--rauda-transition-fast);
}

.collapsible-header:hover {
  background-color: var(--rauda-grey-bg);
}

.collapsible-header h3 {
  font-size: var(--rauda-text-md);
  font-weight: 500;
  color: var(--rauda-black);
  margin: 0;
}

.collapsible-header .collapse-icon {
  transition: transform var(--rauda-transition-fast);
  transform: rotate(180deg);
}

.collapsible-header.collapsed .collapse-icon {
  transform: rotate(0deg);
}

.collapsible-body {
  padding: var(--rauda-space-6);
}

/* ========================================
   TRANSCRIPT TURNS (Call detail)
   ======================================== */

.transcript-turn {
  display: flex;
  gap: var(--rauda-space-6);
  align-items: flex-start;
}

.transcript-time {
  font-family: var(--rauda-font-mono);
  font-size: var(--rauda-text-sm);
  color: var(--rauda-grey-text);
  line-height: var(--rauda-leading-normal);
  flex-shrink: 0;
  min-width: 2.5rem;
}

.transcript-body {
  display: flex;
  flex-direction: column;
  gap: var(--rauda-space-2);
}

.transcript-speaker {
  font-family: var(--rauda-font-sans);
  font-size: var(--rauda-text-sm);
  color: var(--rauda-grey-text);
  line-height: var(--rauda-leading-normal);
}

.transcript-text {
  font-family: var(--rauda-font-sans);
  font-size: var(--rauda-text-base);
  color: var(--rauda-blue-text);
  line-height: var(--rauda-leading-normal);
  margin: 0;
}

/* ========================================
   CALL INDEX (Calls table)
   ======================================== */

.call-index {
  display: flex;
  align-items: center;
  gap: var(--rauda-space-2);
}

.call-index .quality-bar {
  width: 60px;
}

.quality-bar-inline {
  width: 80px;
  flex-shrink: 0;
}

.audit-block-header .quality-bar {
  background-color: var(--rauda-white);
}

/* ========================================
   AUDIT BLOCKS (Call detail — Puntos auditados)
   ======================================== */

.audit-block {
  border-bottom: 1px solid var(--rauda-grey-light);
}

.audit-block:last-child {
  border-bottom: none;
}

.audit-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--rauda-space-2) var(--rauda-space-6);
  background-color: var(--rauda-grey-light);
}

.audit-block-name {
  font-size: var(--rauda-text-sm);
  font-weight: 600;
  color: var(--rauda-black);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.audit-block-score {
  font-family: var(--rauda-font-mono);
  font-size: var(--rauda-text-base);
  color: var(--rauda-blue-text);
  min-width: 3.5rem;
  text-align: right;
  flex-shrink: 0;
}

.audit-criterion {
  padding: var(--rauda-space-3) var(--rauda-space-6);
  border-bottom: 1px solid var(--rauda-grey-light);
}

.audit-criterion:last-child {
  border-bottom: none;
}

.audit-criterion-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rauda-space-4);
}

.audit-criterion-name {
  font-size: var(--rauda-text-base);
  color: var(--rauda-blue-text);
  flex: 1;
}

.audit-criterion-pts {
  font-family: var(--rauda-font-mono);
  font-size: var(--rauda-text-base);
  color: var(--rauda-grey-text);
  min-width: 3.5rem;
  text-align: right;
  flex-shrink: 0;
}

.audit-reasoning {
  margin-top: var(--rauda-space-3);
  padding: var(--rauda-space-3) var(--rauda-space-4);
  border-radius: var(--rauda-radius-md);
  border-left: 3px solid var(--rauda-accent);
}

.audit-reasoning p {
  font-size: var(--rauda-text-base);
  color: var(--rauda-grey-text);
  line-height: var(--rauda-leading-normal);
  margin: 0;
}

/* ========================================
   TABLE UTILITIES
   ======================================== */

.table-link-row {
  cursor: pointer;
}

.table-row-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.filter-search-input {
  width: 200px;
}

.badge-ec {
  font-size: 9px;
  padding: 2px 5px;
  letter-spacing: 0.03em;
}

.badge-verdict {
  min-width: 68px;
  justify-content: center;
  font-family: var(--rauda-font-mono);
  font-size: var(--rauda-text-sm);
}

.nav-divider {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  margin: var(--rauda-space-2) 0;
}

/* ========================================
   SIMS LIST
   ======================================== */

.sim-count {
  font-size: var(--rauda-text-sm);
  color: var(--rauda-grey-text);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.col-checkbox { width: 36px; }
.col-date     { width: 90px; }
.col-id       { width: 80px; }
.col-last-run { width: 118px; }
.col-status   { width: 104px; }

.td-meta {
  font-size: var(--rauda-text-sm);
  color: var(--rauda-grey-text);
  white-space: nowrap;
}

.td-title {
  color: var(--rauda-blue-text);
  white-space: nowrap;
}

.td-secondary {
  color: var(--rauda-grey-text);
  max-width: 260px;
}

.selection-label {
  font-size: var(--rauda-text-sm);
  color: var(--rauda-grey-text);
}

/* Floating launch bar — mirrors the footer Run button while it's off-screen */
.sim-launch-floating {
  position: fixed;
  left: 50%;
  bottom: var(--rauda-space-6);
  z-index: 1040;
  display: flex;
  align-items: center;
  gap: var(--rauda-space-3);
  padding: var(--rauda-space-3) var(--rauda-space-4);
  background-color: var(--rauda-white);
  border: 1px solid var(--rauda-grey-light);
  border-radius: var(--rauda-radius-xl);
  box-shadow: var(--rauda-shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%) translateY(1rem);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.sim-launch-floating.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* ========================================
   SIM PANEL (offcanvas)
   ======================================== */

.sim-panel {
  width: 480px;
}

/* The form wraps header + body + footer, so it must own the panel's full
   height as a flex column; otherwise the body can't scroll and the footer
   (Save/Delete) overflows off-screen on short viewports. */
.sim-panel form {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sim-panel .offcanvas-header {
  border-bottom: 1px solid var(--rauda-grey-light);
  padding: var(--rauda-space-4) var(--rauda-space-6);
}

.sim-panel .offcanvas-title {
  font-size: var(--rauda-text-md);
  font-weight: 500;
  color: var(--rauda-black);
}

.sim-panel .offcanvas-body {
  padding: var(--rauda-space-6);
  display: flex;
  flex-direction: column;
  gap: var(--rauda-space-4);
  /* Grow to fill the form and scroll its own overflow; min-height:0 lets a
     flex child shrink below its content height so the scrollbar appears. */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.sim-panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--rauda-space-4) var(--rauda-space-6);
  border-top: 1px solid var(--rauda-grey-light);
  margin-top: auto;
  flex-shrink: 0;
}

/* ========================================
   TEST RESULT DATAGRID
   ======================================== */

.datagrid-4col {
  grid-template-columns: repeat(4, 1fr);
}

.datagrid-item-span2 {
  grid-row: span 2;
  align-self: stretch;
}

/* ========================================
   PASS RATE BAR
   ======================================== */

.pass-rate-bar {
  display: flex;
  align-items: center;
  gap: var(--rauda-space-3);
  width: 100%;
}

.pass-rate-bar .progress {
  flex: 1;
  height: 8px;
  background-color: var(--rauda-danger);
  border-radius: var(--rauda-radius-md);
  overflow: hidden;
}

.pass-rate-bar .progress-bar {
  background-color: var(--rauda-success);
}

/* While a run is in progress the bar stacks three colours — passed (green),
   failed (red) and a neutral track for the conversations still running/queued —
   so an unfinished run isn't a misleading wall of red. */
.pass-rate-bar .progress.pass-rate-progress-multi {
  background-color: var(--rauda-grey);
}

.pass-rate-bar .progress.pass-rate-progress-multi .progress-bar.bg-danger {
  background-color: var(--rauda-danger);
}

.pass-rate-fraction {
  font-family: var(--rauda-font-mono);
  font-size: var(--rauda-text-sm);
  color: var(--rauda-grey-text);
  white-space: nowrap;
}

/* ========================================
   TEST RESULT TABLE
   ======================================== */

.col-tel          { width: 160px; }
.col-result       { width: 140px; }
.col-duration     { width: 80px; }
.col-date-time    { width: 150px; }
.col-convs        { width: 60px; }
.col-outcome      { width: 150px; max-width: 150px; }
.col-failure      { width: 140px; max-width: 140px; }

/* Mobile: the test-result screen is built for wide tables. Reflow it so every
   field stays readable on a phone instead of being clipped or scrolled away. */
@media (max-width: 575.98px) {
  /* The 4-column summary can't fit a narrow screen, so its right-most card
     (pass rate) was clipped off. Collapse to two columns and give the pass
     rate its own full-width row on top. */
  .datagrid-4col {
    grid-template-columns: repeat(2, 1fr);
  }
  .datagrid-4col .datagrid-item-span2 {
    grid-column: 1 / -1;
    grid-row: auto;
    order: -1;
  }
  /* Drop the desktop alignment filler so it leaves no empty cell. */
  .datagrid-4col .datagrid-item:empty {
    display: none;
  }
  /* The agent number is identical on every row and already shown in the
     summary above — hide it here to shorten the conversations table. */
  .col-tel {
    display: none;
  }
}

/* ========================================
   PASS RATE INLINE (tests list table)
   ======================================== */

.pass-rate-inline {
  display: flex;
  align-items: center;
  gap: var(--rauda-space-2);
  white-space: nowrap;
}

.pass-rate-inline .pass-rate-pct {
  font-family: var(--rauda-font-mono);
  font-size: var(--rauda-text-sm);
  color: var(--rauda-grey-text);
  min-width: 36px;
  text-align: right;
}

.pass-rate-inline .progress {
  width: 80px;
  height: 6px;
  background-color: var(--rauda-danger);
  border-radius: var(--rauda-radius-md);
  overflow: hidden;
  flex-shrink: 0;
}

.pass-rate-inline .progress:not(.progress-indeterminate) .progress-bar {
  width: var(--pct, 0%);
  background-color: var(--rauda-success);
}

.pass-rate-inline .progress-indeterminate {
  background-color: var(--rauda-grey);
}

.pass-rate-inline .progress-indeterminate .progress-bar {
  width: 35%;
  background-color: var(--rauda-accent);
  animation: pass-rate-slide 1.4s ease-in-out infinite;
}

@keyframes pass-rate-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}

/* ========================================
   TESTS INFINITE SCROLL
   ======================================== */

.tests-load-more {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--rauda-space-2);
  padding: var(--rauda-space-4);
  color: var(--rauda-grey-text);
  font-size: var(--rauda-text-sm);
  border-top: 1px solid var(--rauda-grey-light);
}

.tests-load-more > * {
  visibility: hidden;
}

.tests-load-more.is-loading > *,
.tests-load-more.has-error [data-loading-label] {
  visibility: visible;
}

/* ========================================
   CONVERSATION DETAIL
   ======================================== */

.conv-audio {
  margin-top: var(--rauda-space-4);
  padding-top: var(--rauda-space-4);
  border-top: 1px solid var(--rauda-grey-light);
}

.conv-audio-player {
  width: 100%;
}

.conv-audio-player audio {
  display: none;
}

.conv-audio-controls {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
}

.conv-audio-play {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--rauda-white);
  background: var(--rauda-accent);
  transition:
    background-color var(--rauda-transition-fast),
    transform var(--rauda-transition-fast);
}

.conv-audio-play:hover {
  background: var(--rauda-accent-hover);
  transform: scale(1.04);
}

.conv-audio-play:focus-visible,
.conv-waveform:focus-visible,
.conv-audio-speed:focus-visible {
  outline: 3px solid rgba(60, 95, 255, 0.24);
  outline-offset: 2px;
}

.conv-audio-play .ti {
  font-size: 0.9rem;
}

.conv-waveform {
  position: relative;
  width: 100%;
  height: 34px;
  display: block;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.conv-waveform canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.conv-waveform-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--rauda-grey-text);
  font-size: var(--rauda-text-xs);
  pointer-events: none;
}

.conv-audio-player.is-ready .conv-waveform-loading {
  display: none;
}

.conv-audio-meta {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
  color: var(--rauda-grey-text);
  font-size: var(--rauda-text-xs);
}

.conv-audio-time {
  grid-column: 2;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.conv-audio-time-separator {
  margin: 0 3px;
  color: var(--rauda-grey);
}

.conv-audio-speed {
  width: 34px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--rauda-radius-md);
  color: var(--rauda-grey-text);
  background: transparent;
  font-size: var(--rauda-text-sm);
  font-weight: 500;
  transition:
    color var(--rauda-transition-fast),
    background-color var(--rauda-transition-fast);
}

.conv-audio-speed:hover {
  color: var(--rauda-accent);
  background: rgba(60, 95, 255, 0.06);
}

@media (max-width: 575.98px) {
  .conv-audio-controls,
  .conv-audio-meta {
    grid-template-columns: 30px minmax(0, 1fr) 32px;
    gap: 8px;
  }

  .conv-audio-play {
    width: 30px;
    height: 30px;
  }

  .conv-waveform {
    height: 32px;
  }

  .conv-audio-speed {
    width: 32px;
  }
}

/* Sub-headings (Situation, Expected outcome, Failure reason, …): darker and
   heavier than their body text so each one reads as a label, not as more
   content. The block's general category (the card title) is left untouched. */
.conv-field-label {
  color: var(--rauda-blue-text);
  font-weight: 600;
  font-size: var(--rauda-text-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.conv-field + .conv-field {
  margin-top: var(--rauda-space-4);
}

.conv-field-text {
  font-size: var(--rauda-text-base);
  color: var(--rauda-grey-text);
  line-height: var(--rauda-leading-normal);
  margin: var(--rauda-space-1) 0 0;
  white-space: pre-wrap;
}

/* Transcript rendered as a conversation: one turn per row, agent vs user
   distinguished by colour + a left rule, with high-contrast body text. */
.conv-transcript {
  display: flex;
  flex-direction: column;
  gap: var(--rauda-space-3);
  max-height: 520px;
  overflow-y: auto;
}

.conv-turn {
  padding: var(--rauda-space-2) var(--rauda-space-3);
  border-radius: var(--rauda-radius-lg);
  border-left: 3px solid var(--rauda-grey);
  background-color: var(--rauda-grey-light);
}

.conv-turn-agent {
  border-left-color: var(--rauda-accent);
  background-color: rgba(60, 95, 255, 0.06);
}

.conv-turn-user {
  border-left-color: var(--rauda-success);
  background-color: rgba(47, 179, 68, 0.07);
}

.conv-turn-role {
  display: block;
  font-size: var(--rauda-text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--rauda-space-1);
  color: var(--rauda-grey-text);
}

.conv-turn-agent .conv-turn-role { color: var(--rauda-accent); }
.conv-turn-user .conv-turn-role { color: var(--rauda-success); }

/* Per-turn timestamp sits beside the role, muted and in its normal case. */
.conv-turn-time {
  margin-left: var(--rauda-space-2);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--rauda-grey-text);
}

.conv-turn-text {
  margin: 0;
  /* Dark ink for readability — the old grey was too low-contrast. */
  color: var(--rauda-blue-text);
  font-size: var(--rauda-text-base);
  line-height: var(--rauda-leading-normal);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Fallback for a transcript with no recognisable role prefixes. */
.conv-transcript-raw {
  font-family: var(--rauda-font-mono);
  font-size: var(--rauda-text-base);
  color: var(--rauda-blue-text);
  line-height: var(--rauda-leading-normal);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-height: 520px;
  overflow-y: auto;
  margin: 0;
}

/* Collapsible block headers: the whole card-header toggles its body. */
.conv-collapse-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.conv-collapse-icon {
  color: var(--rauda-grey-text);
  /* `transform` has no effect on inline boxes, so the chevron must be
     inline-block for the rotation to apply. The 0.35s ease matches Bootstrap's
     collapse transition so the icon turns in step with the block opening. */
  display: inline-block;
  transition: transform 0.35s ease;
}

/* Bootstrap adds .collapsed to the toggle when its target is hidden; rotate the
   chevron so it points up while the block is open and back down as it closes. */
.conv-collapse-toggle:not(.collapsed) .conv-collapse-icon {
  transform: rotate(180deg);
}
