/* =========================================================
   TEKI CHATBOT – FRONTEND STYLES
   ========================================================= */

:root {
  --teki-primary: #0f766e;
  --teki-primary-dark: #0d5c56;
  --teki-bg: #ffffff;
  --teki-surface: #f8fafc;
  --teki-border: #e2e8f0;
  --teki-text: #0f172a;
  --teki-muted: #64748b;
  --teki-user-bg: #0f766e;
  --teki-bot-bg: #f1f5f9;
  --teki-shadow: 0 20px 40px -12px rgba(15, 23, 42, 0.18);
  --teki-radius: 16px;
  --teki-fab-size: 60px;
}

/* Floating Action Button */
#teki-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: var(--teki-fab-size);
  height: var(--teki-fab-size);
  border-radius: 50%;
  background: var(--teki-primary);
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(15, 118, 110, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99998;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  overflow: hidden;
  padding: 0;
}

#teki-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.45);
}

#teki-fab img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 50%;
}

#teki-fab.hidden {
  display: none !important;
}

/* Chat Window */
#teki-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 24px);
  height: 580px;
  max-height: calc(100vh - 40px);
  background: var(--teki-bg);
  border-radius: var(--teki-radius);
  box-shadow: var(--teki-shadow);
  display: flex;
  flex-direction: column;
  z-index: 99999;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

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

/* Header */
.teki-header {
  background: linear-gradient(135deg, var(--teki-primary), #0d9488);
  color: white;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.teki-header img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: white;
  padding: 2px;
}

.teki-header-info {
  flex: 1;
  min-width: 0;
}

.teki-header-info h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: white;
}

.teki-header-info p {
  margin: 1px 0 0;
  font-size: 11px;
  opacity: 0.9;
  color: white;
}

.teki-header-actions {
  display: flex;
  gap: 6px;
}

.teki-icon-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  padding: 0;
}

.teki-icon-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Messages Area */
.teki-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: var(--teki-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.teki-messages::-webkit-scrollbar {
  width: 5px;
}

.teki-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* Message Bubbles */
.teki-msg {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
  animation: teki-fade-in 0.22s ease;
}

@keyframes teki-fade-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.teki-msg.user {
  align-self: flex-end;
  background: var(--teki-user-bg);
  color: white;
  border-bottom-right-radius: 4px;
}

.teki-msg.bot {
  align-self: flex-start;
  background: var(--teki-bot-bg);
  color: var(--teki-text);
  border-bottom-left-radius: 4px;
}

.teki-msg.bot a {
  color: var(--teki-primary);
  font-weight: 500;
  text-decoration: underline;
}

/* Typing Indicator */
.teki-typing {
  align-self: flex-start;
  background: var(--teki-bot-bg);
  padding: 11px 15px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: none;
  gap: 5px;
  margin: 0 14px 10px;
}

.teki-typing.active {
  display: flex;
}

.teki-typing span {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: teki-bounce 1.2s infinite ease-in-out;
}

.teki-typing span:nth-child(2) { animation-delay: 0.15s; }
.teki-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes teki-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Welcome Message */
.teki-welcome {
  text-align: center;
  color: var(--teki-muted);
  font-size: 13px;
  padding: 18px 10px;
  line-height: 1.5;
}

/* Input Area */
.teki-input-area {
  padding: 10px 12px;
  background: white;
  border-top: 1px solid var(--teki-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.teki-input-area textarea {
  flex: 1;
  border: 1px solid var(--teki-border);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13.5px;
  resize: none;
  max-height: 90px;
  outline: none;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color 0.2s;
  background: white;
  color: var(--teki-text);
}

.teki-input-area textarea:focus {
  border-color: var(--teki-primary);
}

.teki-send {
  background: var(--teki-primary);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
  padding: 0;
}

.teki-send:hover {
  background: var(--teki-primary-dark);
}

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

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

/* Mobile */
@media (max-width: 480px) {
  #teki-window {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }

  #teki-fab {
    bottom: 16px;
    right: 16px;
  }
}