/* ============================================
   Front-Facing Chat Widget Styles
   Same positioning as admin widget, simplified UI
   ============================================ */

/* FAB (Floating Action Button) */
.front-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: #008080;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 128, 128, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1090;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.front-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0, 128, 128, 0.5);
}

.front-chat-fab.hidden {
  display: none;
}

.front-chat-fab i {
  font-size: 1.5rem;
}

/* Tooltip label next to FAB */
.front-chat-fab-label {
  position: fixed;
  bottom: 36px;
  right: 90px;
  background: #fff;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  font-size: 0.875rem;
  font-weight: 500;
  color: #333;
  z-index: 1090;
  opacity: 0;
  transform: translateX(10px);
  transition: all 0.3s ease;
  white-space: nowrap;
  pointer-events: none;
}

.front-chat-fab:hover ~ .front-chat-fab-label,
.front-chat-fab-label.show {
  opacity: 1;
  transform: translateX(0);
}

/* Chat Panel */
.front-chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  height: 520px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  z-index: 1091;
  overflow: hidden;
  animation: frontChatSlideUp 0.25s ease-out;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              right 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              border-radius 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.front-chat-panel.expanded {
  width: 700px;
  height: 85vh;
  bottom: 50%;
  right: 50%;
  transform: translate(50%, 50%);
  border-radius: 16px;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.25);
}

/* Backdrop for expanded mode */
.front-chat-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1090;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.front-chat-backdrop.active {
  opacity: 1;
}

.front-chat-panel.open {
  display: flex;
}

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

/* Header */
.front-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background-color: #008080;
  color: #fff;
  flex-shrink: 0;
}

.front-chat-header-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}

.front-chat-header-info i {
  font-size: 1.25rem;
}

.front-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.front-chat-header-btn {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: background-color 0.15s ease;
}

.front-chat-header-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

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

/* Welcome message */
.front-chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 16px;
  color: #6c757d;
}

.front-chat-welcome i {
  color: #008080;
  margin-bottom: 12px;
  font-size: 2.5rem;
}

.front-chat-welcome p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Suggestion Chips */
.front-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  padding: 0 8px;
}

.front-chat-chip {
  background: transparent;
  border: 1px solid #008080;
  color: #008080;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.front-chat-chip:hover {
  background-color: #008080;
  color: #fff;
}

/* Message Bubbles */
.front-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

.front-chat-msg.user {
  align-self: flex-end;
}

.front-chat-msg.assistant {
  align-self: flex-start;
}

.front-chat-msg .bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.front-chat-msg.user .bubble {
  background-color: #f0f0f0;
  color: #333;
  border-bottom-right-radius: 4px;
}

.front-chat-msg.assistant .bubble {
  background-color: rgba(0, 128, 128, 0.1);
  color: #333;
  border-bottom-left-radius: 4px;
}

/* Typing Indicator */
.front-chat-typing {
  display: flex;
  align-items: center;
  align-self: flex-start;
  gap: 4px;
  padding: 10px 14px;
  background-color: rgba(0, 128, 128, 0.1);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}

.front-chat-typing .dot {
  width: 8px;
  height: 8px;
  background-color: #008080;
  border-radius: 50%;
  animation: frontChatBounce 1.2s infinite ease-in-out;
}

.front-chat-typing .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.front-chat-typing .dot:nth-child(3) {
  animation-delay: 0.4s;
}

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

/* Input Bar */
.front-chat-input-bar {
  padding: 12px 16px;
  border-top: 1px solid #e9ecef;
  flex-shrink: 0;
}

.front-chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.front-chat-input {
  flex: 1;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  resize: none;
  overflow-y: auto;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.15s ease;
}

.front-chat-input:focus {
  border-color: #008080;
  box-shadow: 0 0 0 2px rgba(0, 128, 128, 0.15);
}

.front-chat-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.front-chat-send {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 8px;
  background-color: #008080;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.front-chat-send:hover {
  background-color: #006d6d;
}

.front-chat-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Markdown inside assistant bubbles */
.front-chat-msg.assistant .bubble p {
  margin: 0 0 8px 0;
}

.front-chat-msg.assistant .bubble p:last-child {
  margin-bottom: 0;
}

.front-chat-msg.assistant .bubble ul,
.front-chat-msg.assistant .bubble ol {
  margin: 4px 0 8px 0;
  padding-left: 20px;
}

.front-chat-msg.assistant .bubble li {
  margin-bottom: 2px;
}

.front-chat-msg.assistant .bubble code {
  background-color: rgba(0, 0, 0, 0.06);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.8rem;
}

.front-chat-msg.assistant .bubble a {
  color: #008080;
  text-decoration: underline;
}

.front-chat-msg.assistant .bubble strong {
  font-weight: 600;
}

/* Powered-by footer */
.front-chat-powered {
  text-align: center;
  padding: 4px 16px 8px;
  font-size: 0.7rem;
  color: #adb5bd;
  flex-shrink: 0;
}

.front-chat-powered a {
  color: #008080;
  text-decoration: none;
}

/* Rate limit notice */
.front-chat-rate-limit {
  text-align: center;
  padding: 8px;
  font-size: 0.8rem;
  color: #dc3545;
  background: #fff5f5;
  border-radius: 8px;
}

/* ============================================
   Kai Avatar Styles
   ============================================ */
.kai-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00a0a0 0%, #006d6d 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kai-header-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.kai-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.kai-status {
  font-size: 0.7rem;
  opacity: 0.85;
  font-weight: 400;
}

.kai-welcome-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00a0a0 0%, #006d6d 100%);
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

/* Navigation Card */
.front-chat-nav-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(0, 128, 128, 0.05);
  border: 1px solid rgba(0, 128, 128, 0.2);
  border-left: 3px solid #008080;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  align-self: flex-start;
  max-width: 80%;
  text-decoration: none;
  color: inherit;
}

.front-chat-nav-card:hover {
  background: rgba(0, 128, 128, 0.1);
  border-color: rgba(0, 128, 128, 0.35);
  text-decoration: none;
  color: inherit;
}

.front-chat-nav-card i {
  font-size: 1.4rem;
  color: #008080;
  flex-shrink: 0;
}

.front-chat-nav-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: #333;
}

.front-chat-nav-hint {
  font-size: 0.75rem;
  color: #008080;
  margin-top: 1px;
}

/* ============================================
   Responsive: Full-screen on mobile (<576px)
   ============================================ */
@media (max-width: 575.98px) {
  .front-chat-fab {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
  }

  .front-chat-fab-label {
    display: none;
  }

  .front-chat-expand {
    display: none;
  }

  .front-chat-panel {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .front-chat-panel.expanded {
    width: 100%;
    height: 100%;
    bottom: 0;
    right: 0;
    transform: none;
    border-radius: 0;
  }
}
