/* =============================================
   StatusKWO Live Chat Widget
   Self-contained — remove this file + js/chat.js
   + one script tag to fully remove the feature
   ============================================= */

/* FAB (Floating Action Button) */
.skwo-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%);
  border: none;
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(13, 148, 136, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}
.skwo-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 32px rgba(13, 148, 136, 0.5), 0 4px 12px rgba(0, 0, 0, 0.12);
}
.skwo-chat-fab:active {
  transform: scale(0.96);
}
.skwo-chat-fab svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.2s, transform 0.2s;
}
.skwo-chat-fab .skwo-icon-close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}
.skwo-chat-fab.active .skwo-icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}
.skwo-chat-fab.active .skwo-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Unread badge */
.skwo-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  background: #EF4444;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.3s, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}
.skwo-chat-badge.visible {
  opacity: 1;
  transform: scale(1);
}
.skwo-chat-badge.pulse {
  animation: skwoBadgePulse 1.5s ease infinite;
}

@keyframes skwoBadgePulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 2px 16px rgba(239, 68, 68, 0.7); }
}

/* Chat Window */
.skwo-chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-height: 560px;
  border-radius: 16px;
  background: var(--light, #F8FAFC);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(0, 0, 0, 0.06);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.skwo-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.skwo-chat-header {
  background: var(--primary, #0F2B46);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 2px solid var(--secondary, #0D9488);
  flex-shrink: 0;
}
.skwo-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}
.skwo-chat-header-info h4 {
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
}
.skwo-chat-header-status {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  gap: 6px;
}
.skwo-chat-header-status .skwo-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--secondary-light, #14B8A6);
  display: inline-block;
}

/* Messages area */
.skwo-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 280px;
  max-height: 360px;
  scroll-behavior: smooth;
}
.skwo-chat-messages::-webkit-scrollbar {
  width: 4px;
}
.skwo-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.skwo-chat-messages::-webkit-scrollbar-thumb {
  background: var(--border, #E2E8F0);
  border-radius: 2px;
}

/* Message bubbles */
.skwo-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  line-height: 1.55;
  word-wrap: break-word;
  animation: skwoMsgIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes skwoMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.skwo-msg-visitor {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.skwo-msg-owner {
  align-self: flex-start;
  background: var(--white, #fff);
  color: var(--text, #1E293B);
  border: 1px solid var(--border, #E2E8F0);
  border-bottom-left-radius: 4px;
}

/* Timestamp */
.skwo-msg-time {
  font-size: 0.68rem;
  color: var(--text-light, #64748B);
  padding: 2px 4px;
  margin-top: 2px;
  margin-bottom: 8px;
}
.skwo-msg-time.right {
  align-self: flex-end;
  text-align: right;
}
.skwo-msg-time.left {
  align-self: flex-start;
}

/* Typing indicator */
.skwo-typing {
  align-self: flex-start;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--white, #fff);
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  margin-bottom: 4px;
}
.skwo-typing.visible {
  display: flex;
}
.skwo-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-light, #64748B);
  animation: skwoTypingBounce 1.2s ease-in-out infinite;
}
.skwo-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.skwo-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes skwoTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Welcome message */
.skwo-chat-welcome {
  text-align: center;
  padding: 24px 16px 12px;
}
.skwo-chat-welcome p {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  color: var(--text-light, #64748B);
  line-height: 1.6;
  margin: 0;
}

/* Pre-chat form */
.skwo-prechat {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.skwo-prechat input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  color: var(--text, #1E293B);
  background: var(--white, #fff);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.skwo-prechat input:focus {
  border-color: var(--secondary, #0D9488);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}
.skwo-prechat input::placeholder {
  color: var(--text-light, #94A3B8);
}
.skwo-prechat-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}
.skwo-prechat-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}
.skwo-prechat-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Input area */
.skwo-chat-input {
  padding: 12px 16px;
  border-top: 1px solid var(--border, #E2E8F0);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white, #fff);
  flex-shrink: 0;
}
.skwo-chat-input textarea {
  flex: 1;
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  color: var(--text, #1E293B);
  background: var(--light, #F8FAFC);
  resize: none;
  outline: none;
  min-height: 40px;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.skwo-chat-input textarea:focus {
  border-color: var(--secondary, #0D9488);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}
.skwo-chat-input textarea::placeholder {
  color: var(--text-light, #94A3B8);
}
.skwo-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.skwo-chat-send:hover {
  opacity: 0.9;
  transform: scale(1.04);
}
.skwo-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.skwo-chat-send svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Sound toggle */
.skwo-chat-sound {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: opacity 0.2s;
  margin-left: auto;
}
.skwo-chat-sound:hover {
  opacity: 0.8;
}
.skwo-chat-sound svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: rgba(255, 255, 255, 0.7);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Offline state */
.skwo-chat-offline {
  text-align: center;
  padding: 20px;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  color: var(--text-light, #64748B);
}

/* Mobile responsive */
@media (max-width: 480px) {
  .skwo-chat-window {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 90px;
    max-height: calc(100vh - 120px);
    border-radius: 12px;
  }
  .skwo-chat-fab {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
  .skwo-chat-fab svg {
    width: 24px;
    height: 24px;
  }
  .skwo-chat-messages {
    max-height: calc(100vh - 300px);
  }
}
