/* =========================================================
   Birdy — floating chatbot widget for Birdwing ITS
   Reuses the brand tokens from styles.css (with fallbacks).
   ========================================================= */

.birdy {
  position: fixed;
  right: 24px; bottom: 24px;
  z-index: 1000;
  font-family: var(--font-body, "Inter", system-ui, sans-serif);
}
.birdy *, .birdy *::before, .birdy *::after { box-sizing: border-box; }

/* ---------- launcher ---------- */
.birdy-launcher {
  position: relative;
  width: 60px; height: 60px;
  border: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--grad, linear-gradient(120deg, #3399ff, #ff0066));
  color: #fff; cursor: pointer;
  box-shadow: 0 14px 34px rgba(51, 153, 255, .42);
  transition: transform .2s ease, box-shadow .2s ease;
}
.birdy-launcher:hover { transform: translateY(-2px) scale(1.03); }
.birdy-launcher:focus-visible { outline: 3px solid rgba(255, 255, 255, .8); outline-offset: 2px; }
.birdy-launcher svg { width: 26px; height: 26px; }
.birdy-launcher .ic-close { display: none; }
.birdy.is-open .birdy-launcher .ic-chat { display: none; }
.birdy.is-open .birdy-launcher .ic-close { display: block; }

.birdy-badge {
  position: absolute; top: -1px; right: -1px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--pink, #ff0066);
  border: 2px solid #fff;
}
.birdy.is-open .birdy-badge, .birdy.seen .birdy-badge { display: none; }

/* ---------- panel ---------- */
.birdy-panel {
  position: absolute; right: 0; bottom: 76px;
  width: 374px; max-width: calc(100vw - 32px);
  height: min(560px, calc(100vh - 132px));
  display: flex; flex-direction: column;
  background: #fff;
  border-radius: 18px; overflow: hidden;
  box-shadow: 0 30px 70px rgba(13, 27, 42, .28);
  opacity: 0; transform: translateY(12px) scale(.98);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
.birdy.is-open .birdy-panel { opacity: 1; transform: none; pointer-events: auto; }

.birdy-header {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 15px 14px;
  background: var(--grad, linear-gradient(120deg, #3399ff, #ff0066));
  color: #fff;
}
.birdy-avatar {
  flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  display: grid; place-items: center;
  font-size: 20px;
}
.birdy-id { flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.birdy-id strong {
  display: block;
  font-family: var(--font-head, inherit);
  font-size: .98rem; font-weight: 600;
}
.birdy-id span { display: flex; align-items: center; gap: 6px; font-size: .74rem; opacity: .9; }
.birdy-id span::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #74f7a8;
}
.birdy-x {
  flex: 0 0 auto;
  border: none; background: none; color: #fff; cursor: pointer;
  padding: 6px; border-radius: 8px; line-height: 0;
}
.birdy-x:hover { background: rgba(255, 255, 255, .16); }
.birdy-x svg { width: 18px; height: 18px; }

/* ---------- message log ---------- */
.birdy-log {
  flex: 1 1 auto; overflow-y: auto;
  padding: 18px 16px;
  display: flex; flex-direction: column; gap: 12px;
  background: #f6f9fc;
}
.birdy-msg { max-width: 86%; }
.birdy-msg .b {
  padding: 10px 14px;
  border-radius: 15px;
  font-size: .9rem; line-height: 1.55;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.birdy-msg.bot { align-self: flex-start; }
.birdy-msg.bot .b {
  background: #fff; color: var(--ink, #0d1b2a);
  border: 1px solid var(--line, #e6ecf3);
  border-bottom-left-radius: 5px;
}
.birdy-msg.me { align-self: flex-end; }
.birdy-msg.me .b {
  background: var(--grad, linear-gradient(120deg, #3399ff, #ff0066));
  color: #fff;
  border-bottom-right-radius: 5px;
}
.birdy-msg .b a { color: inherit; text-decoration: underline; }

.birdy-typing {
  align-self: flex-start;
  display: flex; gap: 4px;
  padding: 12px 14px;
  background: #fff; border: 1px solid var(--line, #e6ecf3);
  border-radius: 15px; border-bottom-left-radius: 5px;
}
.birdy-typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #b9c6d4;
  animation: birdyBlink 1.2s infinite ease-in-out;
}
.birdy-typing i:nth-child(2) { animation-delay: .15s; }
.birdy-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes birdyBlink {
  0%, 80%, 100% { opacity: .3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- quick replies ---------- */
.birdy-quick {
  flex: 0 0 auto;
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 0 16px 10px;
  background: #f6f9fc;
}
.birdy-quick:empty { display: none; }
.birdy-quick button {
  font-family: var(--font-head, inherit);
  font-size: .78rem;
  color: var(--blue-dark, #1f7fe0);
  background: rgba(51, 153, 255, .1);
  border: 1px solid rgba(51, 153, 255, .22);
  padding: 7px 12px; border-radius: 999px;
  cursor: pointer;
  transition: background .18s ease;
}
.birdy-quick button:hover { background: rgba(51, 153, 255, .18); }

/* ---------- input ---------- */
.birdy-input {
  flex: 0 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line, #e6ecf3);
  background: #fff;
}
.birdy-input textarea {
  flex: 1 1 auto;
  resize: none;
  border: 1px solid var(--line, #e6ecf3);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit; font-size: .9rem; line-height: 1.4;
  color: var(--ink, #0d1b2a);
  max-height: 120px;
}
.birdy-input textarea:focus {
  outline: none;
  border-color: var(--blue, #3399ff);
  box-shadow: 0 0 0 3px rgba(51, 153, 255, .15);
}
.birdy-input textarea:disabled { background: #f4f7fa; }
.birdy-send {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border: none; border-radius: 12px;
  background: var(--grad, linear-gradient(120deg, #3399ff, #ff0066));
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
}
.birdy-send:disabled { opacity: .5; cursor: default; }
.birdy-send svg { width: 18px; height: 18px; }

.birdy-foot {
  flex: 0 0 auto;
  text-align: center;
  font-size: .68rem; color: #9aa8b6;
  padding: 0 12px 10px; background: #fff;
}

/* ---------- responsive ---------- */
@media (max-width: 480px) {
  .birdy { right: 16px; bottom: 16px; }
  .birdy-panel {
    position: fixed;
    right: 12px; left: 12px; bottom: 86px; top: 14px;
    width: auto; height: auto; max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .birdy-launcher, .birdy-panel { transition: none; }
  .birdy-typing i { animation: none; }
}
