/* ============================================================
   NARA Chatbot – BENTARA Virtual Assistant
   Premium Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---------- CSS Custom Properties ---------- */
:root {
  --chat-primary: #B82126;
  --chat-primary-hover: #8C191D;
  --chat-primary-light: #fef2f2;
  --chat-primary-glow: rgba(184, 33, 38, 0.25);
  --chat-secondary: #F59E0B;
  --chat-dark: #0f172a;
  --chat-dark-2: #1e293b;
  --chat-dark-3: #334155;
  --chat-gray-100: #f8fafc;
  --chat-gray-200: #e2e8f0;
  --chat-gray-300: #cbd5e1;
  --chat-gray-400: #94a3b8;
  --chat-gray-500: #64748b;
  --chat-gray-600: #475569;
  --chat-gray-700: #334155;
  --chat-white: #ffffff;
  --chat-success: #10b981;
  --chat-warning: #f59e0b;
  --chat-radius: 16px;
  --chat-radius-sm: 8px;
  --chat-radius-lg: 20px;
  --chat-radius-full: 50%;
  --chat-shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --chat-shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --chat-shadow-lg: 0 8px 30px rgba(0,0,0,0.15);
  --chat-shadow-xl: 0 20px 60px rgba(0,0,0,0.25);
  --chat-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --chat-transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --chat-transition-bounce: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --chat-font: 'Inter', 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  --chat-width: 420px;
  --chat-height: 600px;
  --chat-width-expanded: 780px;
  --chat-height-expanded: 720px;
}

/* ---------- CHATBOT TOGGLE BUTTON ---------- */
.chatbot-toggle {
  position: fixed;
  bottom: 104px;
  right: 28px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: var(--chat-radius-full);
  background: var(--chat-white);
  border: 2.5px solid var(--chat-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.22), 0 0 0 3px rgba(184, 33, 38, 0.35);
  transition: var(--chat-transition);
  outline: none;
  padding: 0;
  overflow: visible;
  animation: chatbot-float 3s ease-in-out infinite;
}

@keyframes chatbot-float {
  0%, 100% {
    transform: translateY(0);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.22), 0 0 0 3px rgba(184, 33, 38, 0.35);
  }
  50% {
    transform: translateY(-5px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.26), 0 0 0 4px rgba(184, 33, 38, 0.45);
  }
}

.chatbot-toggle:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), 0 0 0 4px var(--chat-primary);
}

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

.chatbot-toggle__avatar {
  width: 100%;
  height: 100%;
  border-radius: var(--chat-radius-full);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-toggle__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--chat-radius-full);
  display: block;
}

.chatbot-toggle__online-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 13px;
  height: 13px;
  background-color: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.85);
}

.chatbot-toggle .icon-close {
  display: none;
  width: 26px;
  height: 26px;
  color: var(--chat-white);
  transition: var(--chat-transition);
}

.chatbot-toggle.active {
  animation: none;
  background: linear-gradient(135deg, var(--chat-primary) 0%, #8C191D 100%);
  border-color: #ffffff;
  box-shadow: 0 6px 24px rgba(184, 33, 38, 0.45);
}

.chatbot-toggle.active .chatbot-toggle__avatar {
  display: none;
}

.chatbot-toggle.active .icon-close {
  display: block;
}

/* Notification Badge */
.chatbot-toggle__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: var(--chat-radius-full);
  background: var(--chat-secondary);
  color: var(--chat-white);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--chat-white);
  animation: chatbot-badge-bounce 1s ease-in-out infinite alternate;
  z-index: 2;
}

@keyframes chatbot-badge-bounce {
  0% { transform: scale(1); }
  100% { transform: scale(1.15); }
}

/* ---------- CHATBOT WINDOW ---------- */
.chatbot-window {
  position: fixed;
  bottom: 175px;
  right: 28px;
  z-index: 9999;
  width: var(--chat-width);
  height: var(--chat-height);
  max-width: calc(100vw - 36px);
  max-height: calc(100vh - 190px);
  border-radius: var(--chat-radius-lg);
  background: var(--chat-white);
  box-shadow: var(--chat-shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--chat-font);
  border: 1px solid var(--chat-gray-200);
}

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

/* EXPANDED (WIDE) MODE */
.chatbot-window.expanded {
  width: var(--chat-width-expanded);
  height: var(--chat-height-expanded);
  max-width: min(840px, calc(100vw - 40px));
  max-height: min(780px, calc(100vh - 120px));
  bottom: 104px;
}

.chatbot-window.expanded .chat-msg__bubble {
  font-size: 14.5px;
  line-height: 1.65;
}

.chatbot-window.expanded .chat-messages {
  padding: 20px 22px;
}

/* ---------- CHATBOT HEADER ---------- */
.chatbot-header {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-hover) 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

/* Decorative pattern overlay */
.chatbot-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 200px;
  height: 200px;
  border-radius: var(--chat-radius-full);
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}

.chatbot-header::after {
  content: '';
  position: absolute;
  bottom: -40%;
  left: -20%;
  width: 150px;
  height: 150px;
  border-radius: var(--chat-radius-full);
  background: rgba(255,255,255,0.04);
  pointer-events: none;
}

.chatbot-header__avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--chat-radius-full);
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  border: 2px solid rgba(255,255,255,0.3);
  overflow: hidden;
}

.chatbot-header__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chatbot-header__avatar svg {
  width: 22px;
  height: 22px;
  color: var(--chat-white);
}

.chatbot-header__info {
  flex: 1;
  position: relative;
  z-index: 1;
}

.chatbot-header__name {
  font-size: 15px;
  font-weight: 700;
  color: var(--chat-white);
  letter-spacing: 0.3px;
}

.chatbot-header__status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.chatbot-header__status-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--chat-radius-full);
  background: var(--chat-success);
  animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.chatbot-header__status-text {
  font-size: 11.5px;
  color: rgba(255,255,255,0.8);
  font-weight: 400;
}

.chatbot-header__actions {
  display: flex;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.chatbot-header__btn {
  width: 32px;
  height: 32px;
  border-radius: var(--chat-radius-sm);
  border: none;
  background: rgba(255,255,255,0.1);
  color: var(--chat-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--chat-transition-fast);
}

.chatbot-header__btn:hover {
  background: rgba(255,255,255,0.2);
}

.chatbot-header__btn svg {
  width: 16px;
  height: 16px;
}

/* ---------- CHATBOT MESSAGES AREA ---------- */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--chat-gray-100);
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.chatbot-messages::-webkit-scrollbar {
  width: 5px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--chat-gray-300);
  border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--chat-gray-400);
}

/* Message Bubbles */
.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: msg-appear 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes msg-appear {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg--bot {
  align-self: flex-start;
}

.chat-msg__avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--chat-radius-full);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  margin-top: 4px;
  overflow: hidden;
}

.chat-msg--bot .chat-msg__avatar {
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-hover));
  color: var(--chat-white);
}

.chat-msg--user .chat-msg__avatar {
  background: linear-gradient(135deg, var(--chat-dark-2), var(--chat-dark-3));
  color: var(--chat-white);
}

.chat-msg__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-msg__content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-msg__bubble {
  padding: 12px 16px;
  border-radius: var(--chat-radius);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--chat-dark);
  word-break: break-word;
  position: relative;
}

.chat-msg--bot .chat-msg__bubble {
  background: var(--chat-white);
  border: 1px solid var(--chat-gray-200);
  border-top-left-radius: 4px;
  box-shadow: var(--chat-shadow-sm);
}

.chat-msg--user .chat-msg__bubble {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-hover) 100%);
  color: var(--chat-white);
  border-top-right-radius: 4px;
  box-shadow: 0 2px 8px var(--chat-primary-glow);
}

/* Markdown-like formatting in bubble */
.chat-msg__bubble strong,
.chat-msg__bubble b {
  font-weight: 700;
}

.chat-msg__bubble em,
.chat-msg__bubble i {
  font-style: italic;
  opacity: 0.85;
}

.chat-msg__time {
  font-size: 10.5px;
  color: var(--chat-gray-400);
  padding: 0 4px;
}

.chat-msg--user .chat-msg__time {
  text-align: right;
}

/* Feedback buttons */
.chat-msg__feedback {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.chat-msg__feedback-btn {
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid var(--chat-gray-200);
  background: var(--chat-white);
  cursor: pointer;
  font-size: 11px;
  color: var(--chat-gray-500);
  transition: var(--chat-transition-fast);
  display: flex;
  align-items: center;
  gap: 3px;
}

.chat-msg__feedback-btn:hover {
  background: var(--chat-gray-100);
  border-color: var(--chat-gray-300);
  color: var(--chat-dark);
}

.chat-msg__feedback-btn.active {
  background: var(--chat-primary-light);
  border-color: var(--chat-primary);
  color: var(--chat-primary);
}

.chat-msg__feedback-btn svg {
  width: 12px;
  height: 12px;
}

/* Typing Indicator */
.chat-typing {
  display: flex;
  gap: 8px;
  align-self: flex-start;
  max-width: 88%;
  animation: msg-appear 0.3s ease both;
}

.chat-typing__avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--chat-radius-full);
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 4px;
  overflow: hidden;
}

.chat-typing__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-typing__bubble {
  background: var(--chat-white);
  border: 1px solid var(--chat-gray-200);
  border-radius: var(--chat-radius);
  border-top-left-radius: 4px;
  padding: 14px 20px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: var(--chat-shadow-sm);
}

.chat-typing__dot {
  width: 7px;
  height: 7px;
  border-radius: var(--chat-radius-full);
  background: var(--chat-gray-400);
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.chat-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); background: var(--chat-gray-400); }
  30% { transform: translateY(-6px); background: var(--chat-primary); }
}

/* ---------- SUGGESTIONS ---------- */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
  animation: msg-appear 0.4s ease both;
  animation-delay: 0.15s;
}

.chat-suggestion-btn {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--chat-primary);
  background: var(--chat-white);
  color: var(--chat-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--chat-transition-fast);
  white-space: nowrap;
  font-family: var(--chat-font);
}

.chat-suggestion-btn:hover {
  background: var(--chat-primary);
  color: var(--chat-white);
  box-shadow: 0 2px 8px var(--chat-primary-glow);
  transform: translateY(-1px);
}

.chat-suggestion-btn:active {
  transform: translateY(0);
}

/* ---------- CHATBOT INPUT AREA ---------- */
.chatbot-input {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--chat-white);
  border-top: 1px solid var(--chat-gray-200);
  flex-shrink: 0;
}

.chatbot-input__field {
  flex: 1;
  padding: 10px 16px;
  border-radius: 24px;
  border: 1.5px solid var(--chat-gray-200);
  background: var(--chat-gray-100);
  font-size: 13.5px;
  font-family: var(--chat-font);
  color: var(--chat-dark);
  outline: none;
  transition: var(--chat-transition-fast);
  resize: none;
  max-height: 80px;
  line-height: 1.4;
}

.chatbot-input__field::placeholder {
  color: var(--chat-gray-400);
}

.chatbot-input__field:focus {
  border-color: var(--chat-primary);
  background: var(--chat-white);
  box-shadow: 0 0 0 3px var(--chat-primary-glow);
}

.chatbot-input__send {
  width: 40px;
  height: 40px;
  border-radius: var(--chat-radius-full);
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-hover));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chat-white);
  transition: var(--chat-transition);
  flex-shrink: 0;
}

.chatbot-input__send:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px var(--chat-primary-glow);
}

.chatbot-input__send:active {
  transform: scale(0.95);
}

.chatbot-input__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chatbot-input__send svg {
  width: 18px;
  height: 18px;
}

/* ---------- POWERED BY FOOTER ---------- */
.chatbot-footer {
  text-align: center;
  padding: 6px;
  font-size: 10px;
  color: var(--chat-gray-400);
  background: var(--chat-white);
  border-top: 1px solid var(--chat-gray-100);
  flex-shrink: 0;
}

.chatbot-footer span {
  font-weight: 700;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------- WELCOME MESSAGE ---------- */
.chat-welcome {
  text-align: center;
  padding: 20px 16px;
  animation: msg-appear 0.5s ease both;
}

.chat-welcome__icon {
  width: 56px;
  height: 56px;
  border-radius: var(--chat-radius-full);
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  box-shadow: 0 4px 16px var(--chat-primary-glow);
  overflow: hidden;
}

.chat-welcome__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-welcome__icon svg {
  width: 28px;
  height: 28px;
  color: var(--chat-white);
}

.chat-welcome__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--chat-dark);
  margin-bottom: 6px;
}

.chat-welcome__desc {
  font-size: 12.5px;
  color: var(--chat-gray-500);
  line-height: 1.6;
  margin-bottom: 16px;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
  .chatbot-toggle {
    bottom: 80px;
    right: 18px;
    left: auto;
    width: 52px;
    height: 52px;
  }

  .chatbot-toggle svg {
    width: 22px;
    height: 22px;
  }

  .chatbot-window {
    bottom: 144px;
    right: 18px;
    left: auto;
    width: min(400px, calc(100vw - 36px));
    height: 560px;
    max-height: calc(100vh - 160px);
  }

  .chatbot-window.expanded {
    width: calc(100vw - 36px);
    max-width: 620px;
    height: calc(100vh - 100px);
    bottom: 80px;
    right: 18px;
  }
}

@media (max-width: 480px) {
  .chatbot-toggle {
    bottom: 74px;
    right: 16px;
    left: auto;
    width: 48px;
    height: 48px;
  }

  .chatbot-toggle__online-indicator {
    width: 11px;
    height: 11px;
  }

  .chatbot-toggle svg {
    width: 20px;
    height: 20px;
  }

  .chatbot-window {
    top: 0 !important;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    z-index: 99999 !important;
  }

  #chatbot-expand {
    display: none !important;
  }

  :root {
    --chat-width: 100%;
    --chat-height: 100%;
  }
}

/* ---------- DARK MODE SUPPORT ---------- */
@media (prefers-color-scheme: dark) {
  /* Only apply if you want auto dark mode support */
}
