/**
 * @file chat-widget.css
 * @description Live chat widget styles for Inda Consulting Due Diligence website.
 *              Covers the floating action button with breathing animation, tooltip,
 *              dialog panel, message bubbles (user / robot), typing indicator,
 *              and input area with send button.
 * @version 2.0.0
 */

/* --- Floating Action Button --- */

.customer-service {
  position: fixed;
  right: 30px;
  bottom: 30px;
  z-index: 45;
}

.service-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: #040498;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 136, 255, 0.3);
  transition: all 0.3s ease;
  position: relative;
  border: none;
  outline: none;
  animation: breathe 2s infinite ease-in-out;
}

@keyframes breathe {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 2px 10px rgba(0, 136, 255, 0.3);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 4px 15px rgba(0, 136, 255, 0.5);
  }
}

.service-btn:hover {
  background-color: #040498;
  animation: none;
  transform: scale(1.1);
}

/* --- Tooltip --- */

.service-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 70px;
  top: 50%;
  transform: translateY(-50%) translateX(10px);
  background-color: #333;
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 14px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 10000;
}

.service-btn::before {
  content: "";
  position: absolute;
  right: 64px;
  top: 50%;
  transform: translateY(-50%) translateX(10px);
  border-width: 6px 0 6px 8px;
  border-style: solid;
  border-color: transparent transparent transparent #333;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 10000;
}

.service-btn:hover::after,
.service-btn:hover::before {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

/* --- Dialog Panel --- */

.service-dialog {
  width: 380px;
  max-width: calc(100% - 60px);
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
  position: fixed;
  right: 30px;
  z-index: 45;
  bottom: 100px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.service-dialog.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.dialog-header {
  background-color: #040498;
  color: white;
  padding: 12px 15px;
  border-radius: 8px 8px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dialog-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.online-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #4cd964;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(76, 217, 100, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(76, 217, 100, 0); }
  100% { box-shadow: 0 0 0 0 rgba(76, 217, 100, 0); }
}

.close-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
}

.close-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* --- Chat Messages --- */

.dialog-content {
  height: 300px;
  padding: 15px;
  overflow-y: auto;
  background-color: #f9f9f9;
}

.message {
  margin-bottom: 15px;
  max-width: 80%;
  opacity: 0;
  transform: translateY(10px);
  animation: messageIn 0.3s ease forwards;
}

@keyframes messageIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.robot {
  text-align: left;
  animation-delay: 0.1s;
}

.message.user {
  text-align: right;
  margin-left: auto;
  animation-delay: 0.2s;
}

.message-content {
  padding: 8px 12px;
  border-radius: 6px;
  display: inline-block;
  position: relative;
}

.robot .message-content {
  background-color: white;
  border: 1px solid #eee;
  border-radius: 6px 6px 6px 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.user .message-content {
  background-color: #040498;
  color: white;
  border-radius: 6px 6px 0 6px;
  box-shadow: 0 1px 2px rgba(0, 136, 255, 0.2);
}

/* --- Typing Indicator --- */

.loading {
  display: inline-flex;
  gap: 2px;
  padding: 8px;
  background-color: white;
  border-radius: 6px 6px 6px 0;
}

.loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #040498;
  animation: loading 1s infinite ease-in-out;
}

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

@keyframes loading {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* --- Input Area --- */

.dialog-input {
  padding: 10px 15px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 10px;
}

#messageInput {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 20px;
  outline: none;
  font-size: 14px;
  transition: all 0.3s ease;
}

#messageInput:focus {
  border-color: #040498;
  box-shadow: 0 0 0 3px rgba(0, 136, 255, 0.1);
  transform: translateX(-2px);
}

#sendBtn {
  padding: 8px 16px;
  background-color: #040498;
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

#sendBtn:hover {
  background-color: #040498;
  transform: scale(1.05);
}

#sendBtn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

#sendBtn:active::after {
  width: 200px;
  height: 200px;
  opacity: 0;
}
