/* ==================== ZeroMii Live Chat Widget ==================== */
#zmii-chat {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: 'Noto Sans JP', -apple-system, sans-serif;
}

/* ===== Chat Button ===== */
#zmii-chat-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2D8C3C, #5BBF3A);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(45, 140, 60, 0.35);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  animation: zmii-pulse 2.5s ease-in-out infinite;
}
#zmii-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 32px rgba(45, 140, 60, 0.45);
}
#zmii-chat-btn.zmii-btn-active {
  animation: none;
  transform: scale(0.9);
  opacity: 0.7;
}
@keyframes zmii-pulse {
  0%, 100% { box-shadow: 0 6px 24px rgba(45, 140, 60, 0.35); }
  50% { box-shadow: 0 6px 24px rgba(45, 140, 60, 0.35), 0 0 0 12px rgba(45, 140, 60, 0.1); }
}

/* ===== Badge ===== */
.zmii-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #E74C6F;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #fff;
  animation: zmii-bounce 0.4s ease;
}
@keyframes zmii-bounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ===== Chat Window ===== */
.zmii-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(45, 140, 60, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(0) scale(1);
  opacity: 1;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}
.zmii-window.zmii-hidden {
  transform: translateY(16px) scale(0.95);
  opacity: 0;
  pointer-events: none;
}

/* ===== Header ===== */
.zmii-header {
  background: linear-gradient(135deg, #2D8C3C, #5BBF3A);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.zmii-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.zmii-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.zmii-title {
  font-size: 14px;
  font-weight: 700;
}
.zmii-subtitle {
  font-size: 11px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 5px;
}
.zmii-online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #A8D948;
  animation: zmii-blink 2s infinite;
}
@keyframes zmii-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
#zmii-chat-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
#zmii-chat-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ===== Messages ===== */
.zmii-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  background: #FEFDF8;
  scroll-behavior: smooth;
}
.zmii-messages::-webkit-scrollbar {
  width: 4px;
}
.zmii-messages::-webkit-scrollbar-thumb {
  background: rgba(45, 140, 60, 0.2);
  border-radius: 4px;
}

.zmii-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: zmii-msg-in 0.25s ease;
}
@keyframes zmii-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.zmii-msg-visitor {
  align-self: flex-end;
  align-items: flex-end;
}
.zmii-msg-agent {
  align-self: flex-start;
  align-items: flex-start;
}
.zmii-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}
.zmii-msg-visitor .zmii-msg-bubble {
  background: linear-gradient(135deg, #2D8C3C, #5BBF3A);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.zmii-msg-agent .zmii-msg-bubble {
  background: #f0f4f0;
  color: #2D2926;
  border-bottom-left-radius: 4px;
}
.zmii-msg-time {
  font-size: 10px;
  color: #999;
  margin-top: 3px;
  padding: 0 4px;
}

/* ===== Media Messages ===== */
.zmii-msg-bubble-media {
  padding: 4px !important;
  overflow: hidden;
}
.zmii-msg-media {
  max-width: 200px;
  border-radius: 12px;
  display: block;
  cursor: pointer;
  margin-bottom: 4px;
}
.zmii-msg-caption {
  padding: 6px 10px 4px;
  font-size: 12px;
  color: #333;
}
.zmii-msg-visitor .zmii-msg-caption {
  color: rgba(255,255,255,0.9);
}

/* ===== Input ===== */
.zmii-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(45, 140, 60, 0.08);
  background: #fff;
  flex-shrink: 0;
}
#zmii-chat-input {
  flex: 1;
  border: 1px solid rgba(45, 140, 60, 0.15);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
#zmii-chat-input:focus {
  border-color: #5BBF3A;
  box-shadow: 0 0 0 3px rgba(91, 191, 58, 0.1);
}
#zmii-chat-input::placeholder {
  color: #aaa;
}
.zmii-input-area button[type="submit"] {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2D8C3C, #5BBF3A);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}
.zmii-input-area button[type="submit"]:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(45, 140, 60, 0.3);
}

/* ===== Avatar Image ===== */
.zmii-avatar-img {
  width: 115%;
  height: 115%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 18%;
}

/* ===== Welcome Prompt ===== */
.zmii-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  height: 100%;
}
.zmii-prompt-icon {
  font-size: 36px;
  margin-bottom: 12px;
}
.zmii-prompt-text {
  font-size: 13px;
  color: #666;
  line-height: 1.6;
}

/* ===== Searching Dot ===== */
.zmii-searching-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #F5A623;
  margin-right: 5px;
  animation: searchPulse 1.2s infinite;
}
@keyframes searchPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== Join Message ===== */
.zmii-msg-join span {
  background: rgba(45, 140, 60, 0.08) !important;
  color: #2D8C3C !important;
  font-weight: 600 !important;
}

/* ===== System Messages ===== */
.zmii-msg-system {
  text-align: center;
  padding: 4px 0;
}
.zmii-msg-system span {
  display: inline-block;
  background: rgba(45, 140, 60, 0.08);
  color: #2D8C3C;
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 500;
}

/* ===== Agent Info ===== */
.zmii-msg-agent-info {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: #888;
  margin-bottom: 3px;
  padding-left: 2px;
}
.zmii-agent-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: cover;
}

/* ===== Media ===== */
.zmii-msg-media {
  max-width: 100%;
  max-height: 160px;
  border-radius: 10px;
  margin-top: 6px;
  cursor: pointer;
  object-fit: cover;
}

/* ===== Message Preview Bubble ===== */
.zmii-msg-preview {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 240px;
  background: #fff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.14), 0 0 0 1px rgba(45,140,60,0.08);
  padding: 12px 14px;
  cursor: pointer;
  transform: translateY(8px);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.zmii-msg-preview.zmii-preview-in {
  opacity: 1;
  transform: translateY(0);
}
.zmii-msg-preview::after {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 18px;
  width: 14px;
  height: 14px;
  background: #fff;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
  box-shadow: 2px 2px 4px rgba(0,0,0,0.06);
}
.zmii-preview-name {
  font-size: 11px;
  font-weight: 700;
  color: #2D8C3C;
  margin-bottom: 4px;
}
.zmii-preview-text {
  font-size: 12px;
  color: #444;
  line-height: 1.5;
  word-break: break-word;
}

/* ===== Closed Banner ===== */
.zmii-closed-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 20px 20px;
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(45, 140, 60, 0.1);
  margin-top: 8px;
  gap: 8px;
}
.zmii-closed-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2D8C3C, #5BBF3A);
  color: #fff;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.zmii-closed-title {
  font-size: 13px;
  font-weight: 700;
  color: #2D2926;
}
.zmii-closed-sub {
  font-size: 11px;
  color: #888;
}
.zmii-stars {
  display: flex;
  gap: 6px;
  margin: 4px 0;
}
.zmii-star {
  background: none;
  border: none;
  font-size: 28px;
  color: #ddd;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s, transform 0.1s;
  padding: 0;
}
.zmii-star:hover,
.zmii-star-active {
  color: #F5A623;
  transform: scale(1.15);
}
.zmii-closed-rated {
  font-size: 12px;
  color: #2D8C3C;
  font-weight: 600;
}
.zmii-reconnect-btn {
  margin-top: 6px;
  background: linear-gradient(135deg, #2D8C3C, #5BBF3A);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}
.zmii-reconnect-btn:hover {
  opacity: 0.88;
  transform: scale(1.02);
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
  #zmii-chat {
    bottom: 16px;
    right: 16px;
  }
  #zmii-chat-btn {
    width: 54px;
    height: 54px;
  }
  .zmii-window {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 70vh;
    max-height: 70vh;
    border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .zmii-header {
    padding: 14px 16px;
  }
  #zmii-chat-close {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }
  .zmii-messages {
    padding: 12px;
  }
}

/* ===== Bottom offset for mobile sticky CTA ===== */
@media (max-width: 768px) {
  #zmii-chat {
    bottom: 76px;
  }
}
