/* ═══════════════════════════════════════════════════════════════════════════
   js/bob-builder.css — A-645 — "Ask Bob the Builder" AI assessor
   Scope: everything namespaced .bob-* (panel mounts in #bob-builder-root,
   outside #app) plus the .bubble-bob skin inside the Comms Dock stack.
   Design language: Archivo/ink like the sales app; Bob's accent is builder
   amber (#F59E0B) so the hard-hat bubble reads instantly in the stack.
   Loads AFTER comms-dock.css so the .bubble-bob skin wins.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Dock bubble ──────────────────────────────────────────────────────────── */
.comms-dock .bubble-bob {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: #271a03;
}
.comms-dock .bubble-bob:hover {
  background: linear-gradient(135deg, #FBBF24 0%, #F59E0B 100%);
}
.comms-dock .bubble-bob .ico { stroke: #271a03; }
.comms-dock .bubble-bob.has-reply { animation: bob-pulse 1.8s infinite; }
.comms-dock .bubble-badge.amber { background: #B45309; }
@keyframes bob-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.55); }
  50%      { box-shadow: 0 0 0 9px rgba(245, 158, 11, 0); }
}

/* ── Panel shell ──────────────────────────────────────────────────────────── */
#bob-builder-root .bob-panel {
  position: fixed;
  right: 84px;                    /* clear of the comms dock stack */
  bottom: 16px;
  width: min(420px, calc(100vw - 108px));
  height: min(660px, calc(100vh - 80px));
  display: flex;
  flex-direction: column;
  background: #FAFAF9;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(10, 10, 10, 0.28), 0 4px 16px rgba(10, 10, 10, 0.14);
  z-index: 61;                    /* matches the Team Chat panel layer */
  font-family: 'Archivo', -apple-system, sans-serif;
  animation: bob-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes bob-in {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (max-width: 820px) {
  #bob-builder-root .bob-panel {
    inset: 0;
    right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    padding-top: env(safe-area-inset-top);
    animation: bob-in-m 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes bob-in-m {
    from { opacity: 0.6; transform: translateY(6vh); }
    to   { opacity: 1; transform: translateY(0); }
  }
  html.bob-open, html.bob-open body { overflow: hidden; }
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.bob-h {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: linear-gradient(120deg, #0A0A0A 55%, #241703 100%);
  color: #fff;
  flex-shrink: 0;
}
.bob-h-ava {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F59E0B, #D97706);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
}
.bob-h-ava .ico { width: 22px; height: 22px; stroke: #271a03; }
.bob-h-t { flex: 1; min-width: 0; }
.bob-h-name { font-weight: 800; font-size: 15px; letter-spacing: -0.02em; }
.bob-h-sub { font-size: 11.5px; color: #D6D3D1; margin-top: 1px; }
.bob-h-actions { display: flex; gap: 6px; }
.bob-h-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.09);
  color: #E7E5E4;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.bob-h-btn:hover { background: rgba(255, 255, 255, 0.18); }
.bob-h-btn:active { transform: scale(0.93); }
.bob-h-btn svg { width: 16px; height: 16px; }

.bob-note {
  padding: 6px 14px;
  background: #FEF3C7;
  color: #92400E;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-bottom: 1px solid #FDE68A;
  flex-shrink: 0;
}

/* ── Messages ─────────────────────────────────────────────────────────────── */
.bob-msgs {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #F5F5F4;
}
.bob-m {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: bob-msg-in 0.22s ease-out;
}
@keyframes bob-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.bob-m-user { justify-content: flex-end; }
.bob-m-ava {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F59E0B, #D97706);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.bob-m-ava .ico { width: 14px; height: 14px; stroke: #271a03; }
.bob-m-bubble {
  max-width: 82%;
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.bob-m-bob .bob-m-bubble {
  background: #fff;
  color: #1C1917;
  border: 1px solid #E7E5E4;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 3px rgba(10, 10, 10, 0.05);
}
.bob-m-user .bob-m-bubble {
  background: #0A0A0A;
  color: #FAFAF9;
  border-radius: 16px 16px 4px 16px;
}
.bob-md-h {
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #B45309;
  margin: 7px 0 2px;
}
.bob-md-li { display: flex; gap: 6px; margin: 1px 0; }
.bob-md-dot { color: #D97706; font-weight: 800; flex-shrink: 0; }
.bob-md-gap { height: 6px; }

/* Photos inside a message */
.bob-m-imgs {
  display: grid;
  gap: 4px;
  margin: -4px -4px 7px;
}
.bob-n1 { grid-template-columns: 1fr; }
.bob-n2 { grid-template-columns: 1fr 1fr; }
.bob-n3 { grid-template-columns: repeat(3, 1fr); }
.bob-m-img {
  position: relative;
  border: 0;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #1C1917;
  cursor: zoom-in;
}
.bob-m-img img { display: block; width: 100%; height: 110px; object-fit: cover; }
.bob-n1 .bob-m-img img { height: 185px; }
.bob-img-tag {
  position: absolute;
  top: 5px; left: 5px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: rgba(10, 10, 10, 0.74);
  color: #FCD34D;
  padding: 2px 6px;
  border-radius: 5px;
}

/* Quick-ask chips (first open) */
.bob-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 0 34px; }
.bob-chip {
  background: #fff;
  border: 1px solid #E7E5E4;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 600;
  color: #1C1917;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.bob-chip:hover { border-color: #F59E0B; box-shadow: 0 2px 8px rgba(245, 158, 11, 0.18); }
.bob-chip:active { transform: scale(0.96); }

/* Typing indicator */
.bob-typing { display: flex; gap: 4px; padding: 3px 2px; }
.bob-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #A8A29E;
  animation: bob-dot 1.2s infinite ease-in-out;
}
.bob-typing span:nth-child(2) { animation-delay: 0.15s; }
.bob-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bob-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* Error row */
.bob-err {
  background: #FEE2E2;
  color: #991B1B;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  margin: 2px 4px 0 34px;
}
.bob-err-retry {
  border: 0;
  background: none;
  color: #991B1B;
  font-weight: 800;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0 2px;
}

/* ── Pending photo tray ───────────────────────────────────────────────────── */
.bob-tray {
  display: flex;
  gap: 10px;
  padding: 10px 12px 12px;
  border-top: 1px solid #E7E5E4;
  background: #fff;
  overflow-x: auto;
  flex-shrink: 0;
}
.bob-tray-item { position: relative; width: 64px; flex-shrink: 0; }
.bob-tray-item img {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  border: 1px solid #E7E5E4;
}
.bob-tray-x {
  position: absolute;
  top: -7px; right: -7px;
  width: 21px; height: 21px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #0A0A0A;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  padding: 0;
}
.bob-tray-x svg { width: 9px; height: 9px; }
.bob-tray-view {
  position: absolute;
  left: 2px; right: 2px; bottom: 2px;
  border: 0;
  border-radius: 7px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.03em;
  padding: 3px 0;
  background: rgba(231, 229, 228, 0.94);
  color: #57534E;
  cursor: pointer;
}
.bob-tray-view.on { background: #F59E0B; color: #271a03; }

/* ── Composer ─────────────────────────────────────────────────────────────── */
.bob-c {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid #E7E5E4;
  background: #fff;
  flex-shrink: 0;
}
.bob-file { display: none; }
.bob-c-btn {
  width: 38px; height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid #E7E5E4;
  background: #F5F5F4;
  color: #44403C;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.bob-c-btn:hover { background: #FEF3C7; border-color: #FDE68A; color: #B45309; }
.bob-c-btn:active { transform: scale(0.93); }
.bob-c-btn svg { width: 18px; height: 18px; }
.bob-c-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #E7E5E4;
  border-radius: 18px;
  padding: 9px 13px;
  font-size: 13.5px;
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  max-height: 110px;
  background: #FAFAF9;
  color: #1C1917;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.bob-c-input:focus {
  border-color: #F59E0B;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.16);
}
.bob-c-send {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, #F59E0B, #D97706);
  color: #271a03;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.35);
}
.bob-c-send:hover { filter: brightness(1.06); }
.bob-c-send:active { transform: scale(0.93); }
.bob-c-send:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.bob-c-send svg { width: 18px; height: 18px; }

/* ── Photo lightbox ───────────────────────────────────────────────────────── */
.bob-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100001;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: bob-fade 0.18s ease-out;
}
.bob-lightbox img {
  max-width: 94vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
}
@keyframes bob-fade { from { opacity: 0; } to { opacity: 1; } }
