/* =========================================================
   AngioBot Widget — pneumaticiangioletti.it
   ========================================================= */

:root {
  --ab-primary:    #E63E12;   /* Angioletti brand red */
  --ab-primary-dk: #bf3310;
  --ab-bg:         #ffffff;
  --ab-surface:    #f7f7f7;
  --ab-border:     #e8e8e8;
  --ab-text:       #1a1a1a;
  --ab-text-muted: #888;
  --ab-bot-bg:     #f0f0f0;
  --ab-user-bg:    #E63E12;
  --ab-user-text:  #ffffff;
  --ab-shadow:     0 8px 32px rgba(0,0,0,.18);
  --ab-radius:     16px;
  --ab-radius-sm:  10px;
  --ab-font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ab-z:          999999;
}

/* ── Widget container ── */
#angiobot-widget {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: var(--ab-z);
  font-family: var(--ab-font);
  box-sizing: border-box;
}

#angiobot-widget *,
#angiobot-widget *::before,
#angiobot-widget *::after {
  box-sizing: border-box;
}

/* ── Toggle button ── */
#angiobot-toggle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--ab-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(230,62,18,.45);
  transition: transform .2s ease, box-shadow .2s ease, background .15s;
  outline: none;
  padding: 0;
  margin-left: 0;
}

#angiobot-toggle:hover {
  background: var(--ab-primary-dk);
  transform: scale(1.07);
  box-shadow: 0 6px 22px rgba(230,62,18,.55);
}

#angiobot-toggle:active {
  transform: scale(.96);
}

#angiobot-toggle svg {
  width: 24px;
  height: 24px;
  color: #fff;
  flex-shrink: 0;
}

/* ── Chat panel ── */
#angiobot-panel {
  position: absolute;
  bottom: 72px;
  left: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--ab-bg);
  border-radius: var(--ab-radius);
  box-shadow: var(--ab-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform-origin: bottom left;
  transform: scale(.85) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s cubic-bezier(.34,1.3,.64,1), opacity .2s ease;
  border: 1px solid var(--ab-border);
}

#angiobot-panel.angiobot-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ── */
#angiobot-header {
  background: var(--ab-primary);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#angiobot-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

#angiobot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.4);
}

#angiobot-name {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

#angiobot-status {
  color: rgba(255,255,255,.85);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.angiobot-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: angiobot-pulse 2s ease infinite;
}

@keyframes angiobot-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

/* ── Messages area ── */
#angiobot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 370px;
  scroll-behavior: smooth;
}

#angiobot-messages::-webkit-scrollbar        { width: 4px; }
#angiobot-messages::-webkit-scrollbar-track  { background: transparent; }
#angiobot-messages::-webkit-scrollbar-thumb  { background: var(--ab-border); border-radius: 4px; }

/* ── Message rows ── */
.angiobot-msg {
  display: flex;
  animation: angiobot-fadein .22s ease;
}

@keyframes angiobot-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.angiobot-msg--bot  { justify-content: flex-start; }
.angiobot-msg--user { justify-content: flex-end; }

/* ── Bubbles ── */
.angiobot-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
}

.angiobot-msg--bot  .angiobot-bubble {
  background: var(--ab-bot-bg);
  color: var(--ab-text);
  border-bottom-left-radius: 4px;
}

.angiobot-msg--user .angiobot-bubble {
  background: var(--ab-user-bg);
  color: var(--ab-user-text);
  border-bottom-right-radius: 4px;
}

/* Markdown bold inside bubbles */
.angiobot-bubble strong { font-weight: 700; }

/* ── Typing indicator ── */
.angiobot-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--ab-bot-bg);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.angiobot-typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ab-text-muted);
  animation: angiobot-bounce .9s ease infinite;
}

.angiobot-typing span:nth-child(2) { animation-delay: .15s; }
.angiobot-typing span:nth-child(3) { animation-delay: .30s; }

@keyframes angiobot-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* ── Error message ── */
.angiobot-error .angiobot-bubble {
  background: #fff3f0;
  color: #c0392b;
  border: 1px solid #f5c6c0;
}

/* ── Input area ── */
#angiobot-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--ab-border);
  background: var(--ab-bg);
}

#angiobot-input {
  flex: 1;
  border: 1px solid var(--ab-border);
  border-radius: var(--ab-radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--ab-font);
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color .15s;
  color: var(--ab-text);
  background: var(--ab-surface);
}

#angiobot-input::placeholder { color: var(--ab-text-muted); }

#angiobot-input:focus {
  border-color: var(--ab-primary);
  background: #fff;
}

#angiobot-send {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--ab-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .15s;
  outline: none;
  padding: 0;
}

#angiobot-send:hover:not(:disabled) {
  background: var(--ab-primary-dk);
  transform: scale(1.07);
}

#angiobot-send:disabled {
  background: #ccc;
  cursor: not-allowed;
}

#angiobot-send svg {
  width: 16px;
  height: 16px;
  color: #fff;
  margin-left: 2px; /* optical centering for send arrow */
}

/* ── Mobile adjustments ── */
@media (max-width: 480px) {
  #angiobot-widget {
    bottom: 16px;
    left: 16px;
  }

  #angiobot-panel {
    width: calc(100vw - 32px);
    left: 0;
    bottom: 68px;
  }

  #angiobot-messages {
    max-height: 300px;
  }
}
