/* ═══════════════════════════════════════════════════════════════
   CALL ASSISTANT — Real-time AI Call Coach Panel
   Dashboard panel styles for live transcription + AI suggestions
   ═══════════════════════════════════════════════════════════════ */

/* ─── Layout ─── */
.ca-wrap {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  grid-template-rows: auto 1fr;
  gap: var(--space-4);
  height: calc(100vh - var(--header-height) - var(--space-8));
  padding: var(--space-4);
  min-height: 0;
}

.ca-wrap.no-customer {
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
}

/* ─── Header Bar ─── */
.ca-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.ca-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
}

.ca-header-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.ca-status-dot {
  width: 10px; height: 10px;
  border-radius: var(--radius-full);
  background: var(--text-tertiary);
  transition: background var(--duration-normal) var(--ease-default);
}

.ca-status-dot.recording { background: var(--error); animation: ca-pulse 1.5s ease infinite; }
.ca-status-dot.connected { background: var(--success); }

@keyframes ca-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.ca-timer {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  color: var(--text-secondary);
  min-width: 60px;
}

.ca-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ─── Customer Search ─── */
.ca-search-wrap {
  position: relative;
  width: 280px;
}

.ca-search-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  padding-left: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--duration-fast);
}

.ca-search-input:focus { border-color: var(--accent); }
.ca-search-input::placeholder { color: var(--text-muted); }

.ca-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.ca-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: none;
}

.ca-search-results.open { display: block; }

.ca-search-item {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--duration-fast);
}

.ca-search-item:hover { background: var(--bg-hover); }
.ca-search-item:last-child { border-bottom: none; }

.ca-search-item-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.ca-search-item-phone {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

/* ─── Customer Context Card ─── */
.ca-context {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overflow-y: auto;
}

.ca-context-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.ca-context-card h3 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
}

.ca-customer-name {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.ca-customer-detail {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-bottom: var(--space-1);
}

.ca-customer-detail span { color: var(--text-secondary); }

.ca-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.ca-stat {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  text-align: center;
}

.ca-stat-val {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--accent-text);
}

.ca-stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Policy List ─── */
.ca-policy-item {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.ca-policy-item:last-child { border-bottom: none; }

.ca-policy-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ca-policy-type {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.ca-policy-premium {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--accent-text);
}

.ca-policy-detail {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.ca-policy-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
}

.ca-policy-badge.active { background: var(--success-muted); color: var(--success); }
.ca-policy-badge.expired { background: var(--error-muted); color: var(--error); }
.ca-policy-badge.pending { background: var(--warning-muted); color: var(--warning); }

/* ─── Transcript Panel ─── */
.ca-transcript {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ca-transcript-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.ca-transcript-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ca-transcript-body {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: var(--space-4);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.ca-transcript-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  color: var(--text-muted);
  text-align: center;
}

.ca-transcript-empty-icon {
  font-size: 48px;
  margin-bottom: var(--space-3);
  opacity: 0.5;
}

/* ─── Chat Bubbles ─── */
.ca-bubble {
  max-width: 85%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  animation: ca-fadeIn 0.2s ease;
}

@keyframes ca-fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ca-bubble.agent {
  align-self: flex-end;
  background: var(--accent-muted);
  color: var(--accent-text);
  border-bottom-right-radius: var(--radius-sm);
}

.ca-bubble.customer {
  align-self: flex-start;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-sm);
}

.ca-bubble-speaker {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  margin-bottom: 2px;
  opacity: 0.8;
}

.ca-bubble-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  text-align: right;
}

.ca-bubble.agent .ca-bubble-speaker { color: var(--accent); }
.ca-bubble.customer .ca-bubble-speaker { color: var(--text-tertiary); }

/* ─── Sentiment Badge ─── */
.ca-sentiment {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.ca-sentiment.positive { background: var(--success-muted); color: var(--success); }
.ca-sentiment.neutral  { background: var(--info-muted);    color: var(--info); }
.ca-sentiment.negative { background: var(--error-muted);   color: var(--error); }

/* ─── Suggestions Panel ─── */
.ca-suggestions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overflow-y: auto;
}

.ca-suggestions-header {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ca-suggestions-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Suggestion Cards ─── */
.ca-suggestion {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  animation: ca-fadeIn 0.3s ease;
}

.ca-suggestion:hover {
  border-color: var(--border-default);
  transform: translateY(-1px);
}

.ca-suggestion-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.ca-suggestion.answer .ca-suggestion-badge  { background: var(--success-muted); color: var(--success); }
.ca-suggestion.crosssell .ca-suggestion-badge { background: var(--info-muted); color: var(--info); }
.ca-suggestion.warning .ca-suggestion-badge  { background: var(--error-muted); color: var(--error); }
.ca-suggestion.info .ca-suggestion-badge     { background: var(--purple-muted); color: var(--purple); }
.ca-suggestion.tip .ca-suggestion-badge      { background: var(--warning-muted); color: var(--warning); }
.ca-suggestion.script .ca-suggestion-badge   { background: var(--accent-muted); color: var(--accent); }

.ca-suggestion-text {
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: var(--leading-normal);
}

.ca-suggestion-text.expanded { white-space: pre-wrap; }

.ca-suggestion-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

/* ─── Quick Actions ─── */
.ca-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.ca-action-btn {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.ca-action-btn:hover {
  background: var(--accent-muted);
  color: var(--accent-text);
  border-color: var(--accent);
}

/* ─── Knowledge Base ─── */
.ca-kb-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ca-kb-item {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
}

.ca-kb-item:hover { background: var(--bg-overlay); }

.ca-kb-item-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.ca-kb-item-text {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: 2px;
  display: none;
}

.ca-kb-item.expanded .ca-kb-item-text { display: block; }

/* ─── Previous Calls ─── */
.ca-prev-call {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.ca-prev-call:last-child { border-bottom: none; }

.ca-prev-call-date {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.ca-prev-call-summary {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Call Summary Modal ─── */
.ca-summary-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.ca-summary-overlay.open { display: flex; }

.ca-summary-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  padding: var(--space-6);
  box-shadow: var(--shadow-xl);
}

.ca-summary-modal h2 {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

.ca-summary-section {
  margin-bottom: var(--space-4);
}

.ca-summary-section h3 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.ca-summary-section p,
.ca-summary-section li {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
}

.ca-summary-section ul {
  list-style: none;
  padding: 0;
}

.ca-summary-section li::before {
  content: '•';
  color: var(--accent);
  margin-right: var(--space-2);
}

.ca-summary-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

/* ─── Buttons ─── */
.ca-btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all var(--duration-fast);
}

.ca-btn:hover { background: var(--bg-overlay); border-color: var(--border-strong); }

.ca-btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
}

.ca-btn-primary:hover { background: var(--accent-hover); }

.ca-btn-danger {
  background: var(--error-muted);
  color: var(--error);
  border-color: transparent;
}

.ca-btn-danger:hover { background: var(--error); color: white; }

.ca-btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

/* ─── Responsive ─── */
@media (max-width: 1200px) {
  .ca-wrap {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto 1fr;
  }
  .ca-header { grid-column: 1 / -1; }
  .ca-context { grid-column: 1 / -1; flex-direction: row; overflow-x: auto; }
  .ca-context-card { min-width: 280px; }
}

@media (max-width: 768px) {
  .ca-wrap {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
    height: auto;
  }
  .ca-header { flex-wrap: wrap; }
  .ca-search-wrap { width: 100%; }
  .ca-transcript-body { max-height: 50vh; }
}
