/* iDC Performance Coach — portable styles for the floating chat panel.
   Copy this file + js/coach.js + img/coach-logo.svg into any iDC Back Office
   Solutions app to drop the Coach in.

   iDC BRAND PALETTE — canonical across every Back Office Solutions product:
     --idc-navy: #12284B   (primary "company blue")
     --idc-teal: #1ACAD4   (accent)
   All surfaces derive from these two via rgba/opacity so we never drift. */

:root {
  --idc-navy: #12284B;
  --idc-teal: #1ACAD4;
  --idc-navy-ink: #12284B;        /* text on light bg */
  --idc-muted: #64748b;           /* neutral gray for sub-text */
  --idc-border: #e2e8f0;
  --idc-surface: #ffffff;
  --idc-surface-soft: #f8fafc;
}

#coachFab {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  width: 64px; height: 64px; border-radius: 50%;
  border: 0; cursor: pointer; background: #fff;
  box-shadow: 0 6px 24px rgba(18, 40, 75, 0.22);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, box-shadow .15s ease;
  color: var(--idc-teal); padding: 12px;
}
#coachFab img { width: 40px; height: 40px; display: block; }
#coachFab:hover { transform: scale(1.08); box-shadow: 0 10px 32px rgba(18, 40, 75, 0.3); }
#coachFab:active { transform: scale(0.96); }
#coachFab::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid rgba(26, 202, 212, 0.4); opacity: 0;
  animation: coachPulse 3.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes coachPulse {
  0%, 100% { transform: scale(1); opacity: 0; }
  30% { opacity: 0.8; }
  70% { transform: scale(1.18); opacity: 0; }
}
#coachFab.active::after { animation: none; }
#coachFab.opening #coachFabIcon { animation: coachBounce 0.5s ease; }
@keyframes coachBounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

#coachDrawer {
  position: fixed; bottom: 96px; right: 24px; z-index: 9998;
  width: 380px; max-width: calc(100vw - 48px);
  height: 560px; max-height: calc(100vh - 120px);
  background: var(--idc-surface); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(18, 40, 75, 0.25);
  display: none; flex-direction: column; overflow: hidden;
  border: 1px solid rgba(18, 40, 75, 0.06);
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
}
/* Header uses the canonical company blue (iDC navy) as a solid fill with a
   subtle teal accent glow at the top — cleaner and on-brand vs. an ad-hoc
   gradient to an unofficial mid-blue. */
.coach-header {
  background: var(--idc-navy);
  background-image:
    radial-gradient(circle at top right, rgba(26, 202, 212, 0.18), transparent 55%),
    linear-gradient(180deg, var(--idc-navy), var(--idc-navy));
  color: #fff; padding: 14px 18px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(26, 202, 212, 0.22);
}
.coach-header-badge {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(26, 202, 212, 0.18);
  display: flex; align-items: center; justify-content: center;
  color: var(--idc-teal); padding: 4px;
}
.coach-header-badge img { width: 22px; height: 22px; }
.coach-header-title { font-size: 14px; font-weight: 600; line-height: 1.1; }
.coach-header-sub { font-size: 11px; color: rgba(255, 255, 255, 0.62); margin-top: 2px; }
.coach-btn-ghost {
  background: none; border: 0; color: rgba(255, 255, 255, 0.62); cursor: pointer;
  font-size: 14px; padding: 4px 8px; border-radius: 4px;
  font-family: inherit;
}
.coach-btn-ghost:hover { color: #fff; }
.coach-btn-close {
  background: none; border: 0; color: #fff; cursor: pointer;
  font-size: 20px; line-height: 1; padding: 2px 6px;
  font-family: inherit;
}

#coachMessages {
  flex: 1; overflow-y: auto; padding: 14px 16px;
  background: var(--idc-surface-soft); display: flex; flex-direction: column; gap: 10px;
}
#coachSuggestions {
  padding: 6px 12px 0;
  display: flex; flex-wrap: wrap; gap: 6px;
  background: var(--idc-surface-soft); border-top: 1px solid var(--idc-border);
}
#coachForm {
  display: flex; gap: 8px; padding: 12px;
  background: var(--idc-surface); border-top: 1px solid var(--idc-border);
}
#coachInput {
  flex: 1; padding: 10px 14px;
  border: 2px solid var(--idc-border); border-radius: 10px;
  font-family: inherit; font-size: 13px; color: var(--idc-navy-ink); outline: none;
  background: #fff;
}
#coachInput:focus { border-color: var(--idc-teal); }
#coachSend {
  background: var(--idc-navy); color: #fff; border: 0;
  padding: 0 18px; border-radius: 10px;
  font-weight: 600; cursor: pointer; font-size: 13px;
  font-family: inherit;
  transition: background .15s ease;
}
#coachSend:hover { background: #0e1d3a; }
#coachSend:disabled { opacity: 0.5; cursor: not-allowed; }

.coach-welcome { text-align: center; padding: 30px 10px; color: var(--idc-muted); font-size: 13px; }
.coach-welcome-emoji { font-size: 40px; margin-bottom: 10px; }
.coach-welcome-title { font-weight: 600; color: var(--idc-navy-ink); margin-bottom: 4px; }
.coach-welcome-sub { color: var(--idc-muted); }

.coach-bubble {
  max-width: 86%; padding: 9px 13px; border-radius: 14px;
  font-size: 13px; line-height: 1.5;
  white-space: pre-wrap; word-wrap: break-word;
}
/* User messages use the company blue — iDC navy — so the Coach speaks to you
   in YOUR brand voice. Teal is reserved for accents (focus, icon, pulse). */
.coach-bubble-user {
  align-self: flex-end; background: var(--idc-navy); color: #fff;
  border-bottom-right-radius: 4px;
}
.coach-bubble-coach {
  align-self: flex-start; background: #fff; color: var(--idc-navy-ink);
  border: 1px solid var(--idc-border); border-bottom-left-radius: 4px;
}
.coach-bubble-coach strong { color: var(--idc-navy-ink); }
.coach-bubble-coach a { color: var(--idc-navy); border-bottom: 1px dotted var(--idc-teal); }

.coach-typing { display: inline-flex; gap: 3px; padding: 4px 2px; }
.coach-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--idc-teal);
  opacity: 0.4; animation: coachTyping 1.2s infinite;
}
.coach-typing span:nth-child(2) { animation-delay: 0.15s; }
.coach-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes coachTyping {
  0%, 60%, 100% { opacity: 0.4; }
  30% { opacity: 1; }
}

.coach-result {
  background: #fff; border: 1px solid var(--idc-border); border-left: 3px solid var(--idc-navy);
  border-radius: 8px; padding: 10px 12px; font-size: 12px; color: #334155;
}
.coach-result-head {
  font-size: 11px; color: var(--idc-navy); text-transform: uppercase;
  letter-spacing: 0.4px; margin-bottom: 6px; font-weight: 700;
}
.coach-result-row { padding: 6px 0; border-bottom: 1px solid #f1f5f9; color: var(--idc-navy-ink); }
.coach-result-row:last-child { border-bottom: 0; }
.coach-sub { font-size: 11px; color: var(--idc-muted); }
.coach-tile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.coach-tile { background: var(--idc-surface-soft); border-radius: 6px; padding: 8px 4px; }
.coach-tile-n { font-size: 18px; font-weight: 700; color: var(--idc-navy-ink); }
.coach-tile-l { font-size: 10px; color: var(--idc-muted); text-transform: uppercase; letter-spacing: 0.4px; }

.coach-suggestion {
  background: #fff; border: 1px solid var(--idc-border); border-radius: 14px;
  padding: 6px 12px; font-size: 12px; color: var(--idc-navy);
  cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: all .12s ease;
}
.coach-suggestion:hover {
  background: var(--idc-navy); color: #fff; border-color: var(--idc-navy);
}

/* Header icon buttons (e.g. the kebab "more options" trigger) — render the
   inline SVG glyph cleanly without inheriting the text-button padding. */
.coach-btn-icon {
  background: none; border: 0; cursor: pointer;
  color: rgba(255, 255, 255, 0.72);
  padding: 4px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: inherit;
  transition: color .12s ease, background .12s ease;
}
.coach-btn-icon:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.coach-btn-icon[aria-expanded="true"] { color: #fff; background: rgba(255, 255, 255, 0.12); }

/* "More options" popover — positioned absolutely under the header so it
   overlays the message list without disturbing flex layout. */
.coach-menu {
  position: absolute; top: 56px; right: 12px; z-index: 20;
  background: #fff; border: 1px solid var(--idc-border);
  border-radius: 10px; padding: 4px;
  box-shadow: 0 10px 28px rgba(18, 40, 75, 0.20);
  min-width: 200px;
  font-family: inherit;
}
.coach-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; background: none; border: 0;
  padding: 9px 10px; border-radius: 7px;
  font-family: inherit; font-size: 13px;
  color: var(--idc-navy-ink); text-align: left;
  cursor: pointer;
  transition: background .12s ease;
}
.coach-menu-item:hover { background: var(--idc-surface-soft); }
.coach-menu-item:focus { outline: none; background: var(--idc-surface-soft); }
.coach-menu-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; color: var(--idc-navy); flex-shrink: 0;
}

/* Expanded drawer state — toggled from the "Expand window" menu item.
   Grows the panel to roughly two-thirds of the viewport while keeping the
   bottom-right anchor and responsive max-width fallback for small screens. */
#coachDrawer.coach-expanded {
  width: 720px;
  max-width: calc(100vw - 48px);
  height: calc(100vh - 120px);
  max-height: calc(100vh - 120px);
}
