:root {
  --pw-bg: #050914;
  --pw-panel: rgba(7, 13, 29, .985);
  --pw-card: rgba(15, 23, 42, .78);
  --pw-card-strong: rgba(14, 30, 52, .96);
  --pw-border: rgba(103, 232, 249, .18);
  --pw-cyan: #22d3ee;
  --pw-cyan-soft: #67e8f9;
  --pw-blue: #0ea5e9;
  --pw-text: #f8fafc;
  --pw-muted: #94a3b8;
  --pw-warning: #fbbf24;
  --pw-green: #25d366;
}

body.pw-chat-open {
  overflow: hidden;
}

.pw-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 0, 0, .58);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity .22s ease,
    visibility .22s ease;
}

.pw-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pw-overlay[hidden] {
  display: none !important;
}

.pw-panel {
  width: min(500px, 100vw);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--pw-text);
  background:
    radial-gradient(
      circle at 14% 0%,
      rgba(14, 165, 233, .16),
      transparent 31%
    ),
    radial-gradient(
      circle at 100% 20%,
      rgba(34, 211, 238, .08),
      transparent 34%
    ),
    var(--pw-panel);
  border-left: 1px solid var(--pw-border);
  box-shadow: -20px 0 70px rgba(0, 0, 0, .62);
  transform: translateX(102%);
  transition: transform .28s cubic-bezier(.16, 1, .3, 1);
  font-family: inherit;
}

.pw-overlay.is-open .pw-panel {
  transform: translateX(0);
}

.pw-header {
  min-height: 92px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding:
    max(16px, env(safe-area-inset-top))
    18px
    16px;
  border-bottom: 1px solid var(--pw-border);
  background: rgba(4, 10, 24, .86);
  backdrop-filter: blur(18px);
}

.pw-avatar-wrap {
  position: relative;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  overflow: visible;
  background:
    linear-gradient(
      145deg,
      rgba(30, 58, 138, .8),
      rgba(6, 182, 212, .22)
    );
  box-shadow:
    0 0 0 1px rgba(103, 232, 249, .18),
    0 0 28px rgba(34, 211, 238, .22);
}

.pw-avatar-wrap picture {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
}

.pw-avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pw-online-dot {
  position: absolute;
  right: -2px;
  bottom: -1px;
  width: 13px;
  height: 13px;
  border: 2px solid #07101f;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 13px rgba(34, 197, 94, .9);
}

.pw-heading {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.pw-heading strong {
  color: #fff;
  font-size: 1.12rem;
  line-height: 1.15;
}

.pw-heading > span {
  margin-top: 4px;
  color: #cbd5e1;
  font-size: .84rem;
}

.pw-heading small {
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #4ade80;
  font-size: .75rem;
  font-weight: 800;
}

.pw-heading small i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.pw-close {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: 13px;
  color: #cbd5e1;
  background: rgba(255, 255, 255, .04);
  font-size: 1.65rem;
  line-height: 1;
  cursor: pointer;
}

.pw-close:hover {
  border-color: rgba(103, 232, 249, .35);
  color: #fff;
  background: rgba(34, 211, 238, .08);
}

.pw-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 18px 18px;
  scrollbar-width: thin;
  scrollbar-color:
    rgba(34, 211, 238, .35)
    rgba(2, 6, 23, .5);
}

.pw-message-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
}

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

.pw-message-avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  margin-top: 2px;
  object-fit: cover;
  border-radius: 11px;
  background: rgba(14, 165, 233, .14);
  box-shadow: 0 0 18px rgba(34, 211, 238, .12);
}

.pw-assistant-content {
  width: min(100%, 390px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
}

.pw-bubble {
  padding: 13px 14px;
  border-radius: 17px;
  font-size: .92rem;
  line-height: 1.58;
  overflow-wrap: anywhere;
}

.pw-assistant-bubble {
  width: 100%;
  border: 1px solid rgba(103, 232, 249, .14);
  border-top-left-radius: 5px;
  color: #e2e8f0;
  background:
    linear-gradient(
      135deg,
      rgba(15, 23, 42, .96),
      rgba(8, 47, 73, .43)
    );
}

.pw-user-bubble {
  max-width: 82%;
  border: 1px solid rgba(56, 189, 248, .26);
  border-bottom-right-radius: 5px;
  color: #fff;
  background:
    linear-gradient(
      135deg,
      rgba(3, 105, 161, .92),
      rgba(14, 116, 144, .88)
    );
  box-shadow: 0 8px 24px rgba(2, 132, 199, .08);
}

.pw-warning {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 11px;
  border: 1px solid rgba(251, 191, 36, .16);
  border-radius: 12px;
  color: #fde68a;
  background: rgba(120, 53, 15, .14);
  font-size: .76rem;
  line-height: 1.45;
}

.pw-warning > span:first-child {
  flex: 0 0 auto;
  color: var(--pw-warning);
}

.pw-whatsapp {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid rgba(74, 222, 128, .28);
  border-radius: 12px;
  color: #fff !important;
  background:
    linear-gradient(
      135deg,
      #16a34a,
      var(--pw-green)
    );
  box-shadow: 0 9px 28px rgba(37, 211, 102, .12);
  text-align: center;
  text-decoration: none !important;
  font-size: .86rem;
  font-weight: 900;
  transition:
    transform .18s ease,
    box-shadow .18s ease;
}

.pw-whatsapp:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 32px rgba(37, 211, 102, .2);
}

.pw-thinking {
  margin: 0 18px 12px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid rgba(34, 211, 238, .12);
  border-radius: 13px;
  color: #bae6fd;
  background: rgba(8, 47, 73, .22);
  font-size: .78rem;
}

.pw-thinking[hidden] {
  display: none;
}

.pw-thinking img {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  object-fit: cover;
}

.pw-thinking b {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--pw-cyan);
  animation: pwThinking 1s infinite ease-in-out;
}

.pw-thinking b:nth-of-type(2) {
  animation-delay: .14s;
}

.pw-thinking b:nth-of-type(3) {
  animation-delay: .28s;
}

.pw-scope-note {
  margin: 0 18px 12px;
  padding: 11px 12px;
  border: 1px solid rgba(148, 163, 184, .12);
  border-radius: 12px;
  background: rgba(15, 23, 42, .56);
}

.pw-scope-note strong,
.pw-scope-note span {
  display: block;
}

.pw-scope-note strong {
  margin-bottom: 3px;
  color: var(--pw-cyan-soft);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.pw-scope-note span {
  color: var(--pw-muted);
  font-size: .72rem;
  line-height: 1.45;
}

.pw-composer {
  flex: 0 0 auto;
  padding:
    14px
    18px
    max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--pw-border);
  background: rgba(3, 7, 18, .96);
}

.pw-composer > label {
  display: block;
  margin-bottom: 8px;
  color: #e2e8f0;
  font-size: .78rem;
  font-weight: 850;
}

.pw-input-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
}

.pw-input-row textarea {
  min-width: 0;
  flex: 1;
  max-height: 120px;
  resize: none;
  padding: 12px 13px;
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 13px;
  outline: none;
  color: #fff;
  background: rgba(15, 23, 42, .78);
  font: inherit;
  font-size: .9rem;
  line-height: 1.42;
}

.pw-input-row textarea:focus {
  border-color: rgba(34, 211, 238, .55);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .07);
}

.pw-input-row textarea::placeholder {
  color: #64748b;
}

.pw-input-row textarea:disabled {
  opacity: .65;
  cursor: not-allowed;
}

.pw-input-row button {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  color: #021018;
  background:
    linear-gradient(
      135deg,
      var(--pw-cyan),
      #38bdf8
    );
  box-shadow: 0 8px 25px rgba(34, 211, 238, .16);
  font-size: 1.15rem;
  font-weight: 900;
  cursor: pointer;
}

.pw-input-row button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.pw-composer-meta {
  margin-top: 7px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #64748b;
  font-size: .67rem;
}

@keyframes pwThinking {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: .35;
  }

  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .pw-panel {
    width: 100vw;
    border-left: 0;
  }

  .pw-header {
    min-height: 82px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .pw-avatar-wrap {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
  }

  .pw-messages {
    padding-left: 13px;
    padding-right: 13px;
  }

  .pw-thinking,
  .pw-scope-note {
    margin-left: 13px;
    margin-right: 13px;
  }

  .pw-composer {
    padding-left: 13px;
    padding-right: 13px;
  }

  .pw-assistant-content {
    max-width: calc(100% - 44px);
  }

  .pw-user-bubble {
    max-width: 88%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pw-overlay,
  .pw-panel,
  .pw-whatsapp,
  .pw-thinking b {
    transition: none !important;
    animation: none !important;
  }
}

/* Will IA conversational compact footer */
.pw-footer-actions {
  margin: 0 18px 11px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pw-mini-warning {
  min-width: 0;
  flex: 1;
  color: #94a3b8;
  font-size: .69rem;
  line-height: 1.35;
}

.pw-footer-whatsapp {
  flex: 0 0 auto;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid rgba(74, 222, 128, .25);
  border-radius: 11px;
  color: #dcfce7 !important;
  background: rgba(22, 163, 74, .15);
  text-decoration: none !important;
  font-size: .72rem;
  font-weight: 850;
  white-space: nowrap;
  transition:
    background .18s ease,
    border-color .18s ease;
}

.pw-footer-whatsapp:hover {
  border-color: rgba(74, 222, 128, .48);
  background: rgba(22, 163, 74, .24);
}

@media (max-width: 640px) {
  .pw-footer-actions {
    margin-left: 13px;
    margin-right: 13px;
  }

  .pw-mini-warning {
    font-size: .65rem;
  }

  .pw-footer-whatsapp {
    padding-left: 10px;
    padding-right: 10px;
    font-size: .68rem;
  }
}
