/* Public digital guide — chatbot-style floating widget */
:root {
  --dg-bg: #f7f8f6;
  --dg-text: #1a1a1a;
  --dg-border: #e4e6e1;
  --dg-accent: #c2410c;
  --dg-navy: #3e547f;
  --dg-navy-soft: #eef1f7;
  --dg-gold: #c8a96e;
  --dg-online: #22c55e;
  --dg-panel-w: 480px;
  --dg-panel-h: 780px;
}

#dg-root {
  position: fixed;
  z-index: 99990;
  right: 1rem;
  bottom: 1rem;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--dg-text);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
}

/* Launcher + Eurobank-style hover tip */
#dg-launch-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
}
#dg-hover-tip {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.7rem);
  width: min(380px, calc(100vw - 1.5rem));
  min-width: min(300px, calc(100vw - 1.5rem));
  background: linear-gradient(165deg, #ffffff 0%, #f7f8fc 100%);
  color: var(--dg-text);
  border: 1px solid rgba(62, 84, 127, 0.14);
  border-radius: 18px;
  padding: 0.95rem 1.15rem 1rem;
  font-family: var(--font-body, "DM Sans", system-ui, sans-serif);
  font-size: 0.92rem;
  line-height: 1.45;
  font-weight: 500;
  box-shadow:
    0 14px 36px rgba(20, 30, 50, 0.18),
    0 2px 0 rgba(200, 169, 110, 0.35) inset;
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.22s ease;
  z-index: 2;
  text-align: left;
}
#dg-hover-tip::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--dg-navy) 0%, var(--dg-gold) 100%);
}
#dg-hover-tip::after {
  content: "";
  position: absolute;
  right: 1.55rem;
  bottom: -7px;
  width: 13px;
  height: 13px;
  background: #fafbfd;
  border-right: 1px solid rgba(62, 84, 127, 0.14);
  border-bottom: 1px solid rgba(62, 84, 127, 0.14);
  transform: rotate(45deg);
}
#dg-hover-tip .dg-tip-greet {
  margin: 0 0 0.2rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #6a7385;
  text-transform: none;
}
#dg-hover-tip .dg-tip-name-line {
  margin: 0 0 0.4rem;
  font-size: 0.98rem;
  color: var(--dg-navy);
  font-weight: 500;
  line-height: 1.35;
}
#dg-hover-tip .dg-tip-name {
  font-family: var(--font-display, Fraunces, Georgia, serif);
  font-size: 1.22rem;
  font-weight: 700;
  color: var(--dg-navy);
  letter-spacing: -0.01em;
}
#dg-hover-tip .dg-tip-comma,
#dg-hover-tip .dg-tip-role {
  font-family: var(--font-body, "DM Sans", system-ui, sans-serif);
  font-size: 0.95rem;
  font-weight: 500;
  color: #4a5568;
}
#dg-hover-tip .dg-tip-body {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--dg-navy);
  line-height: 1.45;
}
#dg-hover-tip .dg-tip-emoji {
  font-style: normal;
  margin-left: 0.15rem;
}

/* Terms acceptance gate (Eurobank-style) — sticky above composer */
#dg-terms {
  flex-shrink: 0;
  padding: 0.55rem 0.75rem 0.7rem;
  background: #eef1f6;
  border-top: 1px solid transparent;
  z-index: 3;
}
#dg-terms:not([hidden]) {
  border-top-color: var(--dg-border);
  box-shadow: 0 -6px 16px rgba(20, 30, 50, 0.06);
}
.dg-terms-card {
  background: #fff;
  border: 2px solid var(--dg-navy);
  border-radius: 14px;
  padding: 0.85rem 0.9rem;
  box-shadow: 0 4px 14px rgba(44, 63, 99, 0.12);
}
.dg-terms-title {
  margin: 0 0 0.55rem;
  font-family: var(--font-display, Fraunces, Georgia, serif);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--dg-navy);
}
.dg-terms-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  cursor: pointer;
  margin: 0 0 0.65rem;
  font-size: 0.84rem;
  line-height: 1.45;
  color: #2f3747;
}
.dg-terms-row input[type="checkbox"] {
  margin-top: 0.15rem;
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  accent-color: var(--dg-navy);
  cursor: pointer;
}
.dg-terms-link {
  color: var(--dg-navy);
  font-weight: 700;
  text-decoration: underline;
}
.dg-terms-accept {
  display: block;
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  background: var(--dg-navy);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.dg-terms-accept:disabled {
  background: #c5ccd8;
  color: #fff;
  cursor: not-allowed;
  opacity: 1;
}
.dg-terms-accept:not(:disabled):hover {
  background: #2c3f63;
}
#dg-root.is-terms-locked #dg-form {
  opacity: 0.55;
}
#dg-root.is-terms-locked #dg-input {
  cursor: not-allowed;
}
#dg-launch-wrap:hover #dg-hover-tip,
#dg-launch-wrap:focus-within #dg-hover-tip,
#dg-root.is-tip-open #dg-hover-tip {
  opacity: 1;
  transform: translateY(0) scale(1);
}
#dg-root.is-open #dg-hover-tip { display: none; }

#dg-launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4.1rem;
  height: 4.1rem;
  border: 3px solid #fff;
  border-radius: 50%;
  padding: 0;
  background: linear-gradient(145deg, #3e547f 0%, #2c3f63 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(62, 84, 127, 0.4);
  overflow: visible;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
#dg-launcher:hover,
#dg-launcher:focus-visible {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 30px rgba(62, 84, 127, 0.48);
  outline: none;
}
#dg-launcher-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
#dg-launcher .dg-icon { width: 1.4rem; height: 1.4rem; }
#dg-launcher-status {
  position: absolute;
  right: 0.05rem;
  bottom: 0.05rem;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: var(--dg-online);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
  animation: dg-online-pulse 2s ease-in-out infinite;
}
#dg-launch-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
@keyframes dg-online-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2); }
  50% { box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.12); }
}

#dg-panel {
  display: none;
  flex-direction: column;
  width: min(var(--dg-panel-w), calc(100vw - 1.25rem));
  height: min(var(--dg-panel-h), calc(100vh - 2.5rem));
  margin-bottom: 0;
  background: var(--dg-bg);
  border: 1px solid var(--dg-border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 22px 56px rgba(20, 30, 50, 0.26);
  animation: dg-panel-in 0.22s ease;
}
@keyframes dg-panel-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
#dg-root.is-open #dg-panel { display: flex; }
#dg-root.is-open #dg-launch-wrap { display: none; }

#dg-crisis {
  background: var(--dg-accent);
  color: #fff;
  font-size: 0.78rem;
  padding: 0.55rem 0.75rem;
  line-height: 1.35;
}
#dg-crisis a { color: #fff; font-weight: 700; text-decoration: underline; }

#dg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--dg-border);
  background: #fff;
}
.dg-head-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  color: var(--dg-navy);
}
#dg-avatar {
  position: relative;
  flex-shrink: 0;
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #3e547f 0%, #2c3f63 100%);
  border: 2px solid #fff;
  color: #fff;
  box-shadow: 0 2px 8px rgba(44, 63, 99, 0.22);
  overflow: visible;
}
#dg-avatar .dg-avatar-svg {
  width: 1.15rem;
  height: 1.15rem;
  display: block;
}
#dg-avatar img,
.dg-msg-avatar img,
#dg-launcher-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
#dg-avatar-status {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  background: var(--dg-online);
  border: 2px solid #fff;
}
#dg-avatar.is-speaking {
  box-shadow: 0 0 0 3px rgba(62, 84, 127, 0.28);
  animation: dg-pulse 1.2s ease-in-out infinite;
}
#dg-header strong {
  font-size: 0.95rem;
  color: var(--dg-navy);
  display: block;
  line-height: 1.2;
}
.dg-head-text { min-width: 0; }
.dg-status-line {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: #15803d;
  font-weight: 600;
  margin-top: 0.12rem;
}
.dg-status-line::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--dg-online);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
  flex-shrink: 0;
}
.dg-disclosure {
  display: block;
  font-size: 0.66rem;
  color: #6a7385;
  font-weight: 400;
  margin: 0.08rem 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dg-head-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
#dg-new {
  border: 1px solid var(--dg-border);
  background: #fff;
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 0.28rem 0.55rem;
  cursor: pointer;
  color: var(--dg-navy);
  font-weight: 600;
}
#dg-new:hover { background: var(--dg-navy-soft); }
#dg-voice,
#dg-min,
#dg-close {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--dg-border);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  color: var(--dg-navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
#dg-voice:hover,
#dg-min:hover,
#dg-close:hover {
  background: #f3f0ec;
  border-color: #d4d0c8;
  color: #111;
}
#dg-voice svg,
#dg-min svg,
#dg-close svg { width: 14px; height: 14px; display: block; }
#dg-voice.is-on {
  background: var(--dg-navy);
  border-color: var(--dg-navy);
  color: #fff;
}

#dg-msgs {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  background: linear-gradient(180deg, #eef1f6 0%, var(--dg-bg) 42%);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #c5ccd8 transparent;
}
#dg-msgs::-webkit-scrollbar { width: 7px; }
#dg-msgs::-webkit-scrollbar-thumb {
  background: #c5ccd8;
  border-radius: 999px;
}
.dg-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  max-width: 100%;
}
.dg-msg-row.user { flex-direction: row-reverse; align-self: flex-end; }
.dg-msg-row.bot { align-self: stretch; }
.dg-msg-stack {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-width: calc(100% - 2.4rem);
  min-width: 0;
}
.dg-msg-row.user .dg-msg-stack { align-items: flex-end; }
.dg-msg-row.bot .dg-msg-stack { align-items: flex-start; }
.dg-msg-time {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: #7a8290;
  line-height: 1;
  padding: 0 0.2rem;
  user-select: none;
}
.dg-msg-row.user .dg-msg-time { color: #8b93a3; }
.dg-msg-avatar {
  flex-shrink: 0;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #3e547f 0%, #2c3f63 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  margin-bottom: 0.1rem;
  box-shadow: 0 1px 3px rgba(44, 63, 99, 0.18);
  overflow: hidden;
}
.dg-msg-avatar .dg-avatar-svg {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
}
.dg-msg-avatar.is-speaking {
  box-shadow: 0 0 0 2px rgba(62, 84, 127, 0.32);
  animation: dg-pulse 1.2s ease-in-out infinite;
}
@keyframes dg-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.dg-bubble {
  max-width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.dg-bubble a,
.dg-bubble code,
.dg-cites a {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.dg-bubble.user {
  background: var(--dg-navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.dg-bubble.bot {
  background: #fff;
  border: 1px solid var(--dg-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.dg-bubble.bot strong {
  font-weight: 700;
  color: var(--dg-navy);
}

.dg-bubble-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.45rem;
}
.dg-links {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
}
.dg-links a {
  color: var(--dg-navy);
  text-decoration: underline;
  font-size: 0.85rem;
}

.dg-play {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--dg-border);
  background: var(--dg-navy-soft);
  color: var(--dg-navy);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.28rem 0.65rem;
}
.dg-play:hover { background: #e3e8f2; }
.dg-play.is-playing {
  background: var(--dg-navy);
  color: #fff;
  border-color: var(--dg-navy);
}
.dg-play svg { width: 12px; height: 12px; flex-shrink: 0; }

/* Rating card */
#dg-rating-slot:empty { display: none; }
#dg-rating-slot {
  padding: 0.65rem 0.85rem 0.75rem;
  border-top: 1px solid var(--dg-border);
  background: #fff;
  flex-shrink: 0;
}
.dg-rating-card {
  border: 1px solid var(--dg-border);
  border-radius: 14px;
  background: linear-gradient(180deg, #fff, #fafaf8);
  padding: 0.75rem 0.8rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.dg-rating-card .dg-rating-title {
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--dg-navy);
  margin: 0 0 0.55rem;
  line-height: 1.35;
}
.dg-rating {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  justify-content: space-between;
}
.dg-rating button {
  flex: 1;
  min-width: 0;
  min-height: 2.55rem;
  border: 1px solid var(--dg-border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--dg-navy);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}
.dg-rating button:hover {
  background: var(--dg-navy-soft);
  border-color: #c5cede;
  transform: translateY(-1px);
}
.dg-rating button.is-selected {
  background: var(--dg-navy);
  color: #fff;
  border-color: var(--dg-navy);
}
.dg-rating-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 0.3rem;
  font-size: 0.65rem;
  color: #7a8494;
}
.dg-rating-reason {
  width: 100%;
  margin-top: 0.55rem;
  border: 1px solid var(--dg-border);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
  outline: none;
  box-sizing: border-box;
}
.dg-rating-reason:focus {
  border-color: var(--dg-navy);
  box-shadow: 0 0 0 3px rgba(62, 84, 127, 0.12);
}
.dg-rating-skip {
  display: block;
  width: 100%;
  margin-top: 0.45rem;
  border: none;
  background: transparent;
  color: #6a7385;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 8px;
}
.dg-rating-skip:hover { background: #f3f4f1; color: var(--dg-navy); }

.dg-bubble.dg-typing {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  opacity: 0.9;
  font-size: 0.85rem;
  color: #5a6578;
}
.dg-thinking-label { font-weight: 500; }
.dg-dots {
  display: inline-flex;
  gap: 0.2rem;
  align-items: center;
}
.dg-dots i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dg-navy);
  opacity: 0.35;
  animation: dg-bounce 1.1s infinite ease-in-out;
}
.dg-dots i:nth-child(2) { animation-delay: 0.15s; }
.dg-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dg-bounce {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.dg-cites { margin-top: 0.45rem; font-size: 0.75rem; }
.dg-cites a {
  display: inline-block;
  margin: 0.15rem 0.3rem 0 0;
  color: var(--dg-navy);
}

#dg-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem 0.55rem;
  flex-shrink: 0;
  border-top: 1px solid var(--dg-border);
  background: #fff;
  max-height: 5.5rem;
  overflow-y: auto;
}
#dg-suggest button {
  border: 1px solid var(--dg-border);
  background: #fff;
  border-radius: 999px;
  padding: 0.28rem 0.6rem;
  font-size: 0.72rem;
  cursor: pointer;
  color: var(--dg-navy);
}

#dg-form {
  display: flex;
  gap: 0.4rem;
  padding: 0.65rem 0.7rem;
  border-top: 1px solid var(--dg-border);
  background: #fff;
}
#dg-input {
  flex: 1;
  border: 1px solid var(--dg-border);
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  font-size: 0.92rem;
  outline: none;
}
#dg-input:focus {
  border-color: var(--dg-navy);
  box-shadow: 0 0 0 3px rgba(62, 84, 127, 0.15);
}
#dg-send {
  border: none;
  border-radius: 999px;
  background: var(--dg-navy);
  color: #fff;
  width: 2.5rem;
  height: 2.5rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
}

@media (max-width: 480px) {
  #dg-root { right: 0.5rem; bottom: 0.5rem; left: 0.5rem; }
  #dg-panel { width: 100%; height: min(86vh, 720px); }
  #dg-launch-wrap { align-self: flex-end; }
  #dg-launcher { width: 4.1rem; height: 4.1rem; }
  .dg-disclosure { max-width: 12rem; }
}
