/* ================================================
   KANTHIL CHATBOT PREMIUM - CSS STYLING
   Author: KANTHIL Development Team
   Features: Responsive Design, Animations, Dark Mode
   ================================================ */

:root {
  --chatbot-primary: #2563eb;
  --chatbot-primary-hover: #1d4ed8;
  --chatbot-accent: #3b82f6;
  --chatbot-success: #10b981;
  --chatbot-bg: #ffffff;
  --chatbot-bg-secondary: #f3f4f6;
  --chatbot-text: #1f2937;
  --chatbot-text-light: #6b7280;
  --chatbot-border: #e5e7eb;
  --chatbot-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  --chatbot-animation: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --chatbot-bg: #1f2937;
    --chatbot-bg-secondary: #111827;
    --chatbot-text: #f3f4f6;
    --chatbot-text-light: #d1d5db;
    --chatbot-border: #374151;
  }
}

/* ================================================
   CONTAINER & LAYOUT
   ================================================ */

.kanthil-chatbot-container {
  position: fixed;
  bottom: 0;
  right: 0;
  z-index: 9998;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ================================================
   FLOATING BUBBLE BUTTON
   ================================================ */

.chatbot-bubble {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-accent));
  border: none;
  color: white;
  cursor: pointer;
  box-shadow: var(--chatbot-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--chatbot-animation);
  font-size: 28px;
  padding: 0;
  z-index: 9999;
}

.chatbot-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 15px 50px rgba(37, 99, 235, 0.3);
}

.chatbot-bubble:active {
  transform: scale(0.95);
}

.chatbot-bubble.hidden {
  display: none;
}

/* Pulse Animation */
.bubble-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--chatbot-primary);
  opacity: 0;
  animation: pulse 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0;
  }
  50% {
    opacity: 0.3;
  }
  100% {
    transform: scale(1.3);
    opacity: 0;
  }
}

/* ================================================
   CHAT WINDOW
   ================================================ */

.chatbot-window {
  position: fixed;
  bottom: 90px;
  left: 20px;
  width: 380px;
  height: 600px;
  background: var(--chatbot-bg);
  border-radius: 12px;
  box-shadow: 0 5px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95) translateY(20px);
  transition: var(--chatbot-animation);
  z-index: 9999;
  overflow: hidden;
}

.chatbot-window.open {
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
}

/* ================================================
   HEADER
   ================================================ */

.chatbot-header {
  background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-accent));
  color: white;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 12px 12px 0 0;
  min-height: 60px;
}

.header-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.header-status {
  margin: 4px 0 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: var(--chatbot-animation);
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ================================================
   MESSAGES CONTAINER
   ================================================ */

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--chatbot-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--chatbot-border);
  border-radius: 3px;
}

.chatbot-message {
  display: flex;
  gap: 8px;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 12px;
  word-wrap: break-word;
  line-height: 1.4;
}

.message-bot .message-bubble {
  background: var(--chatbot-bg-secondary);
  color: var(--chatbot-text);
  border-bottom-left-radius: 4px;
}

.message-user {
  justify-content: flex-end;
}

.message-user .message-bubble {
  background: var(--chatbot-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-content strong {
  color: var(--chatbot-primary);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: var(--chatbot-bg-secondary);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chatbot-text-light);
  animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.5;
  }
  30% {
    opacity: 1;
  }
}

/* ================================================
   QUICK REPLIES
   ================================================ */

.chatbot-quick-replies {
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--chatbot-bg);
  border-top: 1px solid var(--chatbot-border);
  min-height: auto;
  max-height: 180px;
  overflow-y: auto;
}

.chatbot-quick-replies::-webkit-scrollbar {
  width: 4px;
}

.chatbot-quick-replies::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-quick-replies::-webkit-scrollbar-thumb {
  background: var(--chatbot-border);
  border-radius: 2px;
}

.quick-reply-btn {
  background: var(--chatbot-bg-secondary);
  border: 1px solid var(--chatbot-border);
  color: var(--chatbot-text);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--chatbot-animation);
  font-size: 12px;
  text-align: left;
  white-space: normal;
  line-height: 1.3;
}

.quick-reply-btn:hover {
  background: var(--chatbot-primary);
  color: white;
  border-color: var(--chatbot-primary);
}

/* ================================================
   INPUT FORM
   ================================================ */

.chatbot-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--chatbot-bg);
  border-top: 1px solid var(--chatbot-border);
  border-radius: 0 0 12px 12px;
}

.chatbot-input {
  flex: 1;
  border: 1px solid var(--chatbot-border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--chatbot-bg-secondary);
  color: var(--chatbot-text);
  font-size: 13px;
  transition: var(--chatbot-animation);
  outline: none;
}

.chatbot-input:focus {
  border-color: var(--chatbot-primary);
  background: var(--chatbot-bg);
}

.chatbot-input::placeholder {
  color: var(--chatbot-text-light);
}

.send-btn {
  background: var(--chatbot-primary);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--chatbot-animation);
  font-size: 18px;
  padding: 0;
}

.send-btn:hover {
  background: var(--chatbot-primary-hover);
  transform: scale(1.05);
}

.send-btn:active {
  transform: scale(0.95);
}

/* ================================================
   FOOTER
   ================================================ */

.chatbot-footer {
  text-align: center;
  font-size: 11px;
  color: var(--chatbot-text-light);
  margin: 0;
  padding: 8px;
  background: var(--chatbot-bg-secondary);
}

/* ================================================
   RESPONSIVE DESIGN
   ================================================ */

/* Extra Small (< 380px) */
@media (max-width: 379px) {
  .chatbot-window {
    width: calc(100vw - 16px);
    height: calc(100vh - 100px);
    bottom: 70px;
    right: 8px;
    border-radius: 16px;
    max-height: 85vh;
  }

  .chatbot-bubble {
    bottom: 12px;
    right: 12px;
    width: 54px;
    height: 54px;
  }

  .message-bubble {
    max-width: 85%;
  }
}

/* Small (380px - 480px) */
@media (min-width: 380px) and (max-width: 480px) {
  .chatbot-window {
    width: calc(100vw - 32px);
    height: calc(100vh - 110px);
    max-height: 500px;
    bottom: 80px;
  }

  .message-bubble {
    max-width: 80%;
  }
}

/* Medium (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
  .chatbot-window {
    width: calc(100vw - 60px);
    height: calc(100vh - 130px);
    max-width: 450px;
    bottom: 90px;
  }
}

/* Large (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .chatbot-window {
    width: 380px;
    height: 580px;
    bottom: 90px;
    right: 30px;
  }

  .chatbot-bubble {
    bottom: 30px;
    right: 30px;
  }
}

/* Extra Large (> 1024px) */
@media (min-width: 1025px) {
  .chatbot-window {
    width: 380px;
    height: 600px;
    bottom: 100px;
    right: 40px;
  }

  .chatbot-bubble {
    bottom: 40px;
    right: 40px;
    width: 64px;
    height: 64px;
    font-size: 32px;
  }
}

/* Landscape Orientation (max-height: 600px) */
@media (max-height: 600px) {
  .chatbot-window {
    height: calc(100vh - 60px) !important;
    max-height: 400px;
  }

  .chatbot-messages {
    padding: 12px;
  }

  .chatbot-header,
  .chatbot-form {
    padding: 12px;
  }
}

/* Tablet Portrait */
@media (min-width: 600px) and (max-width: 900px) and (orientation: portrait) {
  .chatbot-window {
    width: 90vw;
    max-width: 450px;
    height: 70vh;
    max-height: 550px;
  }
}

/* Tablet Landscape */
@media (min-width: 900px) and (orientation: landscape) {
  .chatbot-window {
    width: 380px;
    height: calc(100vh - 60px);
    max-height: 500px;
  }
}

/* ================================================
   SAFE AREA (Notched Devices)
   ================================================ */

@supports (padding: max(0px)) {
  .kanthil-chatbot-container {
    bottom: max(20px, env(safe-area-inset-bottom));
    right: max(20px, env(safe-area-inset-right));
  }

  .chatbot-bubble {
    bottom: max(20px, env(safe-area-inset-bottom));
    right: max(20px, env(safe-area-inset-right));
  }
}

/* ================================================
   PRINT STYLES
   ================================================ */

@media print {
  .kanthil-chatbot-container,
  .chatbot-bubble,
  .chatbot-window {
    display: none !important;
  }
}

/* ================================================
   ACCESSIBILITY
   ================================================ */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: more) {
  .chatbot-bubble {
    border: 2px solid var(--chatbot-text);
  }

  .message-bubble,
  .quick-reply-btn {
    border: 1.5px solid var(--chatbot-text);
  }
}
