/* =========================================================================
   style-components.css — COMPOSANTS PARTAGÉS (toast, modal, palette…)
   ========================================================================= */

/* ---------- TOAST ---------- */
.comvia-toast {
  position: fixed;
  bottom: var(--space-7);
  right: var(--space-7);
  z-index: var(--z-toast);
  max-width: 420px;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-overlay);
  font-size: var(--text-sm);
  line-height: var(--line-normal);
  color: white;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out);
}
.comvia-toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.comvia-toast--success { background: linear-gradient(135deg, oklch(0.50 0.14 155), oklch(0.42 0.16 155)); }
.comvia-toast--error   { background: linear-gradient(135deg, oklch(0.55 0.18 25),  oklch(0.45 0.20 25)); }
.comvia-toast--info    { background: linear-gradient(135deg, var(--comvia-blue-soft), var(--comvia-blue)); }
.comvia-toast--warn    { background: linear-gradient(135deg, oklch(0.60 0.15 75),  oklch(0.50 0.16 75)); }

/* ---------- MODAL ---------- */
.comvia-modal {
  position: fixed; inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
  pointer-events: none;
}
.comvia-modal.show { opacity: 1; pointer-events: auto; }
.comvia-modal-backdrop {
  position: absolute; inset: 0;
  background: oklch(0.20 0.02 248 / 0.5);
  backdrop-filter: blur(4px);
}
.comvia-modal-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-overlay);
  max-width: 640px;
  width: 92%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.97);
  transition: transform var(--duration-base) var(--ease-out);
}
.comvia-modal.show .comvia-modal-card { transform: scale(1); }
.comvia-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.comvia-modal-head h3 { font-size: var(--text-md); margin: 0; }
.comvia-modal-close {
  font-size: 1.5rem;
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.comvia-modal-close:hover { background: var(--surface-2); }
.comvia-modal-body {
  padding: var(--space-5);
  overflow-y: auto;
}

/* ---------- COMMAND PALETTE ---------- */
.palette {
  display: flex;
  flex-direction: column;
  min-height: 320px;
  max-height: 70vh;
}
.palette-input {
  width: 100%;
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-md);
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
  background: transparent;
}
.palette-results {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) 0;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  cursor: pointer;
  font-size: var(--text-sm);
  border-left: 2px solid transparent;
}
.palette-item:hover, .palette-item.is-selected {
  background: var(--surface-2);
  border-left-color: var(--comvia-blue);
}
.palette-item-icon { width: 24px; text-align: center; }
.palette-item-label { flex: 1; font-weight: var(--weight-medium); }
.palette-item-kind {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.palette-empty {
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
}
.palette-hint {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-xs);
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* ---------- BADGE GÉNÉRIQUE ---------- */
.ui-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--ui-badge-color, var(--comvia-blue));
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
  white-space: nowrap;
}
.ui-badge-icon { font-size: 0.9rem; }

/* ---------- PLACEHOLDER PÉDAGOGIQUE ---------- */
.ui-placeholder {
  max-width: 560px;
  margin: var(--space-10) auto;
  text-align: center;
  padding: var(--space-7);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-xl);
}
.ui-placeholder-icon { font-size: 3rem; margin-bottom: var(--space-4); }
.ui-placeholder-title {
  font-size: var(--text-lg);
  margin-bottom: var(--space-3);
  color: var(--text-strong);
}
.ui-placeholder-sub {
  color: var(--text-muted);
  margin-bottom: var(--space-5);
}
.ui-placeholder-list {
  text-align: left;
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-sm);
}
.ui-placeholder-list li { margin: var(--space-2) 0; }

/* ---------- LOADER + EMPTY STATE ---------- */
.ui-loader {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.ui-spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--comvia-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ui-empty {
  padding: var(--space-7);
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  background: var(--surface-2);
  border-radius: var(--r-lg);
}

/* ---------- BADGE CONNEXION (LIVE / MOCK / À CONFIGURER) ---------- */
.conn-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--cb-bg);
  border: 1px solid var(--cb-color);
  border-left: 4px solid var(--cb-color);
  border-radius: var(--r-md);
  font-size: var(--text-xs);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.conn-badge-icon { font-size: 0.9rem; }
.conn-badge-label {
  font-weight: var(--weight-extra);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cb-color);
}
.conn-badge-source {
  color: var(--text);
  font-weight: var(--weight-semibold);
}
.conn-badge-note {
  color: var(--text-muted);
  font-style: italic;
}

/* ---------- BLOC À CONFIGURER ---------- */
.configure-block {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-xl);
  padding: var(--space-6) var(--space-7);
  margin: var(--space-5) 0;
}
.configure-block-title {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text-strong);
  margin-bottom: var(--space-3);
}
.configure-block-why {
  color: var(--text-muted);
  font-size: var(--text-base);
  margin-bottom: var(--space-4);
  line-height: 1.5;
}
.configure-block-steps {
  padding-left: var(--space-5);
  margin: var(--space-3) 0;
}
.configure-block-steps li {
  margin: var(--space-3) 0;
  font-size: var(--text-sm);
  line-height: 1.5;
}
.configure-block-steps li strong { color: var(--text-strong); }
.configure-block-agent {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.configure-block-agent strong { color: var(--comvia-blue); }

/* ====================================================================
   AGENT CHAT (modal et embed)
   ==================================================================== */
.agent-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 500px;
  max-height: 70vh;
}
.agent-chat-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: linear-gradient(90deg, oklch(0.985 0.015 248), white);
  border-bottom: 2px solid var(--ag-color, var(--comvia-blue));
}
.agent-chat-avatar { font-size: 2rem; }
.agent-chat-info { flex: 1; min-width: 0; }
.agent-chat-name { font-weight: var(--weight-bold); color: var(--text-strong); }
.agent-chat-role { font-size: var(--text-xs); color: var(--text-muted); }
.agent-chat-clear {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
}
.agent-chat-clear:hover { background: var(--surface-2); color: var(--signal-error); }

.agent-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.agent-chat-empty {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: var(--space-7);
}

.agent-msg { max-width: 85%; padding: var(--space-3) var(--space-4); border-radius: var(--r-lg); }
.agent-msg--user {
  background: var(--comvia-blue);
  color: white;
  align-self: flex-end;
}
.agent-msg--agent {
  background: white;
  border: 1px solid var(--border);
  align-self: flex-start;
}
.agent-msg--error {
  background: var(--signal-error-soft);
  border: 1px solid var(--signal-error);
  color: oklch(0.30 0.15 25);
  align-self: stretch;
  max-width: 100%;
}
.agent-msg-head {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  margin-bottom: 4px;
  opacity: 0.7;
}
.agent-msg-author { font-weight: var(--weight-semibold); }
.agent-msg-body {
  font-size: var(--text-sm);
  line-height: 1.5;
}
.agent-msg-body code {
  background: rgba(0,0,0,0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}
.agent-msg--user .agent-msg-body code { background: rgba(255,255,255,0.18); }

.agent-msg--thinking { opacity: 0.85; }
.agent-thinking {
  display: inline-flex;
  gap: 3px;
  vertical-align: middle;
}
.agent-thinking span {
  width: 5px; height: 5px;
  background: var(--comvia-blue);
  border-radius: 50%;
  animation: agentThink 1.2s infinite;
}
.agent-thinking span:nth-child(2) { animation-delay: 0.15s; }
.agent-thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes agentThink {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%      { opacity: 1; transform: scale(1.2); }
}

.agent-chat-input-row {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  background: white;
  border-top: 1px solid var(--border);
}
.agent-chat-input {
  flex: 1;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--text-base);
  font-family: inherit;
  resize: vertical;
  outline: 2px solid transparent;
  transition: outline-color var(--duration-fast) var(--ease-out);
}
.agent-chat-input:focus { outline-color: var(--comvia-blue); }
.agent-chat-send {
  padding: var(--space-3) var(--space-5);
  background: var(--comvia-blue);
  color: white;
  border-radius: var(--r-md);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  white-space: nowrap;
}
.agent-chat-send:hover:not(:disabled) { background: var(--comvia-blue-deep); }
.agent-chat-send:disabled { opacity: 0.5; cursor: wait; }

.agent-chat-hint {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-faint);
  text-align: center;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}
