/* ============================================================
   CSS MARINE CHATBOT — Modern UI
   ============================================================ */

/* Toggle Button */
#chat-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #0d47a1, #1976d2);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 24px;
  z-index: 9999;
  box-shadow: 0 4px 24px rgba(13,71,161,.45), 0 0 0 0 rgba(25,118,210,.4);
  transition: transform .3s cubic-bezier(.4,0,.2,1), box-shadow .3s;
  animation: togglePulse 2.5s infinite;
  border: none;
}
#chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 32px rgba(13,71,161,.55);
}
@keyframes togglePulse {
  0%, 100% { box-shadow: 0 4px 24px rgba(13,71,161,.45), 0 0 0 0 rgba(25,118,210,.35); }
  50% { box-shadow: 0 4px 24px rgba(13,71,161,.45), 0 0 0 12px rgba(25,118,210,0); }
}

/* Chat Popup */
#chat-popup {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 370px;
  height: 530px;
  background: #0b1929;
  color: #e3f2fd;
  display: none;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.06);
  z-index: 9999;
  animation: popupIn .3s cubic-bezier(.4,0,.2,1);
  border: 1px solid rgba(255,255,255,.06);
}
@keyframes popupIn {
  from { opacity: 0; transform: translateY(20px) scale(.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.chat-header {
  background: linear-gradient(135deg, #0d47a1, #1565c0 50%, #1976d2);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  position: relative;
}
.chat-header::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #29b6f6, #4fc3f7, #29b6f6);
  opacity: .7;
}
.chat-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.chat-header-title .header-icon {
  width: 26px;
  height: 26px;
  background: rgba(255,255,255,.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.chat-header-title .header-text {
  display: flex;
  flex-direction: column;
}
.chat-header-title .header-text .header-name {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .3px;
}
.chat-header-title .header-text .header-status {
  font-size: 11px;
  color: rgba(255,255,255,.7);
  font-weight: 400;
}
.chat-header-title .header-text .header-status::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #4caf50;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  animation: statusPulse 2s infinite;
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}
.chat-header-actions {
  display: flex;
  gap: 3px;
  align-items: center;
  flex-shrink: 0;
}
.chat-header button {
  background: rgba(255,255,255,.1);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 13px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.chat-header button:hover {
  background: rgba(255,255,255,.2);
}

/* Language Picker */
.chat-lang-picker { position: relative; }
.chat-lang-current {
  background: rgba(255,255,255,.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px;
  padding: 3px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
  width: auto;
  height: 26px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  transition: all .2s;
}
.chat-lang-current:hover { background: rgba(255,255,255,.18); }
.chat-lang-current svg { width: 16px; height: 11px; flex-shrink: 0; border-radius: 2px; }
.chat-lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #0f2744;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  z-index: 9999;
  min-width: 110px;
  overflow: hidden;
  animation: menuIn .2s ease;
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-lang-menu.open { display: block; }
.chat-lang-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  background: transparent;
  border: none;
  color: #b0bec5;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.chat-lang-menu button:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.chat-lang-menu button.active {
  background: rgba(41,182,246,.15);
  color: #29b6f6;
}
.chat-lang-menu button svg { width: 18px; height: 13px; flex-shrink: 0; }

/* Messages Area */
#chat-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.5;
  scroll-behavior: smooth;
}
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }
#chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }

/* Message Bubbles */
.msg { margin-bottom: 12px; animation: msgIn .3s ease; }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg.user { text-align: right; }
.msg.bot { text-align: left; display: flex; gap: 8px; align-items: flex-start; }
.msg .bot-avatar {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #0d47a1, #1976d2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}
.msg.user span,
.msg.bot span {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 16px;
  max-width: 82%;
  text-align: left;
  word-break: break-word;
}
.msg.user span {
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(13,71,161,.25);
}
.msg.bot span {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-bottom-left-radius: 4px;
  white-space: pre-line;
  color: #e3f2fd;
}
.msg.bot span strong { color: #4fc3f7; font-weight: 600; }

/* Typing Animation */
.typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 6px 0;
}
.typing-dots span {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #29b6f6;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
  padding: 0 !important;
  border: none !important;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .3; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* Chat Links */
.chat-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 7px 14px;
  background: rgba(25,118,210,.12);
  border: 1px solid rgba(25,118,210,.25);
  border-radius: 10px;
  color: #4fc3f7;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  transition: all .25s;
}
.chat-link:hover {
  background: rgba(25,118,210,.25);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(25,118,210,.2);
}
.chat-link-wa {
  background: rgba(37,211,102,.1);
  border-color: rgba(37,211,102,.3);
  color: #4caf50;
}
.chat-link-wa:hover {
  background: rgba(37,211,102,.22);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37,211,102,.2);
}

/* Input Area */
.chat-input {
  display: flex;
  padding: 12px;
  background: #0d1f33;
  gap: 8px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.chat-input input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  outline: none;
  background: rgba(255,255,255,.04);
  color: #e3f2fd;
  font-size: 13.5px;
  transition: border-color .2s, background .2s;
}
.chat-input input::placeholder { color: rgba(255,255,255,.3); }
.chat-input input:focus {
  border-color: rgba(41,182,246,.4);
  background: rgba(255,255,255,.06);
}
.chat-input button {
  padding: 11px 18px;
  background: linear-gradient(135deg, #1565c0, #1976d2);
  border: none;
  color: #fff;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all .2s;
  white-space: nowrap;
}
.chat-input button:hover {
  background: linear-gradient(135deg, #1976d2, #2196f3);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(25,118,210,.3);
}

/* Responsive */
@media (max-width: 480px) {
  #chat-popup {
    width: calc(100% - 24px);
    right: 12px;
    left: 12px;
    bottom: 80px;
    height: calc(100vh - 120px);
    max-height: 520px;
    border-radius: 16px;
  }
  #chat-toggle { bottom: 16px; right: 16px; width: 54px; height: 54px; font-size: 22px; }
  .chat-header { padding: 12px 14px; }
  #chat-messages { padding: 10px; }
  .chat-input { padding: 10px; }
  .chat-input input { padding: 10px 12px; font-size: 14px; }
}

/* Touch */
#chat-toggle, #chat-send, #chat-close, #chat-clear { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
