/* ================================================================
   Doorn Digitaal – Ruard AI Gastheer · Widget Styles
   ================================================================ */

:root {
  --ddh-primary:    #2d4a2a;   /* overridden by wp_localize_script */
  --ddh-accent:     #c47c2b;
  --ddh-cream:      #f5ede0;
  --ddh-linen:      #faf4eb;
  --ddh-border:     #e0ccaa;
  --ddh-text:       #3a2810;
  --ddh-muted:      #7a6248;
  --ddh-radius:     20px;
  --ddh-shadow:     0 16px 48px rgba(0,0,0,0.22), 0 4px 12px rgba(0,0,0,0.12);
  --ddh-z:          99999;
  --ddh-width:      368px;
  --ddh-font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── CONTAINER ──────────────────────────────────────────────── */
#ddr-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--ddh-z);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: var(--ddh-font);
  font-size: 14px;
  line-height: 1.5;
}

#ddr-widget.ddr-bottom-left {
  right: auto;
  left: 24px;
  align-items: flex-start;
}

/* ── PANEL ──────────────────────────────────────────────────── */
.ddr-panel {
  width: var(--ddh-width);
  max-width: calc(100vw - 32px);
  background: var(--ddh-cream);
  border-radius: var(--ddh-radius);
  overflow: hidden;
  box-shadow: var(--ddh-shadow);
  display: flex;
  flex-direction: column;
  transform-origin: bottom right;
}

#ddr-widget.ddr-bottom-left .ddr-panel {
  transform-origin: bottom left;
}

/* Hidden state */
#ddr-widget.ddr-closed .ddr-panel {
  display: none;
}

/* Open animation */
#ddr-widget.ddr-open .ddr-panel {
  animation: ddhSlideUp 0.32s cubic-bezier(0.34,1.2,0.64,1) both;
}

@keyframes ddhSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── HEADER ─────────────────────────────────────────────────── */
.ddr-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--ddh-primary);
  position: relative;
}

.ddr-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 80% 50%, rgba(196,124,43,0.12), transparent 60%);
  pointer-events: none;
}

.ddr-header-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--ddh-accent);
  flex-shrink: 0;
  position: relative;
}

.ddr-header-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 10%;
  display: block;
}

.ddr-header-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ddr-header-name {
  color: var(--ddh-cream);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.1px;
}

.ddr-header-role {
  color: rgba(245,237,224,0.55);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ddr-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #7dd99a;
  font-size: 11px;
}

/* Online dots */
.ddr-online-dot,
.ddr-status-dot {
  width: 8px; height: 8px;
  background: #4caf73;
  border-radius: 50%;
  flex-shrink: 0;
  animation: ddhPulse 2s ease infinite;
}

.ddr-header-avatar .ddr-online-dot {
  position: absolute;
  bottom: 2px; right: 2px;
  border: 2px solid var(--ddh-primary);
}

@keyframes ddhPulse {
  0%, 100% { box-shadow: 0 0 0 0   rgba(76,175,115,0.5); }
  50%       { box-shadow: 0 0 0 4px rgba(76,175,115,0); }
}

.ddr-close-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  color: rgba(245,237,224,0.7);
}

.ddr-close-btn:hover { background: rgba(255,255,255,0.2); color: var(--ddh-cream); }
.ddr-close-btn svg { width: 16px; height: 16px; }

/* ── MESSAGES ───────────────────────────────────────────────── */
.ddr-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 300px;
  background: var(--ddh-cream);
  scroll-behavior: smooth;
}

.ddr-messages::-webkit-scrollbar { width: 4px; }
.ddr-messages::-webkit-scrollbar-thumb { background: #d0b890; border-radius: 4px; }

/* Individual messages */
.ddr-msg {
  display: flex;
  gap: 9px;
  align-items: flex-end;
  animation: ddhMsgIn 0.25s ease both;
}

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

.ddr-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  overflow: hidden;
  border: 1.5px solid var(--ddh-accent);
  flex-shrink: 0;
}

.ddr-msg-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 10%;
  display: block;
}

.ddr-msg-bubble {
  background: #fff;
  border-radius: 16px 16px 16px 4px;
  padding: 10px 13px;
  max-width: 260px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ddh-text);
  box-shadow: 0 2px 6px rgba(0,0,0,0.07);
  word-break: break-word;
}

/* User messages */
.ddr-msg.ddr-user {
  flex-direction: row-reverse;
}

.ddr-msg.ddr-user .ddr-msg-bubble {
  background: var(--ddh-primary);
  color: var(--ddh-cream);
  border-radius: 16px 16px 4px 16px;
}

/* Typing indicator */
.ddr-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 11px 14px;
  background: #fff;
  border-radius: 16px 16px 16px 4px;
  width: fit-content;
  box-shadow: 0 2px 6px rgba(0,0,0,0.07);
}

.ddr-typing span {
  width: 6px; height: 6px;
  background: #c0a080;
  border-radius: 50%;
  animation: ddhBounce 1.2s ease infinite;
}

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

@keyframes ddhBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-5px); }
}

/* ── QUICK REPLIES ──────────────────────────────────────────── */
.ddr-quick-wrap {
  padding: 4px 16px 12px;
}

.ddr-quick-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ddh-muted);
  margin-bottom: 7px;
}

.ddr-quick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ddr-quick-btn {
  background: #fff;
  border: 1.5px solid var(--ddh-border);
  border-radius: 20px;
  padding: 6px 13px;
  font-size: 12.5px;
  color: var(--ddh-text);
  cursor: pointer;
  font-family: var(--ddh-font);
  transition: background 0.14s, border-color 0.14s, color 0.14s, transform 0.12s;
  line-height: 1.3;
}

.ddr-quick-btn:hover {
  background: var(--ddh-primary);
  border-color: var(--ddh-primary);
  color: var(--ddh-cream);
  transform: translateY(-1px);
}

.ddr-quick-btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

/* ── INPUT BAR ──────────────────────────────────────────────── */
.ddr-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1.5px solid var(--ddh-border);
  background: var(--ddh-linen);
}

.ddr-input {
  flex: 1;
  background: #fff;
  border: 1.5px solid var(--ddh-border);
  border-radius: 24px;
  padding: 9px 15px;
  font-size: 13.5px;
  font-family: var(--ddh-font);
  color: var(--ddh-text);
  outline: none;
  transition: border-color 0.15s;
}

.ddr-input::placeholder { color: #b8a080; }
.ddr-input:focus { border-color: var(--ddh-accent); }

.ddr-send-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--ddh-accent);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: background 0.14s, transform 0.14s;
  box-shadow: 0 2px 8px rgba(196,124,43,0.35);
}

.ddr-send-btn:hover { background: #d98c35; transform: scale(1.07); }
.ddr-send-btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.ddr-send-btn svg { width: 16px; height: 16px; }

/* ── FOOTER ─────────────────────────────────────────────────── */
.ddr-footer {
  padding: 7px 16px 9px;
  text-align: center;
  font-size: 10.5px;
  color: #b8a080;
  background: var(--ddh-linen);
  border-top: 1px solid #f0e4cc;
  margin: 0;
}

/* ── BUBBLE (collapsed) ─────────────────────────────────────── */
.ddr-bubble {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--ddh-primary);
  border: none;
  border-radius: 50px;
  padding: 9px 18px 9px 9px;
  cursor: pointer;
  box-shadow: var(--ddh-shadow);
  transition: transform 0.18s, box-shadow 0.18s;
  font-family: var(--ddh-font);
}

.ddr-bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 48px rgba(0,0,0,0.28), 0 4px 12px rgba(196,124,43,0.18);
}

#ddr-widget.ddr-open .ddr-bubble {
  display: none;
}

.ddr-bubble-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--ddh-accent);
  flex-shrink: 0;
  position: relative;
  display: block;
}

.ddr-bubble-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 10%;
  display: block;
}

.ddr-bubble-avatar .ddr-online-dot {
  position: absolute;
  bottom: 1px; right: 1px;
  border: 2px solid var(--ddh-primary);
}

.ddr-bubble-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.ddr-bubble-text strong {
  display: block;
  color: var(--ddh-cream);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
}

.ddr-bubble-text span {
  font-size: 11.5px;
  color: rgba(245,237,224,0.55);
}

.ddr-bubble-arrow {
  color: rgba(245,237,224,0.4);
  font-size: 16px;
  margin-left: 4px;
}

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  #ddr-widget {
    bottom: 16px;
    right: 12px;
  }

  #ddr-widget.ddr-bottom-left {
    left: 12px;
  }

  .ddr-panel {
    width: calc(100vw - 24px);
    max-width: 100%;
  }
}

/* Error message */
.ddr-error {
  color: #c0392b;
  font-style: italic;
  font-size: 13px;
}
