/**
 * Chat Widget - CSS Styling
 * Place this in: chat-live/backend/public/css/chat-widget.css
 */

/* Widget Container */
#chat-widget-container {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 350px;
  height: 500px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
  display: none;
  flex-direction: column;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  z-index: 9999;
  overflow: hidden;
}

#chat-widget-container.active {
  display: flex;
}

/* Header */
.chat-widget-header {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  padding: 20px;
  border-radius: 10px 10px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.chat-widget-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.close-btn:hover {
  transform: scale(1.1);
}

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  background: #f9f9f9;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* Messages */
.message {
  padding: 12px 15px;
  border-radius: 8px;
  word-wrap: break-word;
  max-width: 85%;
  font-size: 14px;
  line-height: 1.4;
  animation: slideIn 0.3s ease-in;
}

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

.message.user {
  background: #007bff;
  color: white;
  align-self: flex-end;
  border-radius: 8px 0 8px 8px;
  margin-left: auto;
}

.message.bot {
  background: #e9ecef;
  color: #333;
  align-self: flex-start;
  border-radius: 0 8px 8px 8px;
  margin-right: auto;
}

.message.system {
  background: #fff3cd;
  color: #856404;
  align-self: center;
  text-align: center;
  font-size: 12px;
  padding: 8px 12px;
}

/* Input Area */
.chat-input-area {
  display: flex;
  gap: 10px;
  padding: 15px;
  border-top: 1px solid #ddd;
  background: white;
  border-radius: 0 0 10px 10px;
}

#chat-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.3s;
  resize: none;
}

#chat-input:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

#chat-input::placeholder {
  color: #999;
}

/* Send Button */
#send-btn {
  padding: 10px 20px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.3s, transform 0.1s;
}

#send-btn:hover {
  background: #0056b3;
}

#send-btn:active {
  transform: scale(0.95);
}

/* Toggle Button */
.chat-toggle-bottom-right {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  z-index: 9998;
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
  transition: transform 0.3s, box-shadow 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-toggle-bottom-left {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  z-index: 9998;
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
  transition: transform 0.3s, box-shadow 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-toggle-bottom-right:hover,
.chat-toggle-bottom-left:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 123, 255, 0.6);
}

.chat-toggle-bottom-right:active,
.chat-toggle-bottom-left:active {
  transform: scale(0.95);
}

/* Loading State */
.message.loading {
  background: #e9ecef;
  color: #333;
  font-style: italic;
}

.message.loading::after {
  content: '';
  animation: dots 1.4s infinite;
}

@keyframes dots {
  0%, 20% {
    content: '';
  }
  40% {
    content: '.';
  }
  60% {
    content: '..';
  }
  80%, 100% {
    content: '...';
  }
}

/* Responsive Design */
@media (max-width: 480px) {
  #chat-widget-container {
    width: calc(100% - 20px);
    height: calc(100vh - 100px);
    right: 10px;
    left: 10px;
    bottom: auto;
    top: 60px;
  }

  .chat-toggle-bottom-right,
  .chat-toggle-bottom-left {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
}

/* Dark Mode (Optional) */
@media (prefers-color-scheme: dark) {
  #chat-widget-container {
    background: #2d2d2d;
    color: #fff;
  }

  .chat-messages {
    background: #1e1e1e;
  }

  .message.bot {
    background: #3d3d3d;
    color: #e0e0e0;
  }

  #chat-input {
    background: #3d3d3d;
    color: #fff;
    border-color: #555;
  }

  #chat-input::placeholder {
    color: #999;
  }
}

.chat-toggle {
  padding: 0 !important;
  box-sizing: border-box !important;
}
.chat-toggle img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 50% !important;
  display: block;
}

/* ===== Full Screen Chat Mode ===== */
.fullscreen-toggle-btn {
  background: none;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  margin-right: 4px;
}
.fullscreen-toggle-btn:hover {
  transform: scale(1.1);
}

#chat-widget-container.chat-fullscreen-mode {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  max-height: 100dvh !important;
  border-radius: 0 !important;
  z-index: 999999 !important;
  transition: all 0.3s ease-in-out;
}

#chat-widget-container:not(.chat-fullscreen-mode) {
  transition: all 0.3s ease-in-out;
}

#chat-widget-container.chat-fullscreen-mode .chat-widget-header {
  border-radius: 0;
}

#chat-widget-container.chat-fullscreen-mode {
  display: flex !important;
  flex-direction: column !important;
}
#chat-widget-container.chat-fullscreen-mode .chat-widget-header {
  flex-shrink: 0;
}
#chat-widget-container.chat-fullscreen-mode #chat-messages,
#chat-widget-container.chat-fullscreen-mode .chat-messages {
  max-height: none;
  height: auto;
  flex: 1 1 auto;
  overflow-y: auto;
}
#chat-widget-container.chat-fullscreen-mode .chat-input-area {
  flex-shrink: 0;
}

@media (max-width: 480px) {
  #chat-widget-container.chat-fullscreen-mode {
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
  }
}

.typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
}
.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #9aa0a6;
    display: inline-block;
    animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}
