/*
 * LW Chat Widget Styles
 */

:root {
  --chat-color: #007cff;
  --chat-color-hover: #0066cc;
  --chat-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  --chat-border-radius: 20px;
}

#lw-chat-widget {
  position: fixed;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
}

/* Position variants */
.lw-chat-bottom-right {
  bottom: 20px;
  right: 20px;
}

.lw-chat-bottom-left {
  bottom: 20px;
  left: 20px;
}

.lw-chat-top-right {
  top: 20px;
  right: 20px;
}

.lw-chat-top-left {
  top: 20px;
  left: 20px;
}

/* Toggle Button */
.lw-chat-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chat-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--chat-shadow);
  transition: all 0.3s ease;
  position: relative;
  border: none;
}

.lw-chat-toggle:hover {
  background: var(--chat-color-hover);
  transform: scale(1.05);
}

.lw-chat-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff4444;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat Window */
.lw-chat-window {
  width: 380px;
  height: 500px;
  background: white;
  border-radius: var(--chat-border-radius);
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: absolute;
  bottom: 80px;
  right: 0;
}

/* Responsive positioning */
.lw-chat-bottom-left .lw-chat-window {
  left: 0;
  right: auto;
}

.lw-chat-top-right .lw-chat-window,
.lw-chat-top-left .lw-chat-window {
  top: 80px;
  bottom: auto;
}

/* Chat Header */
.lw-chat-header {
  background: var(--chat-color);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--chat-border-radius) var(--chat-border-radius) 0 0;
}

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

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

.lw-chat-title h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.lw-chat-status {
  font-size: 12px;
  opacity: 0.8;
}

.lw-chat-actions {
  display: flex;
  gap: 8px;
}

.lw-chat-btn-icon {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.lw-chat-btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* GDPR Consent */
.lw-chat-gdpr {
  padding: 24px;
  text-align: center;
  border-bottom: 1px solid #eee;
}

.lw-chat-gdpr-content p {
  font-size: 14px;
  line-height: 1.5;
  color: #666;
  margin: 0 0 20px 0;
}

.lw-chat-gdpr-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.lw-chat-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.lw-chat-btn-primary {
  background: var(--chat-color);
  color: white;
}

.lw-chat-btn-primary:hover {
  background: var(--chat-color-hover);
}

.lw-chat-btn-secondary {
  background: #f5f5f5;
  color: #666;
}

.lw-chat-btn-secondary:hover {
  background: #e0e0e0;
}

/* Quick Messages */
.lw-chat-quick-messages {
  padding: 20px;
  border-bottom: 1px solid #eee;
  max-height: 300px;
  overflow-y: auto;
}

.lw-chat-quick-messages-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.lw-chat-quick-messages-title {
  flex: 1;
}

.lw-chat-quick-messages-header h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: #333;
}

.lw-chat-quick-messages-header p {
  font-size: 14px;
  color: #666;
  margin: 0;
}

.lw-chat-quick-messages-header .lw-chat-btn-icon {
  color: #666;
  margin-left: 10px;
  flex-shrink: 0;
}

.lw-chat-quick-messages-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lw-chat-quick-message-btn {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  color: #495057;
  line-height: 1.4;
}

.lw-chat-quick-message-btn:hover {
  background: var(--chat-color);
  border-color: var(--chat-color);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 124, 255, 0.2);
}

.lw-chat-quick-message-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0, 124, 255, 0.2);
}

/* Chat Messages */
.lw-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafbfc;
}

.lw-chat-message {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin: 4px 0;
  animation: lw-chat-message-appear 0.3s ease-out;
}

.lw-chat-message-customer {
  background: linear-gradient(135deg, var(--chat-color) 0%, var(--chat-color-hover) 100%);
  color: white;
  align-self: flex-end;
  margin-left: auto;
  margin-right: 8px;
  border-bottom-right-radius: 6px;
}

.lw-chat-message-customer::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: -8px;
  width: 0;
  height: 0;
  border-left: 8px solid var(--chat-color-hover);
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.lw-chat-message-assistant {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  color: #333;
  align-self: flex-start;
  margin-right: auto;
  margin-left: 8px;
  border-bottom-left-radius: 6px;
  border: 1px solid #e8ecf0;
}

.lw-chat-message-assistant::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-right: 8px solid #f8f9fa;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.lw-chat-message-time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 6px;
  text-align: right;
  font-weight: 400;
}

.lw-chat-message-assistant .lw-chat-message-time {
  text-align: left;
}

/* Message animation */
@keyframes lw-chat-message-appear {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Message grouping - reduce spacing between consecutive messages from same sender */
.lw-chat-message-customer + .lw-chat-message-customer {
  margin-top: 8px;
}

.lw-chat-message-assistant + .lw-chat-message-assistant {
  margin-top: 8px;
}

/* First message from each sender gets more spacing */
.lw-chat-message-customer:not(.lw-chat-message-customer + .lw-chat-message-customer) {
  margin-top: 16px;
}

.lw-chat-message-assistant:not(.lw-chat-message-assistant + .lw-chat-message-assistant) {
  margin-top: 16px;
}

/* Input Area */
.lw-chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid #eee;
}

.lw-chat-input-container {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: #f8f9fa;
  border-radius: 20px;
  padding: 4px;
}

.lw-chat-input {
  flex: 1;
  border: none;
  background: none;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 100px;
}

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

.lw-chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--chat-color);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

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

.lw-chat-send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.lw-chat-powered-by {
  text-align: center;
  font-size: 11px;
  color: #999;
  margin-top: 8px;
}

/* Loading Animation */
.lw-chat-loading {
  padding: 20px;
  text-align: center;
}

.lw-chat-loading-dots {
  display: inline-flex;
  gap: 4px;
}

.lw-chat-loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--chat-color);
  border-radius: 50%;
  animation: lw-chat-loading 1.4s ease-in-out infinite both;
}

.lw-chat-loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}
.lw-chat-loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes lw-chat-loading {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Animations */
.lw-chat-window.lw-chat-opening {
  animation: lw-chat-slide-in 0.3s ease-out;
}

.lw-chat-window.lw-chat-closing {
  animation: lw-chat-slide-out 0.3s ease-in;
}

@keyframes lw-chat-slide-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes lw-chat-slide-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
}

/* Responsive Design */
@media (max-width: 480px) {
  .lw-chat-window {
    width: calc(100vw - 20px);
    height: calc(100vh - 100px);
    position: fixed;
    bottom: 10px;
    left: 10px;
    right: 10px;
  }

  .lw-chat-bottom-right .lw-chat-window,
  .lw-chat-bottom-left .lw-chat-window {
    right: 10px;
    left: 10px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .lw-chat-toggle,
  .lw-chat-btn,
  .lw-chat-send-btn {
    transition: none;
  }

  .lw-chat-window.lw-chat-opening,
  .lw-chat-window.lw-chat-closing {
    animation: none;
  }
}
