/* Mia Chat Widget v3 - ChenXin Cargo */
/* Brand: #0B1D3A (navy) + #C9A84C (gold) */

#mia-widget {
  position: fixed;
  bottom: 24px; left: 24px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#mia-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0B1D3A 0%, #163356 100%);
  border: 2px solid #C9A84C;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(11,29,58,0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}

#mia-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(11,29,58,0.5);
}

#mia-toggle svg {
  width: 28px;
  height: 28px;
  fill: #C9A84C;
  transition: transform 0.3s ease;
}

#mia-toggle.open svg {
  transform: rotate(90deg);
}

#mia-toggle .mia-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: #C9A84C;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #0B1D3A;
  animation: mia-pulse 2s infinite;
}

@keyframes mia-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Welcome popup */
.mia-welcome-popup {
  position: absolute;
  bottom: 80px;
  left: 0;
  width: 300px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(11,29,58,0.2);
  padding: 20px;
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border: 1px solid rgba(201,168,76,0.3);
  animation: mia-popIn 0.4s ease;
}

.mia-welcome-popup.show {
  display: flex;
}

.mia-welcome-popup.dismissed {
  display: none !important;
}

@keyframes mia-popIn {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.mia-welcome-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 18px;
  color: #999;
  cursor: pointer;
  line-height: 1;
}
.mia-welcome-close:hover { color: #333; }

.mia-welcome-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0B1D3A 0%, #163356 100%);
  border: 2px solid #C9A84C;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #C9A84C;
  margin-bottom: 12px;
}

.mia-welcome-text {
  font-size: 14px;
  color: #333;
  line-height: 1.5;
  margin: 0 0 16px;
}

.mia-welcome-btns {
  display: flex;
  gap: 8px;
  width: 100%;
}

.mia-welcome-btn {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  border: none;
}

.mia-welcome-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.mia-welcome-btn.primary {
  background: #0B1D3A;
  color: #C9A84C;
}

.mia-welcome-btn.wa {
  background: #25D366;
  color: #fff;
}

/* Chat panel */
#mia-panel {
  position: absolute;
  bottom: 72px;
  left: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(11,29,58,0.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(201,168,76,0.2);
}

#mia-panel.visible {
  display: flex;
  animation: mia-slideUp 0.3s ease;
}

@keyframes mia-slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header */
.mia-header {
  background: linear-gradient(135deg, #0B1D3A 0%, #163356 100%);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.mia-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #C9A84C;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #0B1D3A;
  flex-shrink: 0;
}

.mia-header-info h3 {
  color: #fff;
  font-size: 15px;
  margin: 0;
  font-weight: 600;
}

.mia-header-info p {
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  margin: 2px 0 0;
}

.mia-header-status {
  width: 8px;
  height: 8px;
  background: #4CAF50;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.mia-close {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 20px;
  padding: 4px;
  line-height: 1;
}
.mia-close:hover { color: #fff; }

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

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

.mia-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.mia-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.mia-msg.user {
  align-self: flex-end;
  background: #0B1D3A;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.mia-msg.bot a {
  color: #C9A84C;
  text-decoration: underline;
}

/* Message timestamp - separate content and time */
.mia-msg-content {
  display: block;
}

.mia-msg-time {
  display: block;
  font-size: 10px;
  color: #999;
  margin-top: 4px;
  text-align: right;
  font-weight: 400;
  opacity: 0.7;
}

/* User message timestamp - white on navy */
.mia-msg.user .mia-msg-time {
  color: rgba(255,255,255,0.6);
}

/* FAQ section inside chat */
.mia-faq-section {
  padding: 8px 0;
}

.mia-faq-title {
  font-size: 12px;
  color: #888;
  margin: 0 0 10px;
  font-weight: 500;
}

.mia-faq-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  border-left: 3px solid #C9A84C;
  cursor: pointer;
  font-size: 13px;
  color: #333;
  transition: all 0.2s;
  text-align: left;
}

.mia-faq-btn:hover {
  border-color: #C9A84C;
  background: rgba(201,168,76,0.05);
  transform: translateX(4px);
}

.mia-faq-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.mia-faq-text {
  font-weight: 500;
}

/* Typing indicator */
.mia-typing {
  align-self: flex-start;
  padding: 10px 14px;
  background: #fff;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: none;
}

.mia-typing.visible { display: flex; gap: 4px; }

.mia-typing span {
  width: 7px;
  height: 7px;
  background: #C9A84C;
  border-radius: 50%;
  animation: mia-bounce 1.2s infinite;
}

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

@keyframes mia-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Input area */
.mia-input-area {
  padding: 12px 16px;
  background: #fff;
  border-top: 2px solid #C9A84C;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.mia-input-area input {
  flex: 1;
  border: 2px solid #0B1D3A;
  border-radius: 24px;
  padding: 12px 18px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.mia-input-area input:focus {
  border-color: #C9A84C;
  box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}

.mia-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0B1D3A 0%, #163356 100%);
  border: 2px solid #C9A84C;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.mia-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(11,29,58,0.3);
}

.mia-send-btn:disabled { background: #999; border-color: #999; cursor: not-allowed; }

.mia-send-btn svg {
  width: 18px;
  height: 18px;
  fill: #C9A84C;
}

/* Mobile */
@media (max-width: 480px) {
  #mia-widget { bottom: 16px; left: 16px; }
  #mia-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    bottom: 68px;
  }
  #mia-toggle { width: 52px; height: 52px; }
  .mia-welcome-popup { width: calc(100vw - 48px); }
  .mia-welcome-btns { flex-direction: column; }
}
