.ollama-assistant,
.ollama-assistant * {
  box-sizing: border-box;
}

.ollama-assistant {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10000;
  color: #172033;
  font-family: inherit;
}

.ollama-assistant button,
.ollama-assistant textarea {
  font: inherit;
}

.ollama-assistant-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  box-shadow: 0 10px 28px rgba(37, 99, 235, .32);
  cursor: pointer;
  font-weight: 700;
}

.ollama-assistant-toggle-icon {
  font-size: 19px;
}

.ollama-assistant-toggle.has-unread {
  position: relative;
}

.ollama-assistant-toggle.has-unread:not(:has(.ollama-assistant-unread:not([hidden])))::after {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #ef4444;
  content: "";
}

.ollama-assistant-unread {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  background: #ef4444;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  animation: ollama-assistant-pulse 1.6s infinite;
}

.ollama-assistant-unread[hidden] {
  display: none;
}

.ollama-assistant-message.is-new {
  border-color: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, .25);
}

.ollama-assistant-message.is-new small::after {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  color: #fff;
  background: #ef4444;
  content: "Mới";
  font-size: 9px;
}

@keyframes ollama-assistant-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.ollama-assistant-welcome {
  position: absolute;
  right: 0;
  bottom: 60px;
  width: max-content;
  max-width: min(300px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 14px 14px 4px 14px;
  color: #172033;
  background: #fff;
  border: 1px solid #dbe3ef;
  box-shadow: 0 12px 36px rgba(15, 23, 42, .22);
  font-size: 14px;
  line-height: 1.45;
  animation: ollama-assistant-welcome-in .3s ease;
  transition: opacity .3s ease, transform .3s ease;
}

.ollama-assistant-welcome.is-hiding {
  opacity: 0;
  transform: translateY(8px);
}

@keyframes ollama-assistant-welcome-in {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ollama-assistant-panel {
  position: absolute;
  right: 0;
  bottom: 60px;
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 112px));
  overflow: hidden;
  border: 1px solid #dbe3ef;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .24);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(18px) scale(.9);
  transform-origin: bottom right;
  transition:
    opacity .22s ease,
    transform .32s cubic-bezier(.34, 1.56, .64, 1),
    visibility 0s linear .32s;
}

.ollama-assistant-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition-delay: 0s;
}

.ollama-assistant-toggle {
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s ease, filter .2s ease;
}

.ollama-assistant-toggle:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 16px 34px rgba(37, 99, 235, .42);
  filter: brightness(1.06);
}

.ollama-assistant-toggle:active {
  transform: scale(.95);
}

.ollama-assistant-toggle-icon {
  display: inline-block;
  animation: widget-icon-wiggle 4s ease-in-out infinite;
}

@keyframes widget-icon-wiggle {
  0%, 88%, 100% { transform: rotate(0); }
  92% { transform: rotate(-14deg); }
  96% { transform: rotate(12deg); }
}

.ollama-assistant-message {
  animation: widget-message-in .25s ease both;
}

@keyframes widget-message-in {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ollama-assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 12px 16px;
  color: #fff;
  background: linear-gradient(135deg, #1d4ed8, #4338ca);
}

.ollama-assistant-header div,
.ollama-assistant-header span {
  display: block;
}

.ollama-assistant-header strong {
  font-size: 15px;
}

.ollama-assistant-header span {
  margin-top: 3px;
  color: #dbeafe;
  font-size: 12px;
}

.ollama-assistant-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .16);
  cursor: pointer;
  font-size: 24px !important;
  line-height: 1;
}

.ollama-assistant-notice {
  padding: 9px 14px;
  border-bottom: 1px solid #e8edf5;
  color: #475569;
  background: #f8fafc;
  font-size: 11px;
  line-height: 1.5;
}

.ollama-assistant-messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 14px;
  background: #f8fafc;
}

.ollama-assistant-message {
  max-width: 88%;
  margin: 0;
  padding: 10px 12px;
  border-radius: 13px;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ollama-assistant-message.is-assistant {
  align-self: flex-start;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  color: #1e293b;
  background: #fff;
}

.ollama-assistant-message.is-user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  color: #fff;
  background: #2563eb;
}

.ollama-assistant-modebar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid #e8edf5;
  background: #fff;
}

.ollama-assistant-mode {
  flex: 1;
  min-height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #475569;
  background: #fff;
  cursor: pointer;
  font-size: 12px !important;
  font-weight: 600;
}

.ollama-assistant-mode[aria-pressed="true"] {
  border-color: #2563eb;
  color: #fff;
  background: #2563eb;
}

.ollama-assistant-message.is-admin {
  align-self: flex-start;
  border: 1px solid #bbf7d0;
  border-bottom-left-radius: 4px;
  color: #14532d;
  background: #f0fdf4;
}

.ollama-assistant-message small {
  display: block;
  margin-bottom: 2px;
  font-size: 10px;
  font-weight: 700;
  opacity: .7;
}

.ollama-assistant-message.is-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  padding: 13px 14px;
}

.ollama-assistant-message.is-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: ollama-assistant-bounce 1.2s infinite ease-in-out;
}

.ollama-assistant-message.is-typing span:nth-child(2) {
  animation-delay: .15s;
}

.ollama-assistant-message.is-typing span:nth-child(3) {
  animation-delay: .3s;
}

@keyframes ollama-assistant-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: .5;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

.ollama-assistant-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.ollama-assistant-input {
  flex: 1;
  min-width: 0;
  max-height: 100px;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  outline: none;
  color: #0f172a;
  background: #fff;
  font-size: 13px;
}

.ollama-assistant-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .14);
}

.ollama-assistant-send {
  min-height: 39px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  color: #fff;
  background: #2563eb;
  cursor: pointer;
  font-size: 13px !important;
  font-weight: 700;
}

.ollama-assistant-send:disabled {
  cursor: wait;
  opacity: .6;
}

.ollama-assistant-send.is-busy {
  font-size: 0;
}

.ollama-assistant-send.is-busy::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ollama-assistant-spin .7s linear infinite;
}

@keyframes ollama-assistant-spin {
  to { transform: rotate(360deg); }
}

.ollama-assistant-status {
  min-height: 17px;
  margin: -7px 12px 7px;
  color: #64748b;
  font-size: 11px;
}

.ollama-assistant-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@media (max-width: 480px) {
  .ollama-assistant {
    right: 12px;
    bottom: 12px;
  }

  .ollama-assistant-panel {
    bottom: 58px;
    height: min(560px, calc(100dvh - 90px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ollama-assistant-panel {
    transition: opacity .15s ease, visibility 0s linear .15s;
  }

  .ollama-assistant-toggle-icon,
  .ollama-assistant-message {
    animation: none;
  }

  .ollama-assistant-message.is-typing span {
    animation: none;
    opacity: .7;
  }
}
