/* Doktorly Patient Assistant widget */
.dpa-root {
  --dpa-teal: var(--premium-teal, #00d1b2);
  --dpa-teal-dark: var(--premium-teal-dark, #016959);
  --dpa-turquoise: var(--premium-turquoise, #11445b);
  --dpa-bg: var(--new-bg, #f7f2dc);
  --dpa-dark: var(--dark-text, #2d3436);
  --dpa-white: #ffffff;
  --dpa-radius: 16px;
  --dpa-shadow: 0 12px 40px rgba(17, 68, 91, 0.25);
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1200;
  font-family: "Inter", "Noto Sans", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--dpa-dark);
  text-align: left;
}

/* Launcher button */
.dpa-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--dpa-teal-dark) 0%, var(--dpa-turquoise) 100%);
  color: #fff;
  box-shadow: var(--dpa-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}
.dpa-launcher:hover { transform: scale(1.07); }
.dpa-launcher svg { width: 28px; height: 28px; }
.dpa-launcher[hidden] { display: none; }

/* Teaser bubble */
.dpa-teaser {
  position: absolute;
  right: 0;
  bottom: 4.75rem;
  width: min(300px, calc(100vw - 2.5rem));
  background: var(--dpa-white);
  border-radius: var(--dpa-radius);
  border-top: 3px solid var(--dpa-teal);
  box-shadow: var(--dpa-shadow);
  padding: 1rem 1rem 0.9rem;
  animation: dpa-pop 0.35s ease both;
}
.dpa-teaser[hidden] { display: none; }
.dpa-teaser-header {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.dpa-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--dpa-teal) 0%, var(--dpa-teal-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
}
.dpa-teaser-title { font-weight: 700; font-size: 0.95rem; margin: 0; }
.dpa-teaser-sub { font-size: 0.8rem; opacity: 0.75; margin: 0; }
.dpa-teaser-close {
  margin-left: auto;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: rgba(45, 52, 54, 0.5);
  padding: 0.15rem;
}
.dpa-teaser-close:hover { color: var(--dpa-dark); }
.dpa-teaser-msg { font-size: 0.9rem; margin: 0.35rem 0 0.7rem; }
.dpa-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.dpa-chips::-webkit-scrollbar { display: none; }
.dpa-chip {
  border: 1.5px solid var(--dpa-teal-dark);
  background: var(--dpa-white);
  color: var(--dpa-teal-dark);
  border-radius: 9999px;
  padding: 0.38rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  flex: 0 0 auto;
}
.dpa-chip:hover { background: var(--dpa-teal-dark); color: #fff; }

/* Chat panel */
.dpa-panel {
  position: absolute;
  right: 0;
  bottom: 4.75rem;
  width: min(370px, calc(100vw - 2rem));
  height: min(520px, calc(100vh - 8rem));
  background: var(--dpa-bg);
  border-radius: var(--dpa-radius);
  box-shadow: var(--dpa-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: dpa-pop 0.3s ease both;
}
.dpa-panel[hidden] { display: none; }
.dpa-panel-header {
  background: linear-gradient(135deg, var(--dpa-teal-dark) 0%, var(--dpa-turquoise) 100%);
  color: #fff;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 0 0 auto;
}
.dpa-panel-header .dpa-avatar { background: rgba(255, 255, 255, 0.2); }
.dpa-panel-title { font-weight: 700; font-size: 0.95rem; margin: 0; }
.dpa-panel-status { font-size: 0.72rem; opacity: 0.85; margin: 0; display: flex; align-items: center; gap: 0.3rem; }
.dpa-status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #58d68d; display: inline-block;
}
.dpa-panel-close {
  margin-left: auto;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  flex: 0 0 auto;
}
.dpa-panel-close:hover { background: rgba(255, 255, 255, 0.3); }

.dpa-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  scroll-behavior: smooth;
}
.dpa-msg {
  max-width: 85%;
  padding: 0.6rem 0.8rem;
  border-radius: 14px;
  font-size: 0.875rem;
  white-space: pre-wrap;
  word-break: break-word;
  animation: dpa-fade 0.2s ease both;
}
.dpa-msg--bot {
  align-self: flex-start;
  background: var(--dpa-white);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(17, 68, 91, 0.08);
}
.dpa-msg--user {
  align-self: flex-end;
  background: var(--dpa-teal-dark);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.dpa-msg a {
  color: var(--dpa-teal-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
  display: block;
  margin-top: 0.25rem;
  word-break: break-all;
}
.dpa-msg--user a { color: #d9fffa; }

.dpa-msg--error {
  background: #fdecea;
  border: 1px solid #f5c6c0;
  color: #b3261e;
  max-width: 92%;
}
.dpa-retry {
  display: inline-block;
  margin-top: 0.55rem;
  border: none;
  cursor: pointer;
  background: #d93025;
  color: #fff;
  border-radius: 9999px;
  padding: 0.42rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  min-height: 34px;
}
.dpa-retry:hover { background: #b7291d; }

.dpa-typing { display: flex; gap: 4px; align-items: center; padding: 0.7rem 0.85rem; }
.dpa-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--dpa-teal-dark);
  opacity: 0.4;
  animation: dpa-bounce 1.2s infinite ease-in-out;
}
.dpa-typing span:nth-child(2) { animation-delay: 0.15s; }
.dpa-typing span:nth-child(3) { animation-delay: 0.3s; }

.dpa-panel-chips {
  flex: 0 0 auto;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.45rem 0.9rem;
  background: var(--dpa-bg);
  border-top: 1px solid rgba(17, 68, 91, 0.08);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.dpa-panel-chips::-webkit-scrollbar { display: none; }

.dpa-input-row {
  flex: 0 0 auto;
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
  background: var(--dpa-white);
  border-top: 1px solid rgba(17, 68, 91, 0.08);
}
.dpa-input {
  flex: 1 1 auto;
  border: 1.5px solid rgba(17, 68, 91, 0.2);
  border-radius: 9999px;
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  background: var(--dpa-white);
  color: var(--dpa-dark);
  min-width: 0;
}
.dpa-input:focus { border-color: var(--dpa-teal); }
.dpa-send {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--dpa-teal-dark);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease;
}
.dpa-send:disabled { opacity: 0.45; cursor: not-allowed; }
.dpa-send svg { width: 18px; height: 18px; }

@keyframes dpa-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes dpa-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dpa-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media screen and (max-width: 768px) {
  .dpa-root { right: 0.9rem; bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px)); }
  .dpa-panel {
    width: calc(100vw - 1.5rem);
    height: min(480px, calc(100vh - 10rem));
  }
  .dpa-teaser { width: min(280px, calc(100vw - 1.8rem)); }
}
