/* PH-IDEAS Assistant — chat widget styles */
:root {
  --pha-blue: #034584;
  --pha-blue-dk: #023461;
  --pha-orange: #F7941E;
  --pha-orange-dk: #E67E00;
  --pha-ink: #17323A;
  --pha-muted: #5E7379;
  --pha-bubble: #EAF0F7;
  --pha-line: #E2E8F0;
  --pha-white: #ffffff;
  --pha-shadow: 0 12px 34px rgba(3, 69, 132, 0.24);
}

#pha-widget, #pha-widget * { box-sizing: border-box; }
#pha-widget {
  position: fixed; right: 20px; bottom: 20px; z-index: 2147483000;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

#pha-bubble {
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--pha-orange); color: #fff;
  box-shadow: 0 10px 28px rgba(247,148,30,.40), 0 0 0 4px rgba(247,148,30,.12);
  display: flex; align-items: center; justify-content: center; transition: transform .2s ease;
}
#pha-bubble:hover { transform: scale(1.08); background: var(--pha-orange-dk); }
#pha-bubble svg { width: 28px; height: 28px; }

#pha-panel {
  position: absolute; right: 0; bottom: 0; width: 370px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100vh - 40px); background: var(--pha-white); border-radius: 16px;
  box-shadow: var(--pha-shadow); display: none; flex-direction: column; overflow: hidden;
}
#pha-widget.pha-open #pha-panel { display: flex; }
#pha-widget.pha-open #pha-bubble { display: none; }

#pha-head { background: var(--pha-blue); color: #fff; padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
#pha-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--pha-orange); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
#pha-avatar svg { width: 18px; height: 18px; }
#pha-title { font-weight: 700; font-size: 15px; line-height: 1.1; }
#pha-sub { font-size: 11px; color: #CFE0F0; }
#pha-head .pha-spacer { flex: 1; }
#pha-head button { background: transparent; border: none; color: #fff; cursor: pointer; font-size: 18px; width: 30px; height: 30px; border-radius: 6px; line-height: 1; }
#pha-head button:hover { background: rgba(255,255,255,.15); }

#pha-body { flex: 1; overflow-y: auto; padding: 14px; background: #F7FAFC; }
.pha-msg { margin: 8px 0; display: flex; }
.pha-msg.assistant { justify-content: flex-start; }
.pha-msg.user { justify-content: flex-end; }
.pha-msg .pha-b { max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.pha-msg.assistant .pha-b { background: var(--pha-bubble); color: var(--pha-ink); border-bottom-left-radius: 4px; }
.pha-msg.user .pha-b { background: var(--pha-blue); color: #fff; border-bottom-right-radius: 4px; }
.pha-b a { color: inherit; text-decoration: underline; }
.pha-msg.assistant .pha-b a { color: var(--pha-blue); }

.pha-note { background: #FFF7ED; border: 1px solid #FED7AA; color: #7C4A12; font-size: 12px; border-radius: 10px; padding: 10px 12px; margin: 4px 0 8px; }
.pha-note button { margin-top: 6px; background: var(--pha-orange); color: #fff; border: none; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.pha-sources { margin: 2px 0 8px; font-size: 12px; color: var(--pha-muted); }
.pha-sources a { color: var(--pha-blue); display: block; margin-top: 2px; }

.pha-card { background: #fff; border: 1px solid var(--pha-line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.pha-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pha-card-name { font-weight: 700; color: var(--pha-blue); font-size: 14px; }
.pha-details-toggle { flex: 0 0 auto; background: transparent; border: none; color: var(--pha-orange-dk); font-size: 12px; font-weight: 600; cursor: pointer; padding: 0; white-space: nowrap; }
.pha-card-dist { color: var(--pha-muted); font-size: 12px; margin: 2px 0 6px; }
.pha-card a.pha-line-link { display: block; font-size: 13px; margin: 3px 0; color: var(--pha-blue); text-decoration: none; }
.pha-card a.pha-line-link:hover { text-decoration: underline; }
.pha-card-details { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--pha-line); font-size: 13px; color: var(--pha-ink); }
.pha-card-details > div { margin: 3px 0; }
.pha-card-details a { color: var(--pha-orange-dk); }

/* Footer / Input Container */
#pha-foot { border-top: 1px solid var(--pha-line); background: #fff; padding: 10px; }

/* Combined Input Box (Floating Controls inside) */
#pha-input-box {
  position: relative;
  border: 1px solid var(--pha-line);
  border-radius: 16px;
  background: #fff;
  transition: border-color 0.2s ease;
  display: flex;
  flex-direction: column;
}
#pha-input-box:focus-within { border-color: var(--pha-blue); }

#pha-input {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  line-height: 1.35;
  min-height: 42px;
  max-height: 84px;
  overflow-y: auto;
  font-family: inherit;
  padding: 10px 84px 10px 14px; /* Right padding preserves room for floating action buttons */
  background: transparent;
}

/* Action Controls Container (Bottom Right of Input Box) */
#pha-actions {
  position: absolute;
  right: 8px;
  bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

#pha-send {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--pha-orange); color: #fff; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s ease;
}
#pha-send:hover { background: var(--pha-orange-dk); }
#pha-send:disabled { opacity: .5; cursor: default; }
#pha-send svg { width: 16px; height: 16px; }

#pha-mic-btn {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; border: none;
  background: transparent; color: var(--pha-muted); cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: all 0.2s ease;
}
#pha-mic-btn:hover { background: #f0f6fc; color: var(--pha-blue); }
#pha-mic-btn svg { width: 17px; height: 17px; }

#pha-voice-controls { display: flex; align-items: center; gap: 4px; }

#pha-confirm-btn, #pha-cancel-btn {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: #fff; transition: transform 0.15s ease;
}
#pha-confirm-btn { background: #16a34a; }
#pha-cancel-btn { background: #dc2626; }
#pha-confirm-btn:hover, #pha-cancel-btn:hover { transform: scale(1.08); }
#pha-confirm-btn svg, #pha-cancel-btn svg { width: 15px; height: 15px; }

/* Status Bar beneath input (Location Button / Listening Text on Left, Char Count on Right) */
#pha-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  min-height: 24px;
}

#pha-status-left {
  display: flex;
  align-items: center;
}

/* Inline Location Button */
#pha-locbtn {
  background: transparent; border: none; color: var(--pha-blue);
  font-size: 12px; font-weight: 600; cursor: pointer; padding: 2px 4px;
  display: flex; align-items: center; gap: 4px; border-radius: 4px;
}
#pha-locbtn:hover { background: #f0f6fc; }
#pha-locbtn svg { width: 14px; height: 14px; }

/* Inline Listening Indicator */
#pha-listening-indicator {
  font-size: 12px;
  font-weight: 600;
  color: #dc2626;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 2px;
}

.pha-pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #dc2626;
  border-radius: 50%;
  animation: pha-dot-pulse 1.2s infinite ease-in-out;
}

@keyframes pha-dot-pulse {
  0% { transform: scale(0.8); opacity: 0.5; box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7); }
  70% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
  100% { transform: scale(0.8); opacity: 0.5; box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* Character Counter */
#pha-charcount {
  font-size: 11px;
  color: var(--pha-muted);
  text-align: right;
  transition: color 0.2s ease;
  margin-left: auto;
}
#pha-charcount.pha-char-limit { color: #dc2626; font-weight: 600; }

#pha-fineprint { font-size: 10.5px; color: var(--pha-muted); text-align: center; line-height: 1.3; margin-top: 6px; }

.pha-typing { display: inline-block; }
.pha-typing span { display: inline-block; width: 6px; height: 6px; margin: 0 1px; background: var(--pha-muted); border-radius: 50%; animation: pha-blink 1.2s infinite both; }
.pha-typing span:nth-child(2) { animation-delay: .2s; } .pha-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes pha-blink { 0%,80%,100% { opacity: .2; } 40% { opacity: 1; } }

@media (max-width: 480px) {
  #pha-widget { right: 12px; bottom: 12px; }
  #pha-panel { width: calc(100vw - 24px); height: calc(100vh - 24px); }
}


/* ===== Inactivity toast ===== */
#pha-toast{
  position:absolute; bottom:88px; right:0;
  width:300px; max-width:calc(100vw - 40px);
  display:flex; align-items:flex-start; gap:11px;
  background:#ffffff; color:#1f2937;
  border:1px solid rgba(3,69,132,.10); border-left:4px solid var(--pha-blue,#034584);
  border-radius:14px; padding:13px 12px 13px 15px;
  box-shadow:0 14px 40px rgba(3,69,132,.20), 0 3px 8px rgba(15,23,42,.06);
  font:500 13.5px/1.45 system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  opacity:0; transform:translateY(12px) scale(.96);
  transition:opacity .3s cubic-bezier(.16,1,.3,1), transform .3s cubic-bezier(.16,1,.3,1);
  pointer-events:none; z-index:2147483001;
}
#pha-toast.show{ opacity:1; transform:translateY(0) scale(1); pointer-events:auto; }

/* icon puck */
#pha-toast .pha-toast-ic{
  flex:0 0 auto; width:30px; height:30px; margin-top:1px;
  display:flex; align-items:center; justify-content:center;
  border-radius:9px; color:var(--pha-blue,#034584);
  background:rgba(3,69,132,.10);
}
#pha-toast .pha-toast-msg{ flex:1 1 auto; padding:3px 0; color:#111827; }

/* close button */
#pha-toast .pha-toast-x{
  flex:0 0 auto; width:24px; height:24px; margin:-3px -3px 0 0; padding:0;
  border:0; background:transparent; color:#9aa3af; cursor:pointer;
  font-size:19px; line-height:1; border-radius:7px;
  display:flex; align-items:center; justify-content:center;
  transition:background .15s ease, color .15s ease;
}
#pha-toast .pha-toast-x:hover{ background:rgba(15,23,42,.07); color:#374151; }
#pha-toast .pha-toast-x:active{ transform:scale(.92); }

/* warning variant = orange accent */
#pha-toast.pha-toast-warn{ border-left-color:var(--pha-orange,#F7941E); }
#pha-toast.pha-toast-warn .pha-toast-ic{ color:var(--pha-orange,#F7941E); background:rgba(247,148,30,.14); }

@media (max-width:480px){
  #pha-toast{ right:0; bottom:82px; width:calc(100vw - 32px); }
}