/* ==========================================================================
   Catalyst Advisor — Chatbot IA Conduite du Changement
   Styling for Floating Widget, Modal, Diagnostic Stepper & Advisor View
   ========================================================================== */

:root {
  --ca-bg-dark: #0b1116;
  --ca-bg-surface: #0f172a;
  --ca-bg-card: #1e293b;
  --ca-bg-card-hover: #27354f;
  --ca-border-subtle: rgba(255, 255, 255, 0.08);
  --ca-border-focus: rgba(16, 185, 129, 0.4);
  --ca-primary: #10b981;
  --ca-primary-hover: #059669;
  --ca-primary-glow: rgba(16, 185, 129, 0.25);
  --ca-accent-gold: #d4af37;
  --ca-accent-glow: rgba(212, 175, 55, 0.25);
  --ca-text-main: #e0e6ed;
  --ca-text-muted: #94a3b8;
  --ca-danger: #ef4444;
  --ca-warning: #f59e0b;
  --ca-radius-sm: 6px;
  --ca-radius-md: 12px;
  --ca-radius-lg: 20px;
  --ca-shadow-elevated: 0 20px 45px -10px rgba(0, 0, 0, 0.7), 0 0 25px rgba(16, 185, 129, 0.08);
}

/* ---------------- Floating Launcher Button ---------------- */
.ca-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 40px;
  padding: 10px 18px 10px 14px;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 20px rgba(16, 185, 129, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Inter', -apple-system, sans-serif;
  user-select: none;
}

.ca-launcher:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: var(--ca-primary);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.5), 0 0 28px rgba(16, 185, 129, 0.35);
}

.ca-launcher-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ca-primary) 0%, #059669 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 0 12px var(--ca-primary-glow);
  position: relative;
  flex-shrink: 0;
}

.ca-launcher-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--ca-primary);
  opacity: 0.6;
  animation: ca-pulse-ring 2.4s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes ca-pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

.ca-launcher-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.ca-launcher-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ca-launcher-title .ca-badge-tag {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.ca-launcher-subtitle {
  font-size: 0.74rem;
  color: var(--ca-text-muted);
}

/* ---------------- Chat Widget Container ---------------- */
.ca-widget-panel {
  position: fixed;
  bottom: 88px;
  right: 28px;
  width: 440px;
  max-width: calc(100vw - 32px);
  height: 660px;
  max-height: calc(100vh - 110px);
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--ca-radius-md);
  box-shadow: var(--ca-shadow-elevated);
  z-index: 9991;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', -apple-system, sans-serif;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ca-widget-panel.ca-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Fullscreen mode */
.ca-widget-panel.ca-fullscreen {
  bottom: 16px;
  right: 16px;
  width: calc(100vw - 32px);
  height: calc(100vh - 32px);
  max-width: 1100px;
  margin: 0 auto;
  left: 16px;
}

/* ---------------- Header ---------------- */
.ca-header {
  padding: 14px 18px;
  background: rgba(11, 17, 22, 0.85);
  border-bottom: 1px solid var(--ca-border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ca-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ca-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(212, 175, 55, 0.2));
  border: 1px solid rgba(16, 185, 129, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.ca-header-info h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.05rem;
  color: #fff;
  margin: 0;
  line-height: 1.2;
}

.ca-header-info p {
  font-size: 0.72rem;
  color: var(--ca-text-muted);
  margin: 2px 0 0 0;
}

.ca-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ca-lang-toggle {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 2px 4px;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-right: 2px;
}

.ca-lang-btn {
  background: transparent;
  border: none;
  color: var(--ca-text-muted);
  padding: 2px 6px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.72rem;
  transition: all 0.2s;
  line-height: 1;
}

.ca-lang-btn.active {
  background: var(--ca-primary);
  color: #fff;
  font-weight: 700;
}

.ca-lang-btn:hover:not(.active) {
  color: #fff;
}

.ca-btn-icon {
  background: transparent;
  border: none;
  color: var(--ca-text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--ca-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.95rem;
}

.ca-btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.ca-btn-icon.active {
  color: var(--ca-primary);
  background: rgba(16, 185, 129, 0.15);
}

/* ---------------- Sub-bar: Frameworks & Diagnostic Trigger ---------------- */
.ca-subbar {
  padding: 8px 16px;
  background: rgba(11, 17, 22, 0.5);
  border-bottom: 1px solid var(--ca-border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  gap: 8px;
  overflow-x: auto;
}

.ca-framework-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ca-accent-gold);
  font-weight: 500;
  white-space: nowrap;
}

.ca-diagnostic-btn {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.ca-diagnostic-btn:hover {
  background: var(--ca-primary);
  color: #fff;
}

/* ---------------- Chat Messages Area ---------------- */
.ca-messages-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.ca-messages-body::-webkit-scrollbar {
  width: 6px;
}

.ca-messages-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

/* Message Item */
.ca-msg {
  display: flex;
  flex-direction: column;
  max-width: 92%;
  animation: ca-fadeIn 0.25s ease-out;
}

@keyframes ca-fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ca-msg-user {
  align-self: flex-end;
}

.ca-msg-model {
  align-self: flex-start;
}

.ca-msg-bubble {
  padding: 12px 16px;
  border-radius: var(--ca-radius-md);
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ca-text-main);
  position: relative;
  word-break: break-word;
}

.ca-msg-user .ca-msg-bubble {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(5, 150, 105, 0.3) 100%);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #fff;
  border-bottom-right-radius: 2px;
}

.ca-msg-model .ca-msg-bubble {
  background: var(--ca-bg-card);
  border: 1px solid var(--ca-border-subtle);
  border-bottom-left-radius: 2px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Markdown formatting inside bot responses */
.ca-msg-bubble h1, .ca-msg-bubble h2, .ca-msg-bubble h3, .ca-msg-bubble h4 {
  font-family: 'Playfair Display', Georgia, serif;
  color: #fff;
  margin-top: 14px;
  margin-bottom: 6px;
  line-height: 1.3;
}

.ca-msg-bubble h3 { font-size: 1.05rem; }
.ca-msg-bubble h4 { font-size: 0.95rem; color: #6ee7b7; }

.ca-msg-bubble p {
  margin: 0 0 10px 0;
}

.ca-msg-bubble p:last-child {
  margin-bottom: 0;
}

.ca-msg-bubble ul, .ca-msg-bubble ol {
  margin: 6px 0 12px 20px;
  padding: 0;
}

.ca-msg-bubble li {
  margin-bottom: 6px;
}

.ca-msg-bubble strong {
  color: #fff;
  font-weight: 600;
}

/* Special callout boxes in assistant responses */
.ca-callout {
  padding: 10px 14px;
  border-radius: var(--ca-radius-sm);
  margin: 10px 0;
  font-size: 0.85rem;
}

.ca-callout-warning {
  background: rgba(245, 158, 11, 0.1);
  border-left: 3px solid var(--ca-warning);
  color: #fde68a;
}

.ca-callout-kpi {
  background: rgba(16, 185, 129, 0.1);
  border-left: 3px solid var(--ca-primary);
  color: #a7f3d0;
}

.ca-callout-kpi strong, .ca-callout-warning strong {
  display: block;
  margin-bottom: 2px;
}

/* Message Actions (Copy, Export) */
.ca-msg-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 0 4px;
}

.ca-action-link {
  font-size: 0.72rem;
  color: var(--ca-text-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: color 0.2s;
}

.ca-action-link:hover {
  color: var(--ca-primary);
}

/* ---------------- Starter Chips (Prompt Suggestions) ---------------- */
.ca-starters-wrapper {
  padding: 0 16px 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ca-starters-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ca-text-muted);
  font-weight: 600;
}

.ca-starters-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.ca-starters-row::-webkit-scrollbar {
  display: none;
}

.ca-starter-chip {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--ca-border-subtle);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 0.78rem;
  color: var(--ca-text-main);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ca-starter-chip:hover {
  border-color: var(--ca-primary);
  background: rgba(16, 185, 129, 0.12);
  color: #fff;
  transform: translateY(-1px);
}

/* ---------------- Input Area ---------------- */
.ca-input-bar {
  padding: 12px 16px;
  background: rgba(11, 17, 22, 0.9);
  border-top: 1px solid var(--ca-border-subtle);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.ca-input-box {
  flex: 1;
  background: var(--ca-bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--ca-radius-md);
  padding: 10px 14px;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
  resize: none;
  max-height: 120px;
  min-height: 44px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ca-input-box:focus {
  border-color: var(--ca-primary);
  box-shadow: 0 0 0 2px var(--ca-primary-glow);
}

.ca-input-box::placeholder {
  color: rgba(148, 163, 184, 0.6);
  font-size: 0.85rem;
}

.ca-send-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--ca-radius-md);
  background: var(--ca-primary);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  font-size: 1.1rem;
}

.ca-send-btn:hover:not(:disabled) {
  background: var(--ca-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--ca-primary-glow);
}

.ca-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------------- Diagnostic Modal / Offline Stepper ---------------- */
.ca-diag-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 17, 22, 0.95);
  backdrop-filter: blur(8px);
  z-index: 10;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  animation: ca-fadeIn 0.2s ease-out;
}

.ca-diag-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--ca-border-subtle);
  padding-bottom: 12px;
}

.ca-diag-header h4 {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: #fff;
  margin: 0;
}

.ca-diag-header p {
  font-size: 0.8rem;
  color: var(--ca-text-muted);
  margin: 4px 0 0 0;
}

.ca-diag-step {
  margin-bottom: 20px;
}

.ca-diag-question {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 12px;
}

.ca-diag-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ca-diag-option-btn {
  background: var(--ca-bg-card);
  border: 1px solid var(--ca-border-subtle);
  border-radius: var(--ca-radius-sm);
  padding: 12px 14px;
  color: var(--ca-text-main);
  text-align: left;
  font-size: 0.85rem;
  line-height: 1.4;
  cursor: pointer;
  transition: all 0.2s;
}

.ca-diag-option-btn:hover {
  border-color: var(--ca-primary);
  background: var(--ca-bg-card-hover);
  transform: translateX(3px);
}

.ca-diag-result-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: var(--ca-radius-md);
  padding: 18px;
  margin-top: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.ca-diag-result-card h5 {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  color: var(--ca-accent-gold);
  margin: 0 0 8px 0;
}

.ca-diag-result-card p {
  font-size: 0.88rem;
  color: var(--ca-text-main);
  margin: 0 0 12px 0;
  line-height: 1.5;
}

/* ---------------- API Key Configuration Modal ---------------- */
.ca-key-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 17, 22, 0.95);
  backdrop-filter: blur(8px);
  z-index: 15;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: ca-fadeIn 0.2s ease-out;
}

.ca-key-box {
  background: var(--ca-bg-card);
  border: 1px solid var(--ca-border-subtle);
  border-radius: var(--ca-radius-md);
  padding: 22px;
  box-shadow: var(--ca-shadow-elevated);
}

.ca-key-box h4 {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  color: #fff;
  margin: 0 0 8px 0;
}

.ca-key-box p {
  font-size: 0.82rem;
  color: var(--ca-text-muted);
  line-height: 1.5;
  margin: 0 0 14px 0;
}

.ca-key-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--ca-bg-dark);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--ca-radius-sm);
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  margin-bottom: 14px;
}

.ca-key-input:focus {
  border-color: var(--ca-primary);
}

.ca-key-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.ca-btn-save {
  background: var(--ca-primary);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--ca-radius-sm);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.ca-btn-save:hover {
  background: var(--ca-primary-hover);
}

.ca-btn-cancel {
  background: transparent;
  color: var(--ca-text-muted);
  border: 1px solid var(--ca-border-subtle);
  padding: 8px 14px;
  border-radius: var(--ca-radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
}

.ca-btn-cancel:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

/* ---------------- Loading Animation ---------------- */
.ca-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
}

.ca-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--ca-primary);
  border-radius: 50%;
  animation: ca-typing 1.4s infinite ease-in-out;
}

.ca-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ca-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ca-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ---------------- Mobile Adaptations ---------------- */
@media (max-width: 768px) {
  .ca-launcher {
    bottom: 20px;
    right: 20px;
    padding: 8px 14px;
  }
  
  .ca-launcher-subtitle {
    display: none;
  }
  
  .ca-widget-panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
}
