
:root {
  --chatbot-primary: #059669;
  --chatbot-primary-dark: #047857;
  --chatbot-secondary: #0d9488;
  --chatbot-white: #ffffff;
  --chatbot-gray-50: #f9fafb;
  --chatbot-gray-100: #f3f4f6;
  --chatbot-gray-200: #e5e7eb;
  --chatbot-gray-300: #d1d5db;
  --chatbot-gray-400: #9ca3af;
  --chatbot-gray-600: #4b5563;
  --chatbot-gray-700: #374151;
  --chatbot-gray-800: #1f2937;
  --chatbot-red: #ef4444;
  --chatbot-amber: #f59e0b;
}

/* ===================================
   FLOATING ACTION BUTTON (FAB)
   =================================== */

.chatbot-fab {
  position: fixed !important;
  bottom: 5rem !important;
  right: 0.9rem !important;
  width: 64px;
  height: 64px;
  background: linear-gradient(
    135deg,
    var(--chatbot-primary) 0%,
    var(--chatbot-secondary) 100%
  );
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999999 !important;
  border: none;
  color: var(--chatbot-white);
  -webkit-tap-highlight-color: transparent;
  transform: translateZ(0);
  will-change: transform;
}

.chatbot-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

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

.chatbot-fab svg {
  width: 32px;
  height: 32px;
}

.chatbot-fab-tooltip {
  position: absolute;
  right: 75px;
  background: var(--chatbot-gray-800);
  color: var(--chatbot-white);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  z-index: 999999;
}

.chatbot-fab:hover .chatbot-fab-tooltip {
  opacity: 1;
}

/* ===================================
   CHATBOT CONTAINER
   =================================== */

.chatbot-container {
  position: fixed !important;
  bottom: 5rem;
  right: 2rem;
  width: 500px;
  max-width: calc(100vw - 4rem);
  height: 700px;
  max-height: calc(100vh - 4rem);
  background: var(--chatbot-white);
  border-radius: 1rem;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999999 !important;
  transform: scale(0.95) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
}

.chatbot-container.chatbot-active {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ===================================
   CHATBOT HEADER
   =================================== */

.chatbot-header {
  background: linear-gradient(
    135deg,
    var(--chatbot-primary) 0%,
    var(--chatbot-secondary) 100%
  );
  color: var(--chatbot-white);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.chatbot-header-icon {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chatbot-header-icon svg {
  width: 24px;
  height: 24px;
}

.chatbot-header-text {
  min-width: 0;
}

.chatbot-header-text h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatbot-header-text p {
  font-size: 0.75rem;
  opacity: 0.9;
  margin: 0;
  line-height: 1.2;
}

.chatbot-header-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.chatbot-header-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: var(--chatbot-white);
  width: 36px;
  height: 36px;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.chatbot-header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

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

/* ===================================
   CHATBOT MESSAGES
   =================================== */

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
  background: linear-gradient(
    to bottom,
    var(--chatbot-gray-50) 0%,
    var(--chatbot-white) 100%
  );
  -webkit-overflow-scrolling: touch;
}

.chatbot-message {
  display: flex;
  margin-bottom: 1.25rem;
  animation: chatbotMessageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

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

.chatbot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.75rem;
  flex-shrink: 0;
}

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

.chatbot-avatar-ai {
  background: var(--chatbot-primary);
  color: var(--chatbot-white);
}

.chatbot-message-user {
  flex-direction: row-reverse;
}

.chatbot-message-user .chatbot-avatar {
  background: var(--chatbot-gray-300);
  color: var(--chatbot-gray-700);
  margin-right: 0;
  margin-left: 0.75rem;
}

.chatbot-content {
  max-width: 75%;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.chatbot-bubble {
  padding: 0.875rem 1.125rem;
  border-radius: 1rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.6;
}

.chatbot-message-ai .chatbot-bubble {
  background: var(--chatbot-white);
  color: var(--chatbot-gray-800);
  border: 1px solid var(--chatbot-gray-200);
  border-bottom-left-radius: 0.25rem;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.chatbot-message-user .chatbot-bubble {
  background: linear-gradient(
    135deg,
    var(--chatbot-primary) 0%,
    var(--chatbot-secondary) 100%
  );
  color: var(--chatbot-white);
  border-bottom-right-radius: 0.25rem;
  margin-left: auto;
}

.chatbot-time {
  font-size: 0.75rem;
  color: var(--chatbot-gray-400);
  margin-top: 0.25rem;
  display: block;
}

.chatbot-message-user .chatbot-time {
  text-align: right;
}

/* Markdown Formatting */
.chatbot-bubble strong {
  font-weight: 600;
}

.chatbot-bubble p {
  margin: 0.5rem 0;
}

.chatbot-bubble p:first-child {
  margin-top: 0;
}

.chatbot-bubble p:last-child {
  margin-bottom: 0;
}

.chatbot-bubble ul,
.chatbot-bubble ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.chatbot-bubble li {
  margin: 0.25rem 0;
}

/* ===================================
   TYPING INDICATOR
   =================================== */

.chatbot-typing {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.125rem;
  background: var(--chatbot-white);
  border: 1px solid var(--chatbot-gray-200);
  border-radius: 1rem;
  max-width: fit-content;
}

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

.chatbot-typing-dot {
  width: 8px;
  height: 8px;
  background: var(--chatbot-gray-400);
  border-radius: 50%;
  animation: chatbotTypingBounce 1.4s infinite ease-in-out;
}

.chatbot-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes chatbotTypingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-8px);
  }
}

/* ===================================
   RATE LIMIT WARNING
   =================================== */

.chatbot-rate-limit {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: 0.5rem;
  border: 1px solid #fcd34d;
  font-size: 0.875rem;
  color: #92400e;
  animation: chatbotPulse 2s infinite;
  flex-wrap: wrap;
}

.chatbot-rate-limit.chatbot-rate-limit-show {
  display: flex;
}

.chatbot-rate-limit svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--chatbot-amber);
}

.chatbot-rate-limit strong {
  font-weight: 700;
  color: var(--chatbot-red);
  min-width: 2ch;
  text-align: center;
}

@keyframes chatbotPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

/* ===================================
   CHATBOT INPUT
   =================================== */

.chatbot-input-container {
  padding: 1rem 1.5rem;
  background: var(--chatbot-white);
  border-top: 1px solid var(--chatbot-gray-200);
  flex-shrink: 0;
}

.chatbot-input-wrapper {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.chatbot-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--chatbot-gray-300);
  border-radius: 1.5rem;
  font-size: 0.9375rem;
  font-family: inherit;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  line-height: 1.5;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  color: var(--chatbot-gray-800);
  background: var(--chatbot-white);
}

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

.chatbot-send-btn {
  background: linear-gradient(
    135deg,
    var(--chatbot-primary) 0%,
    var(--chatbot-secondary) 100%
  );
  border: none;
  color: var(--chatbot-white);
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.chatbot-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.chatbot-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--chatbot-gray-400);
}

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

/* ===================================
   SCROLLBAR
   =================================== */

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

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

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

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

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

/* Tablet & Medium Screens (768px - 640px) */
@media (max-width: 768px) {
  .chatbot-container {
    width: 380px;
    height: 560px;
  }

  .chatbot-header {
    padding: 1rem 1.25rem;
  }

  .chatbot-header-text h3 {
    font-size: 1.0625rem;
  }

  .chatbot-header-text p {
    font-size: 0.75rem;
  }

  .chatbot-messages {
    padding: 1.25rem;
  }

  .chatbot-bubble {
    font-size: 0.9375rem;
  }

  .chatbot-time {
    font-size: 0.75rem;
  }

  .chatbot-input {
    font-size: 0.9375rem;
  }

  .chatbot-rate-limit {
    font-size: 0.875rem;
  }

  .chatbot-fab-tooltip {
    font-size: 0.875rem;
  }
}

/* Mobile Large (640px - 480px) */
@media (max-width: 640px) {
  .chatbot-container {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }

  .chatbot-fab {
    bottom: 5rem !important;
    right: 1rem !important;
    width: 56px;
    height: 56px;
  }

  .chatbot-fab svg {
    width: 28px;
    height: 28px;
  }

  .chatbot-fab-tooltip {
    display: none;
  }

  .chatbot-header {
    padding: 1rem;
  }

  .chatbot-header-text h3 {
    font-size: 1rem;
  }

  .chatbot-header-text p {
    font-size: 0.75rem;
  }

  .chatbot-messages {
    padding: 1rem;
  }

  .chatbot-bubble {
    font-size: 0.9375rem;
  }

  .chatbot-time {
    font-size: 0.75rem;
  }

  .chatbot-input-container {
    padding: 0.875rem 1rem;
  }

  .chatbot-input {
    font-size: 0.9375rem;
  }

  .chatbot-rate-limit {
    font-size: 0.875rem;
  }
}

/* Mobile Medium (480px - 375px) */
@media (max-width: 480px) {
  .chatbot-fab {
    bottom: 5rem !important;
    right: 1rem !important;
    width: 52px;
    height: 52px;
  }

  .chatbot-fab svg {
    width: 26px;
    height: 26px;
  }

  .chatbot-header {
    padding: 0.875rem;
  }

  .chatbot-header-icon {
    width: 36px;
    height: 36px;
  }

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

  .chatbot-header-text h3 {
    font-size: 0.9375rem;
  }

  .chatbot-header-text p {
    font-size: 0.6875rem;
  }

  .chatbot-header-btn {
    width: 32px;
    height: 32px;
  }

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

  .chatbot-messages {
    padding: 0.875rem;
  }

  .chatbot-avatar {
    width: 32px;
    height: 32px;
  }

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

  .chatbot-content {
    max-width: 80%;
  }

  .chatbot-bubble {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }

  .chatbot-time {
    font-size: 0.6875rem;
  }

  .chatbot-input {
    font-size: 0.875rem;
    padding: 0.625rem 0.875rem;
  }

  .chatbot-send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

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

  .chatbot-rate-limit {
    font-size: 0.8125rem;
    padding: 0.75rem 0.875rem;
  }
}
@media (max-width: 640px) {
  .chatbot-fab {
    bottom: 4rem !important;
    right: 0.8rem !important;
    width: 50px;
    height: 50px;
  }
}
@media only screen and (max-width: 768px) {
  .chatbot-fab {
    bottom: 4rem !important;
    right: 0.8rem !important;
    width: 50px;
    height: 50px;
  }
}

/* Mobile Small (375px - 320px) */
@media (max-width: 375px) {
  .chatbot-fab {
    bottom: 5rem !important;
    right: 1rem !important;
    width: 48px;
    height: 48px;
  }

  .chatbot-fab svg {
    width: 24px;
    height: 24px;
  }

  .chatbot-header {
    padding: 0.75rem;
    gap: 0.5rem;
  }

  .chatbot-header-info {
    gap: 0.5rem;
  }

  .chatbot-header-icon {
    width: 32px;
    height: 32px;
  }

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

  .chatbot-header-text h3 {
    font-size: 0.875rem;
  }

  .chatbot-header-text p {
    font-size: 0.625rem;
  }

  .chatbot-header-actions {
    gap: 0.375rem;
  }

  .chatbot-header-btn {
    width: 30px;
    height: 30px;
  }

  .chatbot-header-btn svg {
    width: 14px;
    height: 14px;
  }

  .chatbot-messages {
    padding: 0.75rem;
  }

  .chatbot-message {
    margin-bottom: 1rem;
  }

  .chatbot-avatar {
    width: 28px;
    height: 28px;
    margin-right: 0.5rem;
  }

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

  .chatbot-message-user .chatbot-avatar {
    margin-left: 0.5rem;
    margin-right: 0;
  }

  .chatbot-content {
    max-width: 82%;
  }

  .chatbot-bubble {
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
  }

  .chatbot-time {
    font-size: 0.6875rem;
  }

  .chatbot-input-container {
    padding: 0.75rem;
  }

  .chatbot-input-wrapper {
    gap: 0.5rem;
  }

  .chatbot-input {
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
    min-height: 38px;
  }

  .chatbot-send-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }

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

  .chatbot-rate-limit {
    font-size: 0.75rem;
    padding: 0.625rem 0.75rem;
    gap: 0.5rem;
  }

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

  .chatbot-typing {
    padding: 0.75rem 1rem;
  }

  .chatbot-typing-dot {
    width: 7px;
    height: 7px;
  }
}

/* Extra Small Devices (320px and below) */
@media (max-width: 320px) {
  .chatbot-header-text h3 {
    font-size: 0.8125rem;
  }

  .chatbot-header-text p {
    font-size: 0.5625rem;
  }

  .chatbot-bubble {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }

  .chatbot-time {
    font-size: 0.5625rem;
  }

  .chatbot-input {
    font-size: 0.75rem;
  }

  .chatbot-rate-limit {
    font-size: 0.6875rem;
  }
}

/* Landscape Orientation untuk Mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .chatbot-container {
    height: 100vh;
    max-height: 100vh;
  }

  .chatbot-header {
    padding: 0.625rem 0.875rem;
  }

  .chatbot-header-text h3 {
    font-size: 0.9375rem;
  }

  .chatbot-header-text p {
    font-size: 0.6875rem;
  }

  .chatbot-messages {
    padding: 0.75rem;
  }

  .chatbot-bubble {
    font-size: 0.875rem;
  }

  .chatbot-time {
    font-size: 0.6875rem;
  }

  .chatbot-input {
    font-size: 0.875rem;
  }

  .chatbot-input-container {
    padding: 0.625rem 0.875rem;
  }

  .chatbot-message {
    margin-bottom: 0.75rem;
  }

  .chatbot-rate-limit {
    font-size: 0.8125rem;
  }
}