/* Site-wide Aacharya Ji chat widget */

.aacharya-global {
  --aacharya-fab-size: 2.5rem;
  --aacharya-fab-gap: 0.45rem;
  --aacharya-stack: calc(var(--aacharya-fab-size) + var(--aacharya-fab-gap));
  --aacharya-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  position: fixed;
  z-index: 9000;
  right: max(0.65rem, env(safe-area-inset-right));
  bottom: var(--aacharya-bottom);
  width: var(--aacharya-fab-size);
  height: var(--aacharya-fab-size);
  font-family: var(--font-body, system-ui, sans-serif);
  pointer-events: none;
}

.aacharya-global.is-drag-positioned {
  right: auto;
  bottom: auto;
}

html.phone-ui .aacharya-global {
  --aacharya-bottom: calc(
    var(--m-tabbar-total-h, 56px) + 0.45rem + env(safe-area-inset-bottom, 0px)
  );
}

.aacharya-global__fab-wrap,
.aacharya-global__fab,
.aacharya-global__panel {
  pointer-events: auto;
}

.aacharya-global__fab-wrap {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--aacharya-fab-size);
  height: var(--aacharya-fab-size);
}

.aacharya-global__fab-wrap[hidden] {
  display: none !important;
}

.aacharya-global__fab-dismiss {
  position: absolute;
  top: -5px;
  right: -5px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border: 1px solid rgba(201, 162, 39, 0.55);
  border-radius: 50%;
  background: #2b120c;
  color: #f7ecda;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(28, 12, 8, 0.35);
}

.aacharya-global__fab-dismiss:hover,
.aacharya-global__fab-dismiss:focus-visible {
  background: #4a1814;
  color: #fff8eb;
}

.aacharya-global__fab-dismiss:focus-visible {
  outline: 2px solid rgba(201, 162, 39, 0.85);
  outline-offset: 1px;
}

@keyframes aacharya-fab-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@keyframes aacharya-fab-pulse {
  0% {
    transform: scale(1);
    opacity: 0.55;
  }
  70% {
    transform: scale(1.55);
    opacity: 0;
  }
  100% {
    transform: scale(1.55);
    opacity: 0;
  }
}

@keyframes aacharya-dot-breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.12);
    opacity: 0.85;
  }
}

@keyframes aacharya-teaser-nudge {
  0%,
  78%,
  100% {
    opacity: 0;
    transform: translateY(-50%) translateX(6px) scale(0.96);
  }
  82%,
  92% {
    opacity: 1;
    transform: translateY(-50%) translateX(0) scale(1);
  }
}

@keyframes aacharya-panel-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.aacharya-global__fab {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  align-items: center;
  justify-content: center;
  width: var(--aacharya-fab-size);
  height: var(--aacharya-fab-size);
  padding: 0;
  border: 1.5px solid rgba(201, 162, 39, 0.55);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 220, 160, 0.35), transparent 55%),
    linear-gradient(155deg, #e07818 0%, #a84808 48%, #6b2800 100%);
  color: #fff8eb;
  box-shadow:
    0 3px 14px rgba(92, 46, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  cursor: pointer;
  animation: aacharya-fab-float 3.2s ease-in-out infinite;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    filter 0.2s ease;
}

.aacharya-global__fab:active {
  transform: translateY(0) scale(0.94);
  filter: brightness(0.98);
}

.aacharya-global.is-dragging .aacharya-global__fab {
  cursor: grabbing;
  animation: none;
  transform: scale(1.02);
  filter: brightness(1.04);
  z-index: 1;
}

.aacharya-global__fab-glow {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.22), transparent 68%);
  pointer-events: none;
  z-index: -1;
}

.aacharya-global__fab:hover,
.aacharya-global__fab:focus-visible {
  animation-play-state: paused;
  transform: translateY(-2px) scale(1.04);
  filter: brightness(1.06);
  box-shadow:
    0 4px 14px rgba(92, 46, 0, 0.4),
    0 0 0 1px rgba(139, 58, 0, 0.25);
}

.aacharya-global__fab:focus-visible {
  outline: 2px solid rgba(201, 162, 39, 0.85);
  outline-offset: 2px;
}

.aacharya-global__fab-ring {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1px solid rgba(212, 106, 18, 0.45);
  animation: aacharya-fab-pulse 2.4s ease-out infinite;
  pointer-events: none;
}

.aacharya-global__fab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.aacharya-global__fab-om {
  font-family: var(--display, "Cormorant Garamond", Georgia, serif);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.aacharya-global__fab-chat {
  position: absolute;
  right: -0.05rem;
  bottom: -0.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: #fffef9;
  color: #8b3a00;
  border: 1px solid rgba(139, 58, 0, 0.2);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.aacharya-global__fab-chat svg {
  display: block;
}

.aacharya-global__fab-dot {
  position: absolute;
  top: 0.05rem;
  right: 0.05rem;
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: #4ade80;
  border: 1.5px solid #fffef9;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
  animation: aacharya-dot-breathe 2.8s ease-in-out infinite;
}

.aacharya-global__fab-teaser,
.aacharya-global__fab-label {
  position: absolute;
  right: calc(100% + 0.45rem);
  top: 50%;
  transform: translateY(-50%) translateX(4px);
  padding: 0.22rem 0.5rem;
  border-radius: 8px;
  background: rgba(28, 12, 8, 0.94);
  color: #f5e6c8;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
}

.aacharya-global__fab-teaser::after,
.aacharya-global__fab-label::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 50%;
  width: 8px;
  height: 8px;
  background: rgba(28, 12, 8, 0.94);
  transform: translateY(-50%) rotate(45deg);
  border-radius: 1px;
}

.aacharya-global__fab-label {
  opacity: 0;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.aacharya-global__fab-teaser {
  opacity: 0;
  animation: aacharya-teaser-nudge 14s ease-in-out infinite;
}

.aacharya-global__fab:hover .aacharya-global__fab-teaser,
.aacharya-global__fab:focus-visible .aacharya-global__fab-teaser,
.aacharya-global.is-open .aacharya-global__fab-teaser {
  animation: none;
  opacity: 0;
}

.aacharya-global__fab:hover .aacharya-global__fab-label,
.aacharya-global__fab:focus-visible .aacharya-global__fab-label {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.aacharya-global__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + var(--aacharya-fab-gap));
  width: min(30rem, calc(100vw - 1.3rem));
  min-height: min(26rem, calc(100vh - 6rem));
  max-height: min(44rem, calc(100vh - 3.5rem));
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.45rem;
  background: linear-gradient(165deg, #fffef9 0%, #faf6ee 100%);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(139, 58, 0, 0.15);
  overflow: hidden;
}

.aacharya-global.is-panel-below .aacharya-global__panel {
  bottom: auto;
  top: calc(100% + var(--aacharya-fab-gap));
}

.aacharya-global.is-panel-align-left .aacharya-global__panel {
  right: auto;
  left: 0;
}

.aacharya-global__panel[hidden] {
  display: none !important;
}

.aacharya-global.is-open .aacharya-global__panel:not([hidden]) {
  animation: aacharya-panel-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.aacharya-global__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  background: linear-gradient(135deg, rgba(196, 92, 0, 0.14), rgba(28, 12, 8, 0.04));
  border: 1px solid rgba(201, 162, 39, 0.22);
  border-radius: 10px;
  flex-shrink: 0;
}

.aacharya-global__head-main {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.aacharya-global__avatar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  font-family: var(--display, "Cormorant Garamond", Georgia, serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: #5c2e00;
  background: linear-gradient(145deg, #fff6e0, #f0d48a);
  border: 1px solid rgba(201, 162, 39, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.aacharya-global__status {
  margin: 0.12rem 0 0;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.62rem;
  font-weight: 500;
  color: #6b5340;
}

.aacharya-global__status-dot {
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

.aacharya-global__eyebrow {
  margin: 0;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
}

.aacharya-global__title {
  margin: 0.1rem 0 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #5c2e00;
}

.aacharya-global__actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.aacharya-global__new {
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: transparent;
  color: #5c2e00;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 999px;
  padding: 0.22rem 0.5rem;
  cursor: pointer;
}

.aacharya-global__close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  padding: 0 0.25rem;
}

.aacharya-global__log {
  flex: 1 1 0;
  min-height: 16rem;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 0.65rem 0.55rem;
  scroll-padding-bottom: 0.75rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(139, 58, 0, 0.1);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

/* Override legacy .vedic-chat__log margins when used inside the global panel */
.aacharya-global__panel .vedic-chat__log.aacharya-global__log {
  margin: 0;
}

.aacharya-global__log .vedic-chat__msg {
  box-sizing: border-box;
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  margin: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.aacharya-global__log .vedic-chat__msg--user {
  align-self: flex-end;
  width: min(100%, 22rem);
  background: linear-gradient(145deg, rgba(139, 58, 0, 0.08), rgba(139, 58, 0, 0.14));
  border: 1px solid rgba(139, 58, 0, 0.16);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
}

.aacharya-global__log .vedic-chat__msg--assistant {
  align-self: flex-start;
  width: min(100%, 24rem);
  background: #fff;
  border: 1px solid rgba(201, 162, 39, 0.28);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.05),
    0 1px 0 rgba(255, 255, 255, 0.85) inset;
}

.aacharya-global__log .vedic-chat__msg--pending {
  opacity: 0.92;
  border-style: dashed;
  background: rgba(255, 255, 255, 0.85);
}

.aacharya-global__log .vedic-chat__role {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #7a5c3a;
  margin: 0 0 0.35rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.aacharya-global__log .vedic-chat__msg--user .vedic-chat__role {
  color: #8b3a00;
  border-bottom-color: rgba(139, 58, 0, 0.12);
}

.aacharya-global__log .vedic-chat__msg p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
  color: #2a221c;
}

.aacharya-global__log .vedic-chat__msg p + p {
  margin-top: 0.55rem;
}

.aacharya-global__log .vedic-chat__list {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}

.aacharya-global__log .vedic-chat__list li + li {
  margin-top: 0.35rem;
}

.aacharya-global__log .vedic-chat__list li {
  line-height: 1.5;
  padding-left: 0.15rem;
}

.aacharya-global__form.vedic-chat__form {
  display: block;
  flex-wrap: nowrap;
  gap: 0;
  align-items: stretch;
}

.aacharya-global__form {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}

.aacharya-global__composer {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  width: 100%;
  box-sizing: border-box;
  min-height: 3.1rem;
  padding: 0.5rem 0.55rem 0.5rem 0.85rem;
  background: #fff;
  border: 1px solid rgba(139, 58, 0, 0.16);
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(92, 46, 0, 0.06);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.aacharya-global__composer:focus-within {
  border-color: rgba(201, 162, 39, 0.55);
  box-shadow:
    0 0 0 2px rgba(201, 162, 39, 0.18),
    0 1px 4px rgba(92, 46, 0, 0.06);
}

.aacharya-global__composer textarea {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  min-height: 1.75rem;
  max-height: 6rem;
  margin: 0;
  padding: 0.38rem 0;
  resize: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.86rem;
  line-height: 1.45;
  color: #2a221c;
}

.aacharya-global__composer textarea::placeholder {
  color: #8a7a68;
  opacity: 0.9;
}

.aacharya-global__composer textarea:focus {
  outline: none;
}

.aacharya-global__send {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  margin: 0 0 0.05rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #fff8eb;
  background: linear-gradient(155deg, #e07818 0%, #a84808 52%, #7a3200 100%);
  box-shadow:
    0 2px 6px rgba(92, 46, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition:
    transform 0.15s ease,
    filter 0.15s ease,
    opacity 0.15s ease;
}

.aacharya-global__send svg {
  display: block;
  margin-left: 1px;
}

.aacharya-global__send:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: scale(1.04);
}

.aacharya-global__send:active:not(:disabled) {
  transform: scale(0.96);
}

.aacharya-global__send:focus-visible {
  outline: 2px solid rgba(201, 162, 39, 0.85);
  outline-offset: 2px;
}

.aacharya-global__send:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

/* Global panel: input tray only (no footer disclaimer tile) */
.aacharya-global__panel [data-vedic-disclaimer] {
  display: none !important;
}

/* Shared chat bubbles (global + legacy panchang hosts) */
.vedic-chat__log,
.pandit-chat__log {
  margin: 0.75rem 0;
  padding: 0.5rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.04);
}

.vedic-chat__msg,
.pandit-chat__msg {
  margin-bottom: 0.65rem;
  font-size: 0.92rem;
}

.vedic-chat__msg--assistant p,
.pandit-chat__msg--assistant p {
  color: var(--ink, #1a1a1a);
}

.vedic-chat__msg--pending p,
.pandit-chat__msg--pending p {
  font-style: italic;
  opacity: 0.85;
}

.vedic-chat__list,
.pandit-chat__list {
  margin: 0.25rem 0 0.35rem;
  padding-left: 1.15rem;
}

.vedic-chat__role,
.pandit-chat__role {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.65;
  margin-bottom: 0.15rem;
}

.vedic-chat__form,
.pandit-chat__form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.vedic-chat__form textarea,
.pandit-chat__form textarea {
  flex: 1 1 12rem;
  min-width: 0;
}

@media (prefers-reduced-motion: reduce) {
  .aacharya-global__fab,
  .aacharya-global__fab-ring,
  .aacharya-global__fab-dot,
  .aacharya-global__fab-teaser {
    animation: none;
  }

  .aacharya-global.is-open .aacharya-global__panel:not([hidden]) {
    animation: none;
  }
}

@media (max-width: 480px) {
  .aacharya-global {
    --aacharya-fab-size: 2.35rem;
  }

  .aacharya-global.is-open .aacharya-global__panel {
    position: fixed;
    right: 0;
    left: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    max-height: 92vh;
    padding: 0.45rem 0.45rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    border-radius: 14px 14px 0 0;
  }

  .aacharya-global.is-open .aacharya-global__log {
    min-height: 0;
    flex: 1 1 auto;
  }

  .aacharya-global.is-open .aacharya-global__log .vedic-chat__msg--user,
  .aacharya-global.is-open .aacharya-global__log .vedic-chat__msg--assistant {
    width: min(100%, 26rem);
  }

  .aacharya-global.is-open .aacharya-global__fab {
    display: none;
  }
}
