/* Widget de chat — canto inferior direito */
.site-chat-fab {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  z-index: 1200;
  width: 3.75rem;
  height: 3.75rem;
  border: none;
  border-radius: var(--r-full, 9999px);
  background: var(--sesipa-primary, #ff6b35);
  color: #fff;
  box-shadow: var(--shadow-card-hover, 0 12px 28px rgba(0, 0, 0, 0.18));
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform var(--t-fast, 0.15s ease), box-shadow var(--t-fast, 0.15s ease);
}

.site-chat-fab:hover {
  transform: scale(1.04);
}

.site-chat-fab:focus-visible {
  outline: 2px solid var(--primary-ring, rgba(255, 107, 53, 0.45));
  outline-offset: 3px;
}

.site-chat-fab[hidden],
.site-chat-panel[hidden] {
  display: none !important;
}

.site-chat-panel {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: calc(max(1rem, env(safe-area-inset-bottom, 0px)) + 4.5rem);
  z-index: 1199;
  width: min(22.5rem, calc(100vw - 2rem));
  height: min(32rem, calc(100dvh - 7rem));
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg, 12px);
  background: var(--surface, #fff);
  border: 1px solid var(--border-subtle, #e8e8e8);
  box-shadow: var(--shadow-card-hover, 0 16px 40px rgba(0, 0, 0, 0.16));
  overflow: hidden;
}

.site-chat-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  background: var(--surface, #fff);
  color: var(--text, #1a1a1a);
  border-bottom: 1px solid var(--border-subtle, #e8e8e8);
}

.site-chat-header__avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--r-full, 9999px);
  background: var(--surface-soft, #f0f0f0);
  color: var(--text-secondary, #444);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.site-chat-header__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
}

.site-chat-header__sub {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: var(--muted, #6b7280);
  font-weight: 400;
}

.site-chat-header__actions {
  margin-left: auto;
  display: flex;
  gap: 0.35rem;
}

.site-chat-icon-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary, #555);
  width: 2rem;
  height: 2rem;
  border-radius: var(--r-sm, 6px);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.site-chat-icon-btn:hover {
  background: var(--surface-soft, #f0f0f0);
  color: var(--text, #1a1a1a);
}

.site-chat-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-soft, #f6f6f6);
}

.site-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.site-chat-empty {
  margin: auto 0.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted, #6b7280);
  line-height: 1.45;
}

.site-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.site-chat-msg--in {
  align-self: flex-start;
}

.site-chat-msg--out {
  align-self: flex-end;
}

.site-chat-bubble {
  padding: 0.55rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.site-chat-msg--in .site-chat-bubble {
  background: #fff;
  border: 1px solid var(--border-subtle, #e5e5e5);
  border-bottom-left-radius: 0.25rem;
}

.site-chat-msg--out .site-chat-bubble {
  background: #dcf8c6;
  border-bottom-right-radius: 0.25rem;
}

.site-chat-bubble a {
  color: #0b5cab;
  text-decoration: underline;
}

.site-chat-time {
  font-size: 0.68rem;
  color: var(--muted, #888);
  margin-top: 0.15rem;
  padding: 0 0.25rem;
}

.site-chat-typing {
  font-size: 0.8rem;
  color: var(--muted, #777);
  padding: 0 0.25rem 0.5rem;
  min-height: 1.25rem;
}

.site-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 0.75rem 0.5rem;
}

.site-chat-chip {
  border: 1px solid var(--border, #ddd);
  background: #fff;
  border-radius: var(--r-full, 9999px);
  font-size: 0.75rem;
  padding: 0.28rem 0.65rem;
  cursor: pointer;
  color: var(--text, #222);
}

.site-chat-chip:hover {
  border-color: var(--border-strong, #bbb);
  background: var(--surface-soft, #f6f6f6);
}

.site-chat-footer {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--border-subtle, #eee);
  background: #fff;
}

.site-chat-input {
  flex: 1;
  resize: none;
  min-height: 2.5rem;
  max-height: 6rem;
  border: 1px solid var(--border, #ddd);
  border-radius: var(--r-md, 8px);
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.875rem;
}

.site-chat-input:focus {
  outline: 2px solid rgba(0, 0, 0, 0.08);
  border-color: var(--border-strong, #999);
}

.site-chat-send {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.5rem;
  border: none;
  border-radius: var(--r-md, 8px);
  background: var(--text, #2d2d2d);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.site-chat-send:hover:not(:disabled) {
  background: #1a1a1a;
}

.site-chat-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .site-chat-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: min(85dvh, 32rem);
    border-radius: var(--r-lg, 12px) var(--r-lg, 12px) 0 0;
  }

  .site-chat-fab {
    bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  }
}