/* PROFI CS Chat Widget — bottom-right floating */

.profi-chat {
  position: fixed;
  right: 16px;
  bottom: calc(var(--public-footer-h, 44px) + 16px);
  z-index: 1200;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

@media (max-width: 768px) {
  .profi-chat {
    bottom: calc(var(--mobile-bottom-nav-h, 62px) + 12px);
    right: 12px;
  }
}

/* Toggle button */
.profi-chat-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--maroon, #872332), var(--maroon-dark, #5E121D));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(135, 35, 50, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}

.profi-chat-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(135, 35, 50, 0.4);
}

.profi-chat-toggle-icon--close { display: none; }
.profi-chat.is-open .profi-chat-toggle-icon--open { display: none; }
.profi-chat.is-open .profi-chat-toggle-icon--close { display: block; }

/* Panel */
.profi-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(360px, calc(100vw - 32px));
  max-height: min(680px, calc(100dvh - 88px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(26, 10, 12, 0.18);
  border: 1px solid rgba(135, 35, 50, 0.08);
  overflow: hidden;
  animation: profiChatSlideUp 0.25s ease;
}

.profi-chat-panel[hidden] {
  display: none !important;
}

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

/* Header */
.profi-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--maroon, #872332), var(--maroon-mid, #742A35));
  color: #fff;
}

.profi-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profi-chat-avatar {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  font-size: 1.1rem;
}

.profi-chat-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
}

.profi-chat-subtitle {
  display: block;
  font-size: 0.72rem;
  opacity: 0.85;
}

.profi-chat-close {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.profi-chat-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Messages */
.profi-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 380px;
  max-height: 520px;
  background: var(--light, #F7F3EE);
}

.profi-chat-msg {
  display: flex;
}

.profi-chat-msg--user {
  justify-content: flex-end;
}

.profi-chat-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}

.profi-chat-msg--bot .profi-chat-bubble {
  background: #fff;
  color: var(--charcoal, #1A0A0C);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.profi-chat-msg--user .profi-chat-bubble {
  background: var(--maroon, #872332);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.profi-chat-bubble a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

.profi-chat-msg--bot .profi-chat-bubble a {
  color: var(--maroon, #872332);
}

/* Typing indicator */
.profi-chat-typing .profi-chat-bubble {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
}

.profi-chat-typing .profi-chat-bubble span {
  width: 7px;
  height: 7px;
  background: var(--mid, #6B5A5E);
  border-radius: 50%;
  animation: profiChatDot 1.2s infinite;
}

.profi-chat-typing .profi-chat-bubble span:nth-child(2) { animation-delay: 0.15s; }
.profi-chat-typing .profi-chat-bubble span:nth-child(3) { animation-delay: 0.3s; }

@keyframes profiChatDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
  30% { opacity: 1; transform: scale(1); }
}

/* Quick chips */
.profi-chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid rgba(135, 35, 50, 0.06);
  background: #fff;
}

.profi-chat-chip {
  padding: 5px 10px;
  font-size: 0.72rem;
  border: 1px solid rgba(135, 35, 50, 0.15);
  border-radius: 999px;
  background: var(--cream, #FFF9F0);
  color: var(--maroon, #872332);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}

.profi-chat-chip:hover {
  background: rgba(135, 35, 50, 0.08);
  border-color: var(--maroon, #872332);
}

/* Form */
.profi-chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid rgba(135, 35, 50, 0.06);
}

.profi-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid rgba(135, 35, 50, 0.12);
  border-radius: 999px;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.profi-chat-input:focus {
  border-color: var(--maroon, #872332);
}

.profi-chat-send {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--gold, #C59358);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}

.profi-chat-send:hover:not(:disabled) {
  background: var(--gold-dark, #A67C45);
  transform: scale(1.05);
}

.profi-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
