/* ==========================================================================
   AURA-MEET - WIDGET ASSISTANT VIRTUEL PERSISTANT & PERSONNALISABLE
   Style moderne, ergonomique, réactif et compatible multi-plateformes
   ========================================================================== */

:root {
  --widget-primary: #0f172a;
  --widget-accent: #e20020; /* IHEID Red */
  --widget-bg: #ffffff;
  --widget-border: #e2e8f0;
  --widget-text: #1e293b;
  --widget-muted: #64748b;
  --widget-bubble-bot: #f8fafc;
  --widget-bubble-user: #0f172a;
  --widget-shadow: 0 12px 36px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
  --widget-primary: #0b1120;
  --widget-bg: #070a13;
  --widget-border: rgba(56, 189, 248, 0.22);
  --widget-text: #f8fafc;
  --widget-muted: #94a3b8;
  --widget-bubble-bot: #0e1626;
  --widget-bubble-user: #00c4ff;
  --widget-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 25px rgba(0, 196, 255, 0.15);
}

/* Conteneur Flottant Global */
.aura-widget-container {
  position: fixed;
  z-index: 99999;
  font-family: inherit;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}

.aura-widget-container * {
  box-sizing: border-box;
}

.aura-widget-container.pos-bottom-right {
  bottom: 24px;
  right: 24px;
  align-items: flex-end;
}

.aura-widget-container.pos-bottom-left {
  bottom: 24px;
  left: 24px;
  align-items: flex-start;
}

/* Bouton Flottant (FAB) */
.aura-widget-fab {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--widget-primary);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  padding: 0.65rem 1.15rem;
  box-shadow: var(--widget-shadow);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, background-color 0.2s ease;
  user-select: none;
}

.aura-widget-fab:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.24);
  background: #1e293b;
}

.aura-widget-fab:active {
  transform: translateY(0) scale(0.98);
}

.aura-widget-fab-avatar {
  font-size: 1.35rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.aura-widget-pulse-badge {
  position: absolute;
  top: -2px;
  right: -3px;
  width: 9px;
  height: 9px;
  background-color: #10b981;
  border-radius: 50%;
  border: 2px solid var(--widget-primary);
  animation: pulse-green 2.2s infinite;
}

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.aura-widget-fab-label {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Fenêtre de Chat Rétractable */
.aura-widget-window {
  pointer-events: auto;
  position: relative;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: var(--widget-bg);
  color: var(--widget-text);
  border: 1px solid var(--widget-border);
  border-radius: 18px;
  box-shadow: var(--widget-shadow);
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  overflow: hidden;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom right;
}

.aura-widget-container.pos-bottom-left .aura-widget-window {
  transform-origin: bottom left;
}

.aura-widget-window.hidden {
  opacity: 0;
  transform: scale(0.92) translateY(20px);
  pointer-events: none;
  display: none !important;
}

/* En-tête du Widget */
.aura-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: var(--widget-primary);
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.aura-widget-header-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.aura-widget-avatar-display {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.aura-widget-header-title-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.aura-widget-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.aura-widget-status-badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  font-weight: 600;
}

.aura-widget-persona-sub {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 1px;
}

.aura-widget-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.aura-widget-icon-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.95rem;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.aura-widget-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

/* Bandeau de Contexte Actif */
.aura-widget-context-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  background: rgba(226, 0, 32, 0.06);
  border-bottom: 1px solid rgba(226, 0, 32, 0.12);
  font-size: 0.72rem;
  color: var(--widget-accent);
  font-weight: 500;
}

.aura-widget-context-bar .context-icon {
  font-size: 0.8rem;
}

/* Zone des Messages */
.aura-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--widget-bg);
  scroll-behavior: smooth;
}

.aura-msg-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  animation: fadeIn 0.2s ease forwards;
}

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

.aura-msg-row.user {
  justify-content: flex-end;
}

.aura-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.aura-msg-bubble {
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.45;
  max-width: 82%;
  word-break: break-word;
}

.aura-msg-row.user .aura-msg-bubble {
  background: var(--widget-bubble-user);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.aura-msg-row.bot .aura-msg-bubble {
  background: var(--widget-bubble-bot);
  color: var(--widget-text);
  border: 1px solid var(--widget-border);
  border-bottom-left-radius: 4px;
}

.aura-msg-bubble h3, .aura-msg-bubble h4 {
  margin: 0.4rem 0 0.2rem 0;
  color: var(--widget-accent);
  font-size: 0.85rem;
}

.aura-msg-bubble strong {
  font-weight: 600;
}

.aura-msg-bubble em {
  color: var(--widget-muted);
}

.aura-msg-time {
  font-size: 0.65rem;
  color: var(--widget-muted);
  margin-top: 0.25rem;
  display: block;
}

/* Suggestions Rapides */
.aura-widget-suggestions {
  display: flex;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  background: rgba(0, 0, 0, 0.01);
  border-top: 1px solid var(--widget-border);
}

.aura-widget-suggestions::-webkit-scrollbar {
  display: none;
}

.widget-chip {
  background: var(--widget-bubble-bot);
  border: 1px solid var(--widget-border);
  color: var(--widget-text);
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.widget-chip:hover {
  background: var(--widget-accent);
  color: #ffffff;
  border-color: var(--widget-accent);
}

/* Zone de Saisie */
.aura-widget-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 0.85rem;
  background: var(--widget-bg);
  border-top: 1px solid var(--widget-border);
}

.aura-widget-input {
  flex: 1;
  background: var(--widget-bubble-bot);
  border: 1px solid var(--widget-border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.825rem;
  color: var(--widget-text);
  outline: none;
  transition: border-color 0.15s ease;
}

.aura-widget-input:focus {
  border-color: var(--widget-accent);
}

.aura-widget-action-btn, .aura-widget-send-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.aura-widget-action-btn {
  background: var(--widget-bubble-bot);
  border: 1px solid var(--widget-border);
  color: var(--widget-muted);
  font-size: 0.95rem;
}

.aura-widget-action-btn:hover {
  background: var(--widget-border);
  color: var(--widget-text);
}

.aura-widget-action-btn.recording {
  background: #fee2e2;
  color: #dc2626;
  border-color: #ef4444;
  animation: pulse-red 1.2s infinite;
}

@keyframes pulse-red {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.aura-widget-send-btn {
  background: var(--widget-accent);
  color: #ffffff;
  font-size: 0.85rem;
}

.aura-widget-send-btn:hover {
  background: #b91c1c;
  transform: translateY(-1px);
}

/* Volet des Paramètres de Personnalisation */
.aura-widget-settings-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--widget-bg);
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow-y: auto;
  animation: slideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.aura-widget-settings-panel.hidden {
  display: none !important;
}

.aura-widget-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--widget-border);
}

.aura-widget-settings-header h5 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--widget-text);
}

.aura-settings-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--widget-muted);
  margin: 0.75rem 0 0.35rem 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.aura-avatar-picker {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.avatar-opt {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--widget-bubble-bot);
  border: 2px solid var(--widget-border);
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.avatar-opt:hover {
  transform: translateY(-2px);
  border-color: var(--widget-accent);
}

.avatar-opt.active {
  border-color: var(--widget-accent);
  background: rgba(226, 0, 32, 0.08);
}

.aura-settings-actions {
  margin-top: 1.25rem;
}


/* ==========================================================================
   FORGE DU HÉROS SOUVERAIN (AVATAR 3D RPG)
   ========================================================================== */

.aura-widget-forge-panel {
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--widget-bg);
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow-y: auto;
  animation: slideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.aura-widget-forge-panel.hidden {
  display: none !important;
}

.aura-widget-forge-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.aura-widget-class-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(226, 0, 32, 0.1);
  color: var(--widget-accent);
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  border: 1px solid rgba(226, 0, 32, 0.2);
}

.aura-widget-status-badge {
  font-size: 0.62rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
}

.aura-widget-persona-sub {
  font-size: 0.68rem;
  color: var(--widget-muted);
  margin-top: 0.15rem;
}

.aura-rpg-preview-box {
  display: flex;
  gap: 0.75rem;
  background: var(--widget-bubble-bot);
  border: 1px solid var(--widget-border);
  border-radius: 12px;
  padding: 0.75rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.aura-rpg-canvas {
  width: 110px;
  height: 110px;
  border-radius: 10px;
  background: radial-gradient(circle, rgba(226,0,32,0.1) 0%, rgba(15,23,42,0.2) 100%);
  border: 1px solid var(--widget-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.aura-rpg-stats-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.72rem;
}

.rpg-stat-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--widget-text);
  font-weight: 600;
}

.aura-rpg-class-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.rpg-class-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.25rem;
  border-radius: 8px;
  background: var(--widget-bubble-bot);
  border: 1px solid var(--widget-border);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.rpg-class-card:hover {
  transform: translateY(-2px);
  border-color: var(--widget-accent);
}

.rpg-class-card.selected {
  border-color: var(--widget-accent);
  background: rgba(226, 0, 32, 0.1);
  box-shadow: 0 0 0 1px var(--widget-accent);
}

.rpg-class-icon {
  font-size: 1.25rem;
  margin-bottom: 0.15rem;
}

.rpg-class-name {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--widget-text);
  line-height: 1.15;
}

.aura-color-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.4rem;
}

.color-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--widget-border);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-dot:hover {
  transform: scale(1.15);
}

.color-dot.active {
  border-color: var(--widget-accent);
  box-shadow: 0 0 0 2px rgba(226, 0, 32, 0.4);
}
