/* ==========================================================================
   UPALA BLOSSOM AI ASSISTANT — LEFT VERTICAL SIDEBAR & BOTTOM BAR ENGINE
   Unified Persona: Ananda (Backend /desk, Portal, Frontend /, Mainsite, Tools & LINE)
   Always Deepest Midnight Blue Theme (#04070C / #060B16)
   Default State: Collapsed Far-Left Vertical Rail (puja-frame-closed)
   Supports Overlap Mode vs Side-by-Side Push/Dock Mode + Drag Resize
   ========================================================================== */

body.puja-has-left-rail {
  padding-left: 38px !important;
  transition: padding-left 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

body.puja-has-left-rail #suppliesStickyBottomBar {
  left: 38px !important;
  transition: left 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

body.puja-has-bottom-rail {
  padding-bottom: 36px !important;
  transition: padding-bottom 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 768px) {
  body.puja-sidebar-docked {
    padding-left: var(--puja-active-sidebar-w, 400px) !important;
    transition: padding-left 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }
  body.puja-sidebar-docked #suppliesStickyBottomBar {
    left: var(--puja-active-sidebar-w, 400px) !important;
  }
}

#puja-voice-assistant-container {
  position: fixed;
  z-index: 9998;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang TC", "Noto Sans TC", sans-serif;
  pointer-events: none;
  inset: 0;
  --puja-sidebar-w: 400px;
  --puja-bottom-h: 360px;
}

/* ==========================================================================
   FAR-LEFT COLLAPSED RAIL (AND BOTTOM COLLAPSED BAR ON /DESK)
   Click anywhere on the rail to expand AI chat.
   Bottom button toggles between Left Sidebar and Bottom Bar (on /desk).
   ========================================================================== */
#puja-collapsed-rail {
  pointer-events: auto;
  position: fixed;
  background: linear-gradient(180deg, #03060B 0%, #060C18 55%, #04070C 100%);
  color: #E2E8F0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 2px 0 18px rgba(0, 0, 0, 0.65);
}

/* Left Sidebar Collapsed Rail (Default) */
#puja-voice-assistant-container.mode-sidebar-left #puja-collapsed-rail,
#puja-voice-assistant-container.mode-bubble #puja-collapsed-rail {
  top: 0;
  left: 0;
  bottom: 0;
  width: 38px;
  flex-direction: column;
  padding: 12px 0 10px 0;
  border-right: 1px solid rgba(56, 189, 248, 0.28);
}

/* Bottom Bar Collapsed Rail (Backend /desk only) */
#puja-voice-assistant-container.mode-bottom-bar #puja-collapsed-rail {
  left: 0;
  right: 0;
  bottom: 0;
  height: 36px;
  flex-direction: row;
  padding: 0 16px;
  border-top: 1px solid rgba(56, 189, 248, 0.28);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.65);
}

/* Hide collapsed rail when panel is expanded */
#puja-voice-assistant-container:not(.puja-frame-closed) #puja-collapsed-rail {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

#puja-rail-open-zone {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  color: #E0F2FE;
  transition: background-color 0.18s ease, color 0.18s ease;
}
#puja-voice-assistant-container.mode-sidebar-left #puja-rail-open-zone,
#puja-voice-assistant-container.mode-bubble #puja-rail-open-zone {
  flex-direction: column;
}
#puja-rail-open-zone:hover {
  background: rgba(56, 189, 248, 0.1);
  color: #38BDF8;
}

.puja-rail-vertical-label,
.puja-rail-title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #BAE6FD;
}
#puja-voice-assistant-container.mode-bottom-bar .puja-rail-vertical-label,
#puja-voice-assistant-container.mode-bottom-bar .puja-rail-title {
  writing-mode: horizontal-tb;
  letter-spacing: 0.04em;
}
.puja-rail-avatar {
  font-size: 15px;
  line-height: 1;
}
.puja-rail-wave-mini {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.puja-rail-wave-mini span {
  display: inline-block;
  width: 2.5px;
  height: 8px;
  border-radius: 2px;
  background: #38BDF8;
  opacity: 0.85;
}
.puja-rail-wave-mini span:nth-child(2) {
  height: 13px;
}

#puja-rail-mode-toggle-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  background: rgba(14, 165, 233, 0.12);
  color: #7DD3FC;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
#puja-rail-mode-toggle-btn:hover {
  background: rgba(56, 189, 248, 0.25);
  color: #FFFFFF;
  border-color: #38BDF8;
}

/* ==========================================================================
   MAIN AI PANEL — ALWAYS DEEPEST DARK BLUE (#04070C / #060B16)
   ========================================================================== */
#puja-chat-panel {
  pointer-events: auto;
  position: fixed;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, #04070C 0%, #060B16 55%, #04070D 100%) !important;
  color: #F1F5F9 !important;
  border: 1px solid rgba(56, 189, 248, 0.32) !important;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.85), 0 0 28px rgba(14, 165, 233, 0.16) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: opacity 0.22s ease, transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9998;
}

/* Collapsed State hides the main panel */
#puja-voice-assistant-container.puja-frame-closed #puja-chat-panel {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* Mode 1: Left Sidebar (Default everywhere, sole mode on Frontend) */
#puja-voice-assistant-container.mode-sidebar-left #puja-chat-panel,
#puja-voice-assistant-container.mode-bubble #puja-chat-panel {
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--puja-sidebar-w, 400px);
  max-width: 94vw;
  height: 100vh;
  border-radius: 0 18px 18px 0;
  border-left: none !important;
  transform: translateX(0);
}
#puja-voice-assistant-container.puja-frame-closed.mode-sidebar-left #puja-chat-panel,
#puja-voice-assistant-container.puja-frame-closed.mode-bubble #puja-chat-panel {
  transform: translateX(-100%) !important;
}

/* When Docked Side-by-Side (push mode), flush square right border */
#puja-voice-assistant-container.dock-push.mode-sidebar-left #puja-chat-panel {
  border-radius: 0 !important;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.65) !important;
}

/* Mode 2: Bottom Bar (Backend /desk toggleable) */
#puja-voice-assistant-container.mode-bottom-bar #puja-chat-panel {
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: var(--puja-bottom-h, 360px);
  max-height: 85vh;
  border-radius: 18px 18px 0 0;
  border-bottom: none !important;
  transform: translateY(0);
}
#puja-voice-assistant-container.puja-frame-closed.mode-bottom-bar #puja-chat-panel {
  transform: translateY(100%) !important;
}

/* Drag Resize Handle */
#puja-resize-handle {
  position: absolute;
  z-index: 25;
  opacity: 0;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}
#puja-chat-panel:hover #puja-resize-handle {
  opacity: 1;
}
#puja-resize-handle:hover {
  background: rgba(56, 189, 248, 0.35);
}
#puja-voice-assistant-container.mode-sidebar-left #puja-resize-handle,
#puja-voice-assistant-container.mode-bubble #puja-resize-handle {
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
}
#puja-voice-assistant-container.mode-bottom-bar #puja-resize-handle {
  top: 0;
  left: 0;
  width: 100%;
  height: 6px;
  cursor: ns-resize;
}

/* ==========================================================================
   HEADER, MESSAGES & DEEP DARK BLUE SURFACES
   ========================================================================== */
.puja-chat-header {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  background: linear-gradient(90deg, #020409 0%, #081020 55%, #040812 100%) !important;
  border-bottom: 1px solid rgba(56, 189, 248, 0.24) !important;
  color: #F8FAFC !important;
}

.puja-hdr-icon-btn {
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.75);
  color: #BAE6FD;
  border: 1px solid rgba(56, 189, 248, 0.28);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.puja-hdr-icon-btn:hover {
  background: rgba(14, 165, 233, 0.22);
  color: #FFFFFF;
  border-color: #38BDF8;
}
.puja-hdr-icon-btn.active-dock,
.puja-hdr-icon-btn.active {
  background: rgba(2, 132, 199, 0.35);
  color: #38BDF8;
  border-color: #38BDF8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

/* Messages Stream Area */
#puja-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #04070D !important;
}

.chat-msg {
  max-width: 92%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.58;
  word-break: break-word;
  position: relative;
}
.msg-assistant {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  background: #0A1222 !important;
  border: 1px solid #1E2E4A !important;
  color: #F1F5F9 !important;
}
.chat-msg-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid rgba(56, 189, 248, 0.25);
  background: rgba(4, 7, 13, 0.85);
  color: #94A3B8;
  font-size: 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.msg-assistant:hover .chat-msg-copy-btn {
  opacity: 1;
}
.chat-msg-copy-btn:hover {
  color: #38BDF8;
  border-color: #38BDF8;
}
#puja-chat-panel #puja-text-input {
  background: #02060D !important;
  color: #F8FAFC !important;
  border: 1px solid rgba(56, 189, 248, 0.28) !important;
  min-height: 36px;
  max-height: 96px;
  resize: none;
  line-height: 1.45;
  padding: 7px 12px;
  font-family: inherit;
}
.msg-user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: linear-gradient(135deg, #0369A1 0%, #1D4ED8 100%) !important;
  color: #F8FAFC !important;
  border: 1px solid rgba(125, 211, 252, 0.35) !important;
}

/* ==========================================================================
   PROMINENT SOUND WAVES HERO BUTTON (NO MIC ICON) & FOOTER
   ========================================================================== */
.puja-chat-footer {
  padding: 10px 12px 8px 12px;
  border-top: 1px solid rgba(56, 189, 248, 0.22);
  background: #03060C !important;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#puja-waves-btn {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #07142B 0%, #0C254E 50%, #0A346B 100%);
  border: 1.5px solid rgba(56, 189, 248, 0.48);
  color: #E0F2FE;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.22), inset 0 0 12px rgba(56, 189, 248, 0.12);
  transition: all 0.2s ease;
}
#puja-waves-btn:hover {
  background: linear-gradient(135deg, #0A1D3D 0%, #0F3166 50%, #0284C7 100%);
  border-color: #38BDF8;
  color: #FFFFFF;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.32);
}
#puja-waves-btn.is-listening,
#puja-waves-btn.is-recording {
  background: linear-gradient(135deg, #0369A1 0%, #0284C7 50%, #38BDF8 100%);
  border-color: #BAE6FD;
  color: #FFFFFF;
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.65);
}

.puja-waves-svg {
  width: 28px;
  height: 22px;
  flex-shrink: 0;
  color: #38BDF8;
}
.puja-waves-svg rect {
  fill: currentColor;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.18s ease;
}
#puja-waves-btn.is-listening .puja-waves-svg,
#puja-waves-btn.is-recording .puja-waves-svg {
  color: #FFFFFF;
  animation: pujaWavePulse 0.9s infinite ease-in-out alternate;
}
#puja-waves-btn.is-listening .puja-waves-svg .wave-b2,
#puja-waves-btn.is-recording .puja-waves-svg .wave-b2,
#puja-waves-btn.is-listening .puja-waves-svg .wave-b4,
#puja-waves-btn.is-recording .puja-waves-svg .wave-b4 {
  animation: pujaWavePulse 0.55s infinite ease-in-out alternate-reverse;
}

@keyframes pujaWavePulse {
  0% { transform: scaleY(0.82); }
  100% { transform: scaleY(1.18); }
}

/* Bottom Bar <-> Left Sidebar Switch Row inside Panel Footer (/desk only) */
#puja-panel-bottom-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
  border-top: 1px solid rgba(56, 189, 248, 0.14);
  font-size: 11px;
  color: #94A3B8;
}

#puja-panel-mode-toggle-btn {
  width: 100%;
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid rgba(56, 189, 248, 0.24);
  background: rgba(15, 23, 42, 0.7);
  color: #7DD3FC;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}
#puja-panel-mode-toggle-btn:hover {
  background: rgba(14, 165, 233, 0.2);
  color: #FFFFFF;
  border-color: #38BDF8;
}

/* ==========================================================================
   ROSE / LYNN WORKSPACE PARITY: SMART COLOR-CODED TOKENS & DATA TABLES
   ========================================================================== */
.tok-money {
  display: inline-block;
  padding: 0 5px;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgba(16, 185, 129, 0.18);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.tok-datetime {
  display: inline-block;
  padding: 0 5px;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 600;
  background: rgba(168, 85, 247, 0.18);
  color: #D8B4FE;
  border: 1px solid rgba(168, 85, 247, 0.32);
}

.tok-order {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 6px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  background: rgba(14, 165, 233, 0.2);
  color: #7DD3FC;
  border: 1px solid rgba(56, 189, 248, 0.42);
  cursor: pointer;
  transition: all 0.15s ease;
}
.tok-order:hover {
  background: rgba(14, 165, 233, 0.35);
  transform: translateY(-1px);
}

.tok-code {
  display: inline-block;
  padding: 0 5px;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(245, 158, 11, 0.18);
  color: #FCD34D;
  border: 1px solid rgba(245, 158, 11, 0.38);
}

.tok-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #38BDF8;
}

.tok-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.03em;
}
.tok-badge-paid {
  background: rgba(16, 185, 129, 0.2);
  color: #6EE7B7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.tok-badge-pending {
  background: rgba(245, 158, 11, 0.2);
  color: #FCD34D;
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.tok-badge-rbac {
  background: rgba(56, 189, 248, 0.16);
  color: #7DD3FC;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

/* Structured Data Cards inside Chat */
.puja-data-card {
  margin-top: 8px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, 0.25);
  background: #070D19;
}
.puja-data-card-header {
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #040811;
  border-bottom: 1px solid rgba(56, 189, 248, 0.2);
  color: #E0F2FE;
}
.puja-data-table-wrap {
  overflow-x: auto;
  max-height: 220px;
}
.puja-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
.puja-data-table th {
  text-align: left;
  padding: 5px 8px;
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  color: #BAE6FD;
}
.puja-data-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  white-space: nowrap;
}

/* File Staging Bar */
#puja-staging-bar {
  display: none;
  padding: 6px 12px;
  gap: 6px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(56, 189, 248, 0.2);
  background: #050A14;
}
#puja-staging-bar.has-files {
  display: flex;
}
.puja-staged-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #E0F2FE;
}

/* ==========================================================================
   REALTIME CO-PILOT HIGHLIGHT & FLOATING POINTER NOTE CALLOUT
   ========================================================================== */
.puja-copilot-glow {
  outline: 3px solid #38BDF8 !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.28), 0 0 24px rgba(14, 165, 233, 0.5) !important;
  transition: outline 0.25s ease, box-shadow 0.25s ease !important;
}

#puja-copilot-callout {
  position: fixed;
  z-index: 10000;
  max-width: 310px;
  padding: 10px 13px;
  border-radius: 14px;
  background: linear-gradient(135deg, #04070D 0%, #0A1324 100%);
  color: #F8FAFC;
  border: 1.5px solid #38BDF8;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.7), 0 0 18px rgba(56, 189, 248, 0.35);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: auto;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#puja-copilot-callout.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
}
