/* css/chat-widget.css */
:root {
  --chat-primary: #1e3a8a; /* Deep blue to match Tiknet */
  --chat-secondary: #3b82f6; 
  --chat-bg: rgba(255, 255, 255, 0.85); /* Glassmorphic base */
  --chat-border: rgba(255, 255, 255, 0.3);
  --chat-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
  --chat-bubble-out: #3b82f6;
  --chat-bubble-in: #f1f5f9;
  --chat-text-dark: #1e293b;
  --chat-text-light: #ffffff;
}

/* Floating Action Button */
.tiknet-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.tiknet-chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.tiknet-chat-fab svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
  transition: transform 0.3s ease;
}

/* The Modal Container */
.tiknet-chat-modal {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 360px;
  height: 600px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 120px);
  background: var(--chat-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.tiknet-chat-modal.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
.tiknet-chat-header {
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
  padding: 16px 20px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

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

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

.tiknet-chat-subtitle {
  font-size: 12px;
  opacity: 0.8;
  margin: 0;
}

.tiknet-chat-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  padding: 4px;
}

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

/* Body */
.tiknet-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Pre-Chat Form */
.tiknet-prechat-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 10px 0;
  animation: fadeIn 0.4s ease;
}

.tiknet-chat-welcome {
  text-align: center;
  color: var(--chat-text-dark);
  margin-bottom: 8px;
}

.tiknet-chat-welcome h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.tiknet-chat-welcome p {
  font-size: 14px;
  color: #64748b;
  margin: 0;
}

.tiknet-chat-input-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--chat-text-dark);
  margin-bottom: 4px;
}

.tiknet-chat-input-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.9);
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.tiknet-chat-input-group input:focus {
  outline: none;
  border-color: var(--chat-secondary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.tiknet-btn-primary {
  background: var(--chat-primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
  font-size: 15px;
}

.tiknet-btn-primary:hover {
  background: var(--chat-secondary);
}

.tiknet-btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Messages */
.tiknet-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
  animation: slideUpFade 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.tiknet-msg-in {
  align-self: flex-start;
  background: var(--chat-bubble-in);
  color: var(--chat-text-dark);
  border-bottom-left-radius: 4px;
}

.tiknet-msg-out {
  align-self: flex-end;
  background: var(--chat-bubble-out);
  color: var(--chat-text-light);
  border-bottom-right-radius: 4px;
}

.tiknet-msg-author {
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 4px;
  display: block;
}

.tiknet-msg-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 4px;
  display: block;
  text-align: right;
}

/* Footer / Input Area */
.tiknet-chat-footer {
  padding: 16px;
  background: rgba(255,255,255,0.9);
  border-top: 1px solid rgba(0,0,0,0.05);
  display: none; /* hidden until chat starts */
}

.tiknet-chat-footer.active {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.tiknet-chat-textarea {
  flex: 1;
  background: rgba(0,0,0,0.04);
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 12px 16px;
  font-size: 14px;
  resize: none;
  max-height: 100px;
  min-height: 44px;
  font-family: inherit;
  transition: all 0.2s;
}

.tiknet-chat-textarea:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.3);
  background: white;
}

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

.tiknet-btn-send:hover {
  background: var(--chat-secondary);
  transform: scale(1.05);
}

.tiknet-btn-send svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  margin-left: 2px;
}

.tiknet-btn-send:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

/* Animations */
@keyframes slideUpFade {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Loading States */
.tiknet-chat-loader {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.tiknet-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: var(--chat-bubble-in);
  border-radius: 12px;
  align-self: flex-start;
  width: fit-content;
  align-items: center;
  display: none;
}
.tiknet-typing-indicator.active {
  display: flex;
  animation: slideUpFade 0.3s ease;
}

.tiknet-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

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

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

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .tiknet-chat-modal {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    max-width: 100%;
    border-radius: 0;
    border: none;
  }
}
