/* Floating Chat Widget Styles */

.floating-chat-widget {
  position: fixed !important;
  bottom: 24px !important;
  right: 24px !important;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Chat Button */
.chat-widget-button {
  width: auto;
  min-width: 58px;
  height: 58px;
  border-radius: 999px;
  background: #0f766e;
  border: none;
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.28);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px;
  transition: all 0.3s ease;
  position: relative;
}

.chat-widget-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(15, 118, 110, 0.34);
}

.chat-widget-button:active {
  transform: scale(0.95);
}

.chat-widget-button .chat-icon,
.chat-widget-button .close-icon {
  width: 24px;
  height: 24px;
  color: white;
  transition: all 0.3s ease;
  flex: 0 0 auto;
}

.chat-widget-label {
  color: white;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.chat-widget-button .close-icon {
  display: none;
}

.chat-widget-button.widget-active .chat-icon {
  display: none;
}

.chat-widget-button.widget-active .chat-widget-label {
  display: none;
}

.chat-widget-button.widget-active .close-icon {
  display: block;
}

/* Unread Badge */
.unread-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  border: 2px solid white;
}

.unread-badge.hidden {
  display: none;
}

/* Chat Window */
.chat-window {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: min(390px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 116px));
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: 0 20px 54px rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  transform-origin: bottom right;
}

.chat-window.hidden {
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
}

.chat-window.chat-window-open {
  opacity: 1;
  transform: scale(1);
}

/* Chat Header */
.chat-header {
  background: #0f172a;
  color: white;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

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

.chat-status {
  margin: 0;
  font-size: 12px;
  opacity: 0.9;
}

.chat-close-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.chat-close-btn:hover {
  opacity: 1;
}

.chat-close-btn svg {
  width: 20px;
  height: 20px;
}

/* Chat Body */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f7fafc;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e0 #f7fafc;
}

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

.chat-body::-webkit-scrollbar-track {
  background: #f7fafc;
}

.chat-body::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 3px;
}

/* Chat Messages */
.chat-message {
  margin-bottom: 16px;
  animation: slideIn 0.3s ease;
}

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

.message-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 85%;
  word-wrap: break-word;
}

.chat-message-user .message-bubble {
  background: #0f766e;
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.chat-message-assistant .message-bubble {
  background: white;
  color: #2d3748;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

.chat-message-error .message-bubble {
  background: #fed7d7;
  color: #c53030;
  border: 1px solid #fc8181;
}

.message-bubble p {
  margin: 0 0 8px 0;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-time {
  font-size: 10px;
  opacity: 0.7;
  display: block;
  margin-top: 4px;
}

/* Quick Actions */
.quick-actions {
  margin: 12px 0;
  padding: 12px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.quick-actions small {
  display: block;
  margin-bottom: 8px;
  color: #718096;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quick-action-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin: 6px 0;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #4a5568;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-action-btn:hover {
  background: #edf2f7;
  border-color: #cbd5e0;
  transform: translateX(2px);
}

/* Compact Table */
.compact-table {
  margin: 12px 0;
  overflow-x: auto;
}

.compact-table table {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
}

.compact-table th {
  background: #edf2f7;
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
  color: #4a5568;
  border-bottom: 2px solid #cbd5e0;
}

.compact-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e2e8f0;
  color: #2d3748;
}

.compact-table tr:last-child td {
  border-bottom: none;
}

/* Typing Indicator */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: #cbd5e0;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Chat Footer */
.chat-footer {
  background: white;
  border-top: 1px solid #e2e8f0;
  padding: 16px;
}

.chat-input-form {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: #0f766e;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.chat-input::placeholder {
  color: #a0aec0;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #0f766e;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.chat-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
}

.chat-footer-text {
  text-align: center;
}

.chat-footer-text small {
  font-size: 11px;
  color: #a0aec0;
}

.chat-link {
  color: #0f766e;
  text-decoration: none;
}

.chat-link:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 480px) {
  .chat-window {
    width: calc(100vw - 24px);
    height: calc(100vh - 104px);
    bottom: 74px;
    right: -12px;
  }
}

@media (max-width: 768px) {
  .floating-chat-widget {
    bottom: 16px !important;
    right: 16px !important;
  }
  
  .chat-widget-button {
    width: 56px;
    min-width: 56px;
    height: 56px;
    padding: 0;
  }

  .chat-widget-label {
    display: none;
  }
}
