/* ===== CRAB ISLAND CHAT WIDGET ===== */
.ci-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0A6E7A, #00B4D8);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 180, 216, 0.4);
  transition: transform 0.3s, box-shadow 0.3s;
  color: white;
}

.ci-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 180, 216, 0.5);
}

.ci-chat-btn svg { width: 28px; height: 28px; }

.ci-chat-btn .chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #FF6B5A;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  border: 2px solid white;
}

.ci-chat-btn.has-unread .chat-badge { display: flex; }
.ci-chat-btn:not(.has-unread) .chat-badge { display: none; }

/* Chat Window */
.ci-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9991;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: white;
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(11, 29, 46, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}

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

/* Header */
.ci-chat-header {
  background: linear-gradient(135deg, #0B1D2E, #0A6E7A);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

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

.ci-chat-header-info { flex: 1; }

.ci-chat-header-name {
  color: white;
  font-family: 'Fraunces', serif;
  font-size: 1rem;
  font-weight: 700;
}

.ci-chat-header-status {
  color: rgba(255,255,255,0.6);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ci-chat-header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
}

.ci-chat-close {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background 0.2s;
}

.ci-chat-close:hover { background: rgba(255,255,255,0.2); }

/* Tabs */
.ci-chat-tabs {
  display: flex;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.ci-chat-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #999;
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.ci-chat-tab.active {
  color: #0A6E7A;
  border-bottom-color: #0A6E7A;
}

.ci-chat-tab:hover { color: #0A6E7A; }

/* Messages Area */
.ci-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8f9fa;
}

.ci-chat-messages::-webkit-scrollbar { width: 4px; }
.ci-chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* Message Bubbles */
.ci-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: msgSlideIn 0.3s ease-out;
}

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

.ci-msg.bot { align-self: flex-start; }
.ci-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.ci-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.ci-msg.bot .ci-msg-avatar { background: linear-gradient(135deg, #0A6E7A, #00B4D8); }
.ci-msg.user .ci-msg-avatar { background: linear-gradient(135deg, #FF6B5A, #FF9E5E); }

.ci-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.ci-msg.bot .ci-msg-bubble {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.ci-msg.user .ci-msg-bubble {
  background: linear-gradient(135deg, #0A6E7A, #00B4D8);
  color: white;
  border-bottom-right-radius: 4px;
}

.ci-msg-bubble a {
  color: #00B4D8;
  text-decoration: underline;
  font-weight: 600;
}

.ci-msg.user .ci-msg-bubble a { color: #CAF0F8; }

/* Quick Reply Buttons */
.ci-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ci-quick-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid #00B4D8;
  background: white;
  color: #0A6E7A;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Outfit', sans-serif;
}

.ci-quick-btn:hover {
  background: #00B4D8;
  color: white;
}

/* Media in messages */
.ci-msg-media {
  max-width: 200px;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 6px;
}

.ci-msg-media img,
.ci-msg-media video {
  width: 100%;
  display: block;
  border-radius: 12px;
}

/* Typing Indicator */
.ci-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 4px 0;
}

.ci-typing-dots {
  display: flex;
  gap: 4px;
  background: white;
  padding: 10px 16px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.ci-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aaa;
  animation: typingBounce 1.4s infinite;
}

.ci-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ci-typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Input Area */
.ci-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid #eee;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: white;
  flex-shrink: 0;
}

.ci-chat-input-wrap {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: #f0f2f5;
  border-radius: 22px;
  padding: 6px 6px 6px 16px;
  min-height: 40px;
}

.ci-chat-input {
  flex: 1;
  border: none;
  background: none;
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  color: #333;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  padding: 4px 0;
  outline: none;
}

.ci-chat-input::placeholder { color: #999; }

/* Upload Button */
.ci-chat-upload-btn {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  flex-shrink: 0;
}

.ci-chat-upload-btn:hover { color: #0A6E7A; }
.ci-chat-upload-btn svg { width: 20px; height: 20px; }

/* Send Button */
.ci-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0A6E7A, #00B4D8);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}

.ci-chat-send:hover { transform: scale(1.08); }
.ci-chat-send:disabled { opacity: 0.4; cursor: default; transform: none; }
.ci-chat-send svg { width: 18px; height: 18px; }

/* Upload Preview */
.ci-upload-preview {
  padding: 8px 16px 0;
  border-top: 1px solid #eee;
  background: white;
  display: none;
  flex-shrink: 0;
}

.ci-upload-preview.active { display: block; }

.ci-upload-preview-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: #f0f2f5;
  border-radius: 12px;
}

.ci-upload-preview img,
.ci-upload-preview video {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
}

.ci-upload-preview-name {
  flex: 1;
  font-size: 0.8rem;
  color: #555;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ci-upload-preview-remove {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
}

/* Live Chat Panel */
.ci-chat-panel { display: none; }
.ci-chat-panel.active { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

/* Live Chat - Contact Form */
.ci-live-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
}

.ci-live-form label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
}

.ci-live-form input,
.ci-live-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  color: #333;
  outline: none;
  transition: border-color 0.2s;
}

.ci-live-form input:focus,
.ci-live-form textarea:focus { border-color: #00B4D8; }

.ci-live-form textarea { resize: none; height: 80px; }

.ci-live-submit {
  padding: 12px;
  background: linear-gradient(135deg, #0A6E7A, #00B4D8);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.ci-live-submit:hover { transform: translateY(-1px); }

.ci-live-success {
  text-align: center;
  padding: 40px 20px;
  display: none;
}

.ci-live-success.show { display: block; }

.ci-live-success-icon { font-size: 3rem; margin-bottom: 12px; }

.ci-live-success h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.2rem;
  color: #0B1D2E;
  margin-bottom: 8px;
}

.ci-live-success p {
  font-size: 0.88rem;
  color: #666;
  line-height: 1.5;
}

/* Mobile */
@media (max-width: 480px) {
  .ci-chat-window {
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .ci-chat-btn {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
}
