/* =================================================================
   AppTools Support Chat Widget Styles
   ================================================================= */

:root {
  --chat-bg: rgba(22, 28, 45, 0.85);
  --chat-surface: rgba(30, 41, 59, 0.7);
  --chat-border: rgba(255, 255, 255, 0.08);
  --chat-accent: #00d4aa;
  --chat-accent-rgb: 0, 212, 170;
  --chat-text: #f8fafc;
  --chat-text-muted: #94a3b8;
  --chat-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 212, 170, 0.1);
}

/* Floating Chat Toggle Trigger */
.chat-toggle-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00b4db, var(--chat-accent));
  border: none;
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 212, 170, 0.3);
  z-index: 10000;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-toggle-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 212, 170, 0.5);
}

.chat-toggle-btn:active {
  transform: scale(0.95);
}

/* Chat window container */
.chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 520px;
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  box-shadow: var(--chat-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
}

.chat-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Chat Header */
.chat-header {
  padding: 16px 20px;
  background: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--chat-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
  box-shadow: 0 0 8px #10b981;
}

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

.chat-close-btn {
  background: none;
  border: none;
  color: var(--chat-text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.chat-close-btn:hover {
  color: var(--chat-text);
  background: rgba(255, 255, 255, 0.05);
}

/* Chat Content Areas */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(15, 23, 42, 0.2);
}

/* Scrollbar styling */
.chat-body::-webkit-scrollbar {
  width: 6px;
}
.chat-body::-webkit-scrollbar-track {
  background: transparent;
}
.chat-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
}
.chat-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Form Styles */
.chat-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  justify-content: center;
}

.chat-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-form-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--chat-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.chat-form-input, .chat-form-select, .chat-form-textarea {
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--chat-text);
  font-size: 0.85rem;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-form-input:focus, .chat-form-select:focus, .chat-form-textarea:focus {
  border-color: var(--chat-accent);
  box-shadow: 0 0 0 2px rgba(var(--chat-accent-rgb), 0.15);
}

.chat-form-textarea {
  resize: none;
  height: 80px;
}

.chat-form-submit {
  background: linear-gradient(135deg, #00b4db, var(--chat-accent));
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  margin-top: 8px;
}

.chat-form-submit:hover {
  opacity: 0.95;
}

.chat-form-submit:active {
  transform: scale(0.98);
}

/* Topic Button grid */
.chat-topic-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

.chat-topic-btn {
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--chat-text);
  font-size: 0.88rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-topic-btn:hover {
  border-color: var(--chat-accent);
  background: rgba(var(--chat-accent-rgb), 0.05);
  transform: translateX(4px);
}

.chat-topic-btn::after {
  content: '→';
  font-size: 16px;
  color: var(--chat-accent);
  opacity: 0;
  transition: opacity 0.2s;
}

.chat-topic-btn:hover::after {
  opacity: 1;
}

/* Message Bubbles */
.chat-message-row {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.chat-message-row.user {
  align-items: flex-end;
}

.chat-message-row.admin {
  align-items: flex-start;
}

.chat-message-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chat-message-row.user .chat-message-bubble {
  background: linear-gradient(135deg, #0099be, rgba(var(--chat-accent-rgb), 0.85));
  color: #fff;
  border-bottom-right-radius: 2px;
}

.chat-message-row.admin .chat-message-bubble {
  background: var(--chat-surface);
  color: var(--chat-text);
  border-bottom-left-radius: 2px;
  border: 1px solid var(--chat-border);
}

.chat-message-time {
  font-size: 0.68rem;
  color: var(--chat-text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.chat-message-system {
  align-self: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--chat-border);
  color: var(--chat-text-muted);
  font-size: 0.75rem;
  padding: 5px 12px;
  border-radius: 99px;
  text-align: center;
  max-width: 90%;
  line-height: 1.3;
}

/* Footer / Input area */
.chat-footer {
  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.5);
  border-top: 1px solid var(--chat-border);
  display: flex;
  gap: 10px;
  align-items: center;
}

.chat-input-field {
  flex: 1;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  padding: 8px 16px;
  color: var(--chat-text);
  font-size: 0.85rem;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
  height: 36px;
  box-sizing: border-box;
}

.chat-input-field:focus {
  border-color: var(--chat-accent);
}

.chat-send-btn {
  background: linear-gradient(135deg, #00b4db, var(--chat-accent));
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 212, 170, 0.2);
}

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

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

/* Welcome Title styling */
.chat-welcome-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--chat-text);
  margin: 10px 0 4px;
  text-align: center;
}

.chat-welcome-desc {
  font-size: 0.8rem;
  color: var(--chat-text-muted);
  text-align: center;
  margin: 0 0 20px 0;
  line-height: 1.4;
}

/* End chat ticket button */
.chat-end-btn {
  font-size: 0.72rem;
  font-weight: 600;
  color: #ff5c5c;
  background: rgba(255, 92, 92, 0.1);
  border: 1px solid rgba(255, 92, 92, 0.2);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-end-btn:hover {
  background: rgba(255, 92, 92, 0.2);
  border-color: #ff5c5c;
}

/* Loading indicator */
.chat-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px;
}

.chat-loading-dot {
  width: 6px;
  height: 6px;
  background: var(--chat-accent);
  border-radius: 50%;
  animation: chatBounce 1.4s infinite ease-in-out both;
}

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

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

@media (max-width: 480px) {
  .chat-window {
    width: calc(100% - 32px);
    right: 16px;
    bottom: 88px;
    height: calc(100% - 120px);
    max-height: 480px;
  }
  .chat-toggle-btn {
    bottom: 16px;
    right: 16px;
  }
}
