/* ============================================================
   ASTROJYOTHI AI CHAT — CSS
   Krishnalaya Temple Brown/Gold Theme
   ============================================================ */

:root {
  --ajac-primary:   #8B4513;
  --ajac-accent:    #FFD700;
  --ajac-dark:      #1a0800;
  --ajac-light:     #fdf8f0;
  --ajac-text:      #2d1200;
  --ajac-bot-bg:    #fff8ee;
  --ajac-user-bg:   linear-gradient(135deg, #8B4513, #D2691E);
  --ajac-shadow:    0 8px 32px rgba(139,69,19,0.25);
  --ajac-radius:    16px;
  --ajac-font:      'Segoe UI', 'Noto Sans Tamil', Arial, sans-serif;
}

/* ---- INLINE WRAPPER ---- */
.ajac-inline-wrapper {
  width: 100%;
  max-width: 780px;
  margin: 0 auto 40px;
  font-family: var(--ajac-font);
}

/* ---- FLOATING WRAPPER ---- */
.ajac-floating-wrapper {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999999;
  font-family: var(--ajac-font);
}

/* Float Toggle Button */
.ajac-float-btn {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--ajac-primary);
  border: 3px solid var(--ajac-accent);
  cursor: pointer;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(139,69,19,0.5);
  transition: transform 0.3s, box-shadow 0.3s;
  outline: none;
}

.ajac-float-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(139,69,19,0.7);
}

/* Pulse animation */
.ajac-float-pulse {
  position: absolute;
  top: -4px; right: -4px;
  width: 16px; height: 16px;
  background: #FF4444;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: ajac-pulse 2s infinite;
}

@keyframes ajac-pulse {
  0%   { transform: scale(1); opacity: 1; }
  50%  { transform: scale(1.4); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---- CHAT WIDGET ---- */
.ajac-chat-widget {
  width: 380px;
  height: 560px;
  background: #fff;
  border-radius: var(--ajac-radius);
  box-shadow: var(--ajac-shadow);
  border: 1px solid rgba(139,69,19,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ajac-slide-up 0.3s ease;
}

.ajac-floating-wrapper .ajac-chat-widget {
  position: absolute;
  bottom: 78px;
  right: 0;
}

.ajac-inline-wrapper .ajac-chat-widget {
  width: 100%;
  height: 600px;
}

.ajac-hidden { display: none !important; }

@keyframes ajac-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- HEADER ---- */
.ajac-header {
  background: linear-gradient(135deg, var(--ajac-dark), #2d1200);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--ajac-primary);
  flex-shrink: 0;
}

.ajac-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ajac-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--ajac-primary), #D2691E);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 2px solid var(--ajac-accent);
  flex-shrink: 0;
}

.ajac-header-info {
  display: flex;
  flex-direction: column;
}

.ajac-title {
  color: var(--ajac-accent);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.ajac-status {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #aaa;
  font-size: 11px;
  margin-top: 2px;
}

.ajac-dot {
  width: 7px;
  height: 7px;
  background: #44FF88;
  border-radius: 50%;
  animation: ajac-blink 2s infinite;
}

@keyframes ajac-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.ajac-header-right {
  display: flex;
  gap: 8px;
}

.ajac-clear-btn,
.ajac-close-btn {
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: all 0.2s;
  line-height: 1;
}

.ajac-clear-btn:hover { background: rgba(255,0,0,0.15); color: #ff6666; }
.ajac-close-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ---- MESSAGES ---- */
.ajac-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: var(--ajac-light);
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ajac-messages::-webkit-scrollbar { width: 4px; }
.ajac-messages::-webkit-scrollbar-track { background: transparent; }
.ajac-messages::-webkit-scrollbar-thumb { background: rgba(139,69,19,0.3); border-radius: 4px; }

/* Message groups */
.ajac-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.ajac-message.ajac-user { align-self: flex-end; align-items: flex-end; }
.ajac-message.ajac-bot  { align-self: flex-start; align-items: flex-start; }

/* Bubbles */
.ajac-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.ajac-message.ajac-bot .ajac-bubble {
  background: var(--ajac-bot-bg);
  color: var(--ajac-text);
  border: 1px solid rgba(139,69,19,0.15);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.ajac-message.ajac-user .ajac-bubble {
  background: var(--ajac-user-bg);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(139,69,19,0.3);
}

.ajac-time {
  font-size: 10px;
  color: #bbb;
  margin-top: 3px;
  padding: 0 4px;
}

/* ---- TYPING INDICATOR ---- */
.ajac-typing {
  padding: 0 14px 8px;
  background: var(--ajac-light);
  flex-shrink: 0;
}

.ajac-typing .ajac-bubble {
  background: var(--ajac-bot-bg);
  border: 1px solid rgba(139,69,19,0.15);
  display: inline-flex;
  gap: 5px;
  padding: 12px 16px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.ajac-dot-anim {
  width: 7px;
  height: 7px;
  background: var(--ajac-primary);
  border-radius: 50%;
  animation: ajac-typing-bounce 1.4s infinite ease-in-out;
}

.ajac-dot-anim:nth-child(1) { animation-delay: 0s; }
.ajac-dot-anim:nth-child(2) { animation-delay: 0.2s; }
.ajac-dot-anim:nth-child(3) { animation-delay: 0.4s; }

@keyframes ajac-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-6px); }
}

/* ---- QUICK SUGGESTIONS ---- */
.ajac-suggestions {
  padding: 8px 12px;
  background: var(--ajac-light);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid rgba(139,69,19,0.1);
  flex-shrink: 0;
}

.ajac-suggestion-btn {
  background: #fff;
  border: 1px solid rgba(139,69,19,0.3);
  color: var(--ajac-primary);
  padding: 5px 11px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: var(--ajac-font);
}

.ajac-suggestion-btn:hover {
  background: var(--ajac-primary);
  color: #fff;
  border-color: var(--ajac-primary);
}

/* ---- INPUT AREA ---- */
.ajac-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid rgba(139,69,19,0.15);
  flex-shrink: 0;
}

.ajac-input {
  flex: 1;
  border: 1.5px solid rgba(139,69,19,0.25);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--ajac-font);
  color: var(--ajac-text);
  background: var(--ajac-light);
  resize: none;
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.2s;
  line-height: 1.5;
}

.ajac-input:focus {
  border-color: var(--ajac-primary);
  box-shadow: 0 0 0 3px rgba(139,69,19,0.1);
}

.ajac-input::placeholder { color: #bba; }

.ajac-send-btn {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--ajac-primary), #D2691E);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(139,69,19,0.4);
}

.ajac-send-btn:hover {
  background: linear-gradient(135deg, var(--ajac-accent), #FFA500);
  color: var(--ajac-dark);
  transform: scale(1.05);
}

.ajac-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ---- FOOTER ---- */
.ajac-footer {
  text-align: center;
  font-size: 10px;
  color: #bbb;
  padding: 5px 12px;
  background: #fff;
  border-top: 1px solid rgba(139,69,19,0.08);
  flex-shrink: 0;
}

.ajac-footer a { color: var(--ajac-primary); text-decoration: none; }
.ajac-footer a:hover { color: var(--ajac-accent); }

/* ---- ERROR MESSAGE ---- */
.ajac-error .ajac-bubble {
  background: #fff0f0 !important;
  border-color: #ffcccc !important;
  color: #cc0000 !important;
}

/* ---- MOBILE ---- */
@media (max-width: 480px) {
  .ajac-floating-wrapper {
    bottom: 16px;
    right: 16px;
  }
  .ajac-floating-wrapper .ajac-chat-widget {
    width: calc(100vw - 32px);
    height: 70vh;
    right: 0;
  }
  .ajac-inline-wrapper .ajac-chat-widget {
    height: 520px;
  }
}
