/* agent_styles.css — Widget flottant Agent IA Zonify */

/* ─── Variables ──────────────────────────────────────────────────────────── */
:root {
  --znf-accent:      #2563EB;
  --znf-accent-dark: #1D4ED8;
  --znf-bg:          #FFFFFF;
  --znf-bg-2:        #F8F9FA;
  --znf-border:      #E5E7EB;
  --znf-text:        #111827;
  --znf-text-2:      #6B7280;
  --znf-user-bg:     #2563EB;
  --znf-user-text:   #FFFFFF;
  --znf-error:       #EF4444;
  --znf-success:     #10B981;
  --znf-radius:      14px;
  --znf-shadow:      0 4px 24px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
  --znf-z:           9999;
  --znf-panel-w:     360px;
  --znf-panel-h:     520px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --znf-bg:      #1F2937;
    --znf-bg-2:    #111827;
    --znf-border:  #374151;
    --znf-text:    #F9FAFB;
    --znf-text-2:  #9CA3AF;
  }
}

/* ─── Conteneur global ───────────────────────────────────────────────────── */
#znf-agent {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--znf-z);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ─── Bouton flottant (FAB) ──────────────────────────────────────────────── */
#znf-fab {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--znf-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--znf-shadow);
  transition: transform 0.18s ease, background 0.18s ease;
  outline: none;
}

#znf-fab:hover  { background: var(--znf-accent-dark); transform: scale(1.06); }
#znf-fab:active { transform: scale(0.97); }
#znf-fab:focus-visible { box-shadow: 0 0 0 3px rgba(37,99,235,0.4); }

/* Badge erreur */
.znf-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--znf-error);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  transition: opacity 0.2s;
}
.znf-hidden { opacity: 0; pointer-events: none; }

/* ─── Panel de chat ──────────────────────────────────────────────────────── */
.znf-panel {
  position: absolute;
  bottom: 64px;
  right: 0;
  width: var(--znf-panel-w);
  max-height: var(--znf-panel-h);
  background: var(--znf-bg);
  border: 1px solid var(--znf-border);
  border-radius: var(--znf-radius);
  box-shadow: var(--znf-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transition: transform 0.22s cubic-bezier(0.4,0,0.2,1),
              opacity  0.22s cubic-bezier(0.4,0,0.2,1);
}

.znf-closed {
  transform: scale(0.88) translateY(8px);
  opacity: 0;
  pointer-events: none;
}
.znf-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.znf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--znf-border);
  background: var(--znf-bg);
  flex-shrink: 0;
}

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

.znf-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--znf-accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.znf-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--znf-text);
}

.znf-header-sub {
  font-size: 11px;
  color: var(--znf-success);
}

.znf-header-actions {
  display: flex;
  gap: 4px;
}

.znf-icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--znf-text-2);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.znf-icon-btn:hover { background: var(--znf-bg-2); color: var(--znf-text); }

/* ─── Zone de messages ───────────────────────────────────────────────────── */
.znf-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.znf-messages::-webkit-scrollbar { width: 4px; }
.znf-messages::-webkit-scrollbar-thumb { background: var(--znf-border); border-radius: 2px; }

/* ─── Messages ───────────────────────────────────────────────────────────── */
.znf-msg {
  display: flex;
  flex-direction: column;
  max-width: 90%;
}

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

.znf-msg-assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.znf-bubble {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.znf-msg-user .znf-bubble {
  background: var(--znf-user-bg);
  color: var(--znf-user-text);
  border-bottom-right-radius: 4px;
}

.znf-msg-assistant .znf-bubble {
  background: var(--znf-bg-2);
  color: var(--znf-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--znf-border);
}

.znf-bubble code {
  background: rgba(0,0,0,0.08);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 12px;
  font-family: "SF Mono", "Fira Code", monospace;
}

/* ─── Indicateur de frappe ───────────────────────────────────────────────── */
.znf-typing .znf-bubble {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 14px;
}

.znf-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--znf-text-2);
  animation: znf-bounce 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
.znf-dot:nth-child(2) { animation-delay: 0.2s; }
.znf-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes znf-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

/* ─── Bouton Appliquer ───────────────────────────────────────────────────── */
.znf-apply-btn {
  margin-top: 6px;
  padding: 6px 14px;
  background: var(--znf-success);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}
.znf-apply-btn:hover  { opacity: 0.88; }
.znf-apply-btn:active { transform: scale(0.97); }

/* ─── Zone de saisie ─────────────────────────────────────────────────────── */
.znf-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--znf-border);
  background: var(--znf-bg);
  flex-shrink: 0;
}

.znf-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--znf-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--znf-text);
  background: var(--znf-bg-2);
  outline: none;
  min-height: 36px;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.15s;
  line-height: 1.5;
}
.znf-input:focus { border-color: var(--znf-accent); }
.znf-input::placeholder { color: var(--znf-text-2); }

.znf-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--znf-accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.12s;
}
.znf-send-btn:hover  { background: var(--znf-accent-dark); }
.znf-send-btn:active { transform: scale(0.95); }

/* ─── Suggestions rapides ────────────────────────────────────────────────── */
.znf-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 10px;
  background: var(--znf-bg);
  flex-shrink: 0;
}

.znf-chip {
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--znf-border);
  background: var(--znf-bg-2);
  color: var(--znf-text-2);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.znf-chip:hover {
  border-color: var(--znf-accent);
  color: var(--znf-accent);
  background: rgba(37,99,235,0.05);
}

/* ─── Responsive mobile ──────────────────────────────────────────────────── */
@media (max-width: 420px) {
  #znf-agent { bottom: 16px; right: 16px; }
  .znf-panel {
    width: calc(100vw - 32px);
    right: 0;
    bottom: 60px;
    max-height: calc(100vh - 120px);
  }
}

/* ─── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .znf-panel  { transition: opacity 0.15s; }
  #znf-fab    { transition: background 0.15s; }
  .znf-dot    { animation: none; opacity: 0.5; }
}
