/* Visorium Visa Bot — Allvisa-style floating chat */

.vvb-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

/* ── FAB ── */
.vvb-fab {
  position: relative;
  width: 95px;
  height: 95px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e3a8a, #2563eb 55%, #3b82f6);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 32px rgba(30, 58, 138, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  animation: vvb-fab-pulse 2s ease-in-out infinite;
}

.vvb-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 14px 40px rgba(30, 58, 138, 0.65);
  animation: none;
}

.vvb-fab--anna {
  padding: 0;
  overflow: visible;
  background: #fff;
}

.vvb-fab--anna .vvb-fab__avatar {
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #2563eb, 0 10px 32px rgba(30, 58, 138, 0.45);
}

.vvb-fab__avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.vvb-fab__online {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #22c55e;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
  z-index: 2;
  pointer-events: none;
}

.vvb-fab__svg {
  width: 38px;
  height: 38px;
  display: block;
  pointer-events: none;
}

@keyframes vvb-fab-pulse {
  0%,
  100% {
    box-shadow: 0 10px 32px rgba(30, 58, 138, 0.55), 0 0 0 0 rgba(59, 130, 246, 0.45);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 12px 36px rgba(30, 58, 138, 0.6), 0 0 0 14px rgba(59, 130, 246, 0);
    transform: scale(1.03);
  }
}

/* ── Backdrop (desktop + mobile) ── */
.vvb-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99990;
  background: rgba(15, 23, 42, 0.45);
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(1px);
}

.vvb-backdrop[hidden] {
  display: none !important;
}

.vvb-backdrop:not([hidden]) {
  display: block;
}

/* ── Panel ── */
.vvb-panel {
  position: absolute;
  right: 0;
  bottom: 110px;
  width: min(460px, calc(100vw - 32px));
  height: min(85vh, calc(100vh - 120px));
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.vvb-panel[hidden] {
  display: none !important;
}

.vvb-root--open .vvb-fab {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

@media (min-width: 769px) {
  .vvb-root--open .vvb-panel:not([hidden]) {
    position: fixed;
    top: calc(var(--vh-header-h, 72px) + 16px);
    right: 20px;
    bottom: 20px;
    left: auto;
    width: min(460px, calc(100vw - 40px));
    height: auto;
    max-height: none;
    z-index: 100001;
  }
}

/* ── Header (light, Allvisa-style) ── */
.vvb-panel__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: #fff;
  color: #0f172a;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.vvb-panel__avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid #e5e7eb;
}

.vvb-panel__head-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.vvb-panel__name {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  color: #0f172a;
}

.vvb-panel__status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #16a34a;
}

.vvb-panel__status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

.vvb-panel__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #f1f5f9;
  border: none;
  border-radius: 50%;
  color: #64748b;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s;
}

.vvb-panel__close:hover,
.vvb-panel__close:focus-visible {
  background: #e2e8f0;
  color: #0f172a;
  outline: none;
}

/* ── Scrollable body ── */
.vvb-panel__scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #f8fafc;
  -webkit-overflow-scrolling: touch;
}

/* ── Welcome block ── */
.vvb-welcome {
  padding: 18px 18px 12px;
  flex-shrink: 0;
}

.vvb-welcome--hidden {
  display: none;
}

.vvb-welcome__text {
  margin: 0 0 14px;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: #334155;
}

/* ── Quick reply chips ── */
.vvb-quick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  flex-shrink: 0;
}

.vvb-quick__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 3rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: #dbeafe;
  color: #1e3a8a;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.vvb-quick__btn:hover,
.vvb-quick__btn:focus-visible {
  background: #bfdbfe;
  border-color: #93c5fd;
  outline: none;
}

.vvb-quick__btn:active {
  transform: scale(0.98);
}

.vvb-quick__icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}

/* ── Messages ── */
.vvb-panel__messages {
  flex: 1;
  padding: 12px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.vvb-panel__messages:empty {
  display: none;
}

.vvb-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9375rem;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.vvb-msg--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.vvb-msg--user {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.vvb-msg--typing {
  opacity: 0.85;
  font-style: italic;
  animation: vvb-typing-pulse 1.2s ease-in-out infinite;
}

@keyframes vvb-typing-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

/* ── Quota + form ── */
.vvb-panel__quota {
  margin: 0;
  padding: 6px 18px;
  font-size: 0.75rem;
  color: #94a3b8;
  background: #fff;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.vvb-panel__quota--blocked {
  color: #b45309;
  font-weight: 500;
}

.vvb-panel__form {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}

.vvb-panel__form input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  background: #f8fafc;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.vvb-panel__form input:focus {
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.vvb-panel__form input:disabled {
  background: #f1f5f9;
  cursor: not-allowed;
}

.vvb-panel__send {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 12px;
  background: #2563eb;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.vvb-panel__send:hover:not(:disabled) {
  background: #1d4ed8;
}

.vvb-panel__send:active:not(:disabled) {
  transform: scale(0.96);
}

.vvb-panel__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.vvb-blocked-cta {
  margin: 0 16px 14px;
  text-align: center;
  flex-shrink: 0;
}

.vvb-blocked-cta a {
  display: inline-block;
  padding: 10px 18px;
  background: #0e7490;
  color: #fff !important;
  text-decoration: none;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
}

body.vvb-body-lock {
  overflow: hidden;
  touch-action: none;
}

/* ── Mobile bottom sheet ── */
@media (max-width: 768px) {
  .vvb-root {
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    z-index: 999999;
    pointer-events: none;
  }

  .vvb-fab,
  .vvb-panel,
  .vvb-backdrop {
    pointer-events: auto;
  }

  body:has(.visorium-country-page) .vvb-fab,
  .vvb-fab {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 72px;
    height: 72px;
    min-width: 56px;
    min-height: 56px;
  }

  .vvb-root--open .vvb-fab {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
  }

  .vvb-panel:not([hidden]) {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: 100%;
    height: min(92dvh, calc(100dvh - env(safe-area-inset-top, 0px)));
    max-height: calc(100dvh - env(safe-area-inset-top, 0px));
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.18);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 999999;
  }

  .vvb-panel__form {
    padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
  }

  .vvb-panel__avatar {
    width: 52px;
    height: 52px;
  }
}

@media (max-width: 480px) {
  .vvb-panel:not([hidden]) {
    height: min(96dvh, calc(100dvh - env(safe-area-inset-top, 0px)));
  }
}
