/* Floating Chat Widget CSS */

:root {
  --chat-primary: #1e293b;
  --chat-primary-rgb: 30, 41, 59;
  --chat-accent: #2563eb;
  --chat-accent-hover: #1d4ed8;
  --chat-bg: #0f172a;
  --chat-widget-bg: rgba(255, 255, 255, 0.95);
  --chat-text: #0f172a;
  --chat-text-light: #ffffff;
  --chat-muted: #64748b;
  --chat-bubble-user: #2563eb;
  --chat-bubble-agent: #f1f5f9;
  --chat-border: #e2e8f0;
}

/* Floating SOS button */
.chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 65px;
  height: 65px;
  border-radius: 50%;
  background-color: #dc2626; /* Emergency Red */
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 99999;
  position: fixed;
}

.chat-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.5);
  background-color: #b91c1c;
}

/* Pulsing outer ring */
.chat-launcher::before {
  content: '';
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border-radius: 50%;
  border: 2px solid #dc2626;
  opacity: 0.6;
  animation: ringPulse 2s infinite;
  pointer-events: none;
}

@keyframes ringPulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.35); opacity: 0; }
}

.sos-text {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.5px;
  color: white;
  animation: sosTextPulse 1.5s infinite alternate;
}

@keyframes sosTextPulse {
  from { transform: scale(1); text-shadow: 0 0 4px rgba(255,255,255,0.2); }
  to { transform: scale(1.08); text-shadow: 0 0 10px rgba(255,255,255,0.6); }
}

/* Notification badge */
.chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background-color: #ef4444;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Chat window container */
.chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 580px;
  border-radius: 16px;
  background-color: white;
  box-shadow: 0 12px 24px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 99998;
}

.chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Glassmorphism Header */
.chat-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--chat-accent);
}

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

.chat-header-avatar {
  width: 38px;
  height: 38px;
  background-color: var(--chat-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 2px solid rgba(255,255,255,0.2);
  color: white;
}

.chat-header-text h3 {
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
}

.chat-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  opacity: 0.8;
  margin-top: 2px;
}

.chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #cbd5e1;
}

.chat-status-dot.online {
  background-color: #10b981;
  box-shadow: 0 0 4px #10b981;
}

.chat-header-actions button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.chat-header-actions button:hover {
  color: white;
  background-color: rgba(255, 255, 255, 0.1);
}

/* Profile Edit Bar (Collapsible) */
.chat-profile-bar {
  background-color: #f8fafc;
  padding: 8px 16px;
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--chat-muted);
}

.chat-profile-name {
  font-weight: 600;
  color: var(--chat-primary);
}

.chat-profile-edit-btn {
  background: none;
  border: none;
  color: var(--chat-accent);
  font-weight: 500;
  cursor: pointer;
}

.chat-profile-edit-btn:hover {
  text-decoration: underline;
}

/* Edit Form Overlay */
.chat-profile-form {
  background-color: #f8fafc;
  padding: 12px 16px;
  border-bottom: 1px solid var(--chat-border);
  display: none;
  gap: 8px;
}

.chat-profile-form.open {
  display: flex;
}

.chat-profile-input {
  flex: 1;
  padding: 6px 12px;
  border: 1px solid var(--chat-border);
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
}

.chat-profile-input:focus {
  border-color: var(--chat-accent);
}

.chat-profile-submit {
  background-color: var(--chat-accent);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.chat-profile-submit:hover {
  background-color: var(--chat-accent-hover);
}

/* Messages container */
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background-color: #fdfdfd;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

/* Message block */
.chat-msg-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: messageSlide 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.chat-msg-wrapper.visitor {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-msg-wrapper.operator {
  align-self: flex-start;
  align-items: flex-start;
}

/* Message Bubble */
.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.4;
  word-break: break-word;
}

.chat-msg-wrapper.visitor .chat-bubble {
  background-color: var(--chat-bubble-user);
  color: white;
  border-bottom-right-radius: 2px;
}

.chat-msg-wrapper.operator .chat-bubble {
  background-color: var(--chat-bubble-agent);
  color: var(--chat-text);
  border: 1px solid var(--chat-border);
  border-bottom-left-radius: 2px;
}

/* Timestamp / metadata */
.chat-msg-meta {
  font-size: 0.7rem;
  color: var(--chat-muted);
  margin-top: 4px;
  padding: 0 4px;
}

/* System messages */
.chat-system-msg {
  align-self: center;
  background-color: #f1f5f9;
  color: var(--chat-muted);
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 9999px;
  text-align: center;
  max-width: 90%;
  margin: 6px 0;
  border: 1px solid var(--chat-border);
}

/* Input area */
.chat-input-area {
  padding: 14px 16px;
  border-top: 1px solid var(--chat-border);
  background-color: white;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-input-field {
  flex: 1;
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  padding: 8px 16px;
  outline: none;
  font-size: 0.88rem;
  resize: none;
  height: 38px;
  line-height: 20px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.chat-input-field:focus {
  border-color: var(--chat-accent);
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: var(--chat-accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background-color: var(--chat-accent-hover);
  transform: scale(1.05);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

.chat-send-btn i {
  width: 18px;
  height: 18px;
}

/* Mobile responsive fixes */
@media (max-width: 480px) {
  .chat-window {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
  }
  .chat-launcher {
    bottom: 16px;
    right: 16px;
  }
}

/* Pre-chat Form Styling */
.chat-preform {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 24px;
  text-align: center;
  flex: 1;
  background-color: #ffffff;
}

.chat-preform-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-color: rgba(37, 99, 235, 0.1);
  color: var(--chat-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.chat-preform-logo i {
  width: 32px;
  height: 32px;
}

.chat-preform h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--chat-primary);
  margin-bottom: 8px;
}

.chat-preform p {
  font-size: 0.82rem;
  color: var(--chat-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.chat-preform-field {
  width: 100%;
  text-align: left;
  margin-bottom: 16px;
}

.chat-preform-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--chat-primary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-preform-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--chat-border);
  border-radius: 8px;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.chat-preform-field input:focus {
  border-color: var(--chat-accent);
}

.chat-preform-submit {
  width: 100%;
  padding: 12px;
  background-color: var(--chat-accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  transition: background-color 0.2s, transform 0.1s;
}

.chat-preform-submit:hover {
  background-color: var(--chat-accent-hover);
}

.chat-preform-submit:active {
  transform: scale(0.98);
}

/* Adjust Profile Edit form in chatMainArea for dual fields */
.chat-profile-form {
  flex-direction: column;
}
.chat-profile-form input {
  margin-bottom: 8px;
  width: 100%;
}
.chat-profile-form button {
  width: 100%;
}

