/**
 * Professional Chat Styles - Chain of Thought Steps v3
 * - Expandable steps with chevrons
 * - Inline status word in chat area
 * - Persistent COT after completion
 */

:root {
  --cellyn-purple: #6D55D6;
  --cellyn-purple-light: #6D55D6;
  --cellyn-purple-dark: #5D46BF;
  --cellyn-green: #22C55E;
}

/* ===========================================
   INLINE STATUS (sticky at bottom of white chat area)
   =========================================== */

.cot-inline-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-family: 'Inter', -apple-system, sans-serif;
  background: #f5f0ff;
  z-index: 5;
  flex-shrink: 0;
}

.cot-status-text {
  font-size: 13px;
  font-weight: 600;
  color: #6D55D6;
  transition: opacity 0.12s ease;
}

.cot-status-timer {
  font-size: 12px;
  font-weight: 600;
  color: #6D55D6;
  font-variant-numeric: tabular-nums;
}

/* Custom spinning loader (scaled to 16px for inline use) */
.custom-loader {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background:
    radial-gradient(farthest-side, #6D55D6 94%, #0000) top/3px 3px no-repeat,
    conic-gradient(#0000 30%, #6D55D6);
  -webkit-mask: radial-gradient(farthest-side, #0000 calc(100% - 3px), #000 0);
  mask: radial-gradient(farthest-side, #0000 calc(100% - 3px), #000 0);
  animation: customSpin 1s infinite linear;
  flex-shrink: 0;
}

@keyframes customSpin {
  100% { transform: rotate(1turn); }
}

/* ===========================================
   CHAIN OF THOUGHT — SINGLE STEP DISPLAY
   =========================================== */

.cot-container {
  margin: 8px 0 4px 0;
  padding: 0;
  transition: opacity 0.5s ease;
}

.cot-container.cot-done {
  opacity: 0.7;
  transition: opacity 0.4s ease;
}

.cot-step-display {
  position: relative;
  min-height: 28px;
}

.cot-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 6px 4px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Dot */
.cot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6D55D6;
  flex-shrink: 0;
  animation: cotPulse 1.5s ease-in-out infinite;
}

@keyframes cotPulse {
  0%, 100% { opacity: 0.5; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.cot-step.complete .cot-dot {
  background: #9ca3af;
  animation: none;
}

/* Text */
.cot-text {
  font-size: 13px;
  font-weight: 400;
  color: #374151;
  font-family: 'Inter', -apple-system, sans-serif;
  flex: 1;
  min-width: 0;
}

.cot-step.complete .cot-text {
  color: #9ca3af;
}

/* ===========================================
   CHEVRON (expand/collapse)
   =========================================== */

.cot-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  color: #9ca3af;
  transition: transform 0.2s ease, color 0.2s ease;
  border-radius: 4px;
}

.cot-chevron:hover {
  color: #6D55D6;
  background: rgba(109, 85, 214, 0.06);
}

.cot-chevron.expanded {
  transform: rotate(180deg);
  color: #6D55D6;
}

/* ===========================================
   COLLAPSIBLE DETAIL PANEL
   =========================================== */

.cot-detail {
  width: 100%;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, padding 0.25s ease, opacity 0.25s ease;
  opacity: 0;
  font-size: 12px;
  font-family: 'Inter', -apple-system, sans-serif;
  color: #6b7280;
  line-height: 1.5;
  padding: 0 0 0 17px;
  margin-left: 0;
}

.cot-detail.expanded {
  max-height: 200px;
  opacity: 1;
  padding: 4px 0 8px 17px;
}

/* ===========================================
   ELAPSED TIME LABEL (appears after AI message)
   =========================================== */

.cot-elapsed {
  font-size: 12px;
  font-weight: 600;
  color: #6D55D6;
  font-style: normal;
  padding: 2px 0 8px 0;
  font-family: 'Inter', -apple-system, sans-serif;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===========================================
   LEGACY: inline-thinking-section compat
   =========================================== */

.inline-thinking-section {
  display: none !important;
}

/* ===========================================
   INLINE APPROVAL
   =========================================== */

.chat-approval-panel {
  margin: 16px 0;
  background: linear-gradient(135deg, #F5F1FD 0%, #EFE9FA 100%);
  border: 2px solid var(--cellyn-purple);
  border-radius: 16px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
}

.chat-approval-panel.visible {
  opacity: 1;
  transform: translateY(0);
}

.chat-approval-panel.removing {
  opacity: 0;
  transform: translateY(-10px);
}

.approval-message {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
}

.approval-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  background: var(--cellyn-purple);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.approval-icon svg { width: 24px; height: 24px; color: white; }
.approval-details { flex: 1; }
.approval-title { font-size: 15px; font-weight: 600; color: #1F2937; margin-bottom: 4px; }
.approval-summary { font-size: 13px; color: #6B7280; }

.approval-actions {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  background: rgba(112, 85, 226, 0.05);
  border-top: 1px solid rgba(112, 85, 226, 0.1);
}

.btn-cancel,
.btn-approve {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.btn-cancel { background: #F3F4F6; color: #6B7280; }
.btn-cancel:hover { background: #E5E7EB; color: #374151; }
.btn-approve { background: var(--cellyn-purple); color: white; }
.btn-approve:hover { background: var(--cellyn-purple-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(112, 85, 226, 0.3); }

.key-hint { font-size: 10px; padding: 2px 6px; border-radius: 4px; opacity: 0.7; }
.btn-cancel .key-hint { background: #E5E7EB; }
.btn-approve .key-hint { background: rgba(255, 255, 255, 0.2); }

@media (max-width: 768px) {
  .approval-actions { flex-direction: column; }
}

/* ===========================================
   HIDE LEGACY ELEMENTS
   =========================================== */

.thinking-indicator-bar,
#thinking-indicator,
.thinking-panel,
.cellyn-status-bar {
  display: none !important;
}

/* ===========================================
   DARK MODE — Professional Chat Overrides
   =========================================== */

[data-theme="dark"] .cot-inline-status {
    background: #2d2850;
}

[data-theme="dark"] .cot-inline-label {
    color: #8B75E8;
}

[data-theme="dark"] .cot-inline-text {
    color: #a8a3c0;
}

[data-theme="dark"] .cot-detail-text {
    color: #a8a3c0;
}

[data-theme="dark"] .cot-detail-toggle {
    color: #706b8a;
}

[data-theme="dark"] .cot-detail-toggle:hover {
    color: #8B75E8;
    background: rgba(139, 117, 232, 0.1);
}

[data-theme="dark"] .cot-text {
    color: #c4bfe0;
}

[data-theme="dark"] .cot-step.complete .cot-text {
    color: #706b8a;
}

[data-theme="dark"] .cot-step.complete .cot-dot {
    background: #504a6e;
}

[data-theme="dark"] .cot-checklist {
    background: rgba(109, 85, 214, 0.06) !important;
    border-left-color: rgba(139, 117, 232, 0.25) !important;
}

[data-theme="dark"] .cot-checklist-item {
    color: #8a7fb8 !important;
}

[data-theme="dark"] .approval-card {
    background: linear-gradient(135deg, #24243d 0%, #2a2a45 100%);
}

[data-theme="dark"] .approval-title {
    color: #f0f0f5;
}

[data-theme="dark"] .approval-summary {
    color: #a8a3c0;
}

[data-theme="dark"] .approval-changes {
    background: rgba(139, 117, 232, 0.08);
}

[data-theme="dark"] .btn-cancel {
    background: #2a2a45;
    color: #a8a3c0;
}

[data-theme="dark"] .btn-cancel:hover {
    background: #353550;
    color: #f0f0f5;
}

[data-theme="dark"] .btn-cancel .key-hint {
    background: #353550;
}
