/* ============================================================
   The Tech Pad — AI-assisted messaging (inbox overlay)
   Companion stylesheet for ai-assistant-ui.js. Matches the
   bundle's design system: green #087552, mint #badfce,
   borders #dfe7e3, white header/composer surfaces.
   ============================================================ */

/* ---------- AI mode selector (chat header) ---------- */
.ai-mode-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 2px;
}

.ai-mode-caption {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #6b7a74;
  text-transform: uppercase;
}

.ai-segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: #fff;
  border: 1px solid #badfce;
  border-radius: 9px;
}

.ai-segmented button {
  border: 0;
  background: transparent;
  color: #087552;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.ai-segmented button:hover:not(.active) {
  background: #eefaf4;
}

.ai-segmented button.active {
  background: #087552;
  color: #fff;
}

.ai-mode-wrap[data-disabled="true"] .ai-segmented button {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-mode-badge {
  font-size: 11px;
  font-weight: 800;
  color: #0b5f40;
  background: #e2f5ec;
  border: 1px solid #badfce;
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
  animation: aiPulse 2s ease-in-out infinite;
}

@keyframes aiPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ---------- AI action bar (above composer) ---------- */
.ai-action-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: #f7faf8;
  border-bottom: 1px solid #e6eeea;
}

.ai-action-bar:has(.ai-btn[aria-busy="true"]) {
  animation: aiBarBusy 1.6s ease-in-out infinite;
}

@keyframes aiBarBusy {
  0%, 100% { background: #f7faf8; }
  50% { background: #eef6f1; }
}

.ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #badfce;
  background: #fff;
  color: #087552;
  border-radius: 9px;
  padding: 7px 12px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

.ai-btn:hover:not(:disabled) {
  background: #eefaf4;
}

.ai-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.ai-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ai-spinner {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border: 2px solid #cfe9dd;
  border-top-color: #087552;
  border-radius: 50%;
  animation: aiSpin 0.7s linear infinite;
}

@keyframes aiSpin {
  to { transform: rotate(360deg); }
}

.ai-bar-hint {
  margin-left: auto;
  font-size: 11px;
  color: #7d8a85;
  text-align: right;
}

.ai-bar-status {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.ai-bar-status.ok { color: #087552; }
.ai-bar-status.error { color: #b3261e; }
.ai-bar-status.warn { color: #9a6700; }

.ai-status-action {
  border: 1px solid #badfce;
  background: #fff;
  color: #087552;
  border-radius: 7px;
  padding: 2px 8px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
  cursor: pointer;
}

.ai-status-action:hover {
  background: #eefaf4;
}

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .ai-mode-caption {
    display: none;
  }

  .ai-segmented button {
    font-size: 11px;
    padding: 5px 7px;
  }

  .ai-action-bar {
    padding: 7px 10px;
    gap: 6px;
  }

  .ai-btn {
    flex: 1 1 auto;
    justify-content: center;
    font-size: 12px;
    padding: 7px 8px;
  }

  .ai-bar-hint {
    display: none;
  }

  /* ---- mobile chat header: never lose the back button, contact name or
     the AI control. The bundle's .chat-actions row is ~407px wide and does
     not wrap, so on phones it overflows the screen and squeezes the contact
     name to zero width. Let the header flow into two rows (back+name, then
     actions) and let the actions wrap internally. ---- */
  .inbox-shell .chat-header {
    flex-wrap: wrap;
    row-gap: 6px;
    padding: 8px 9px;
  }

  .inbox-shell .chat-header .mobile-chat-back {
    flex: 0 0 auto;
  }

  .inbox-shell .chat-person {
    flex: 1 1 auto;
    min-width: 0;
  }

  .inbox-shell .chat-person b {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .inbox-shell .chat-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 5px;
    min-width: 0;
    max-width: 100%;
  }

  .inbox-shell .chat-actions .ai-mode-wrap {
    flex: 0 0 auto;
  }

  .inbox-shell .chat-actions .ai-mode-badge {
    display: none;
  }
}

@media (max-width: 520px) {
  .inbox-shell .chat-header {
    padding: 8px;
  }

  /* Full-width action row on the second line: AI control + actions
     right-aligned, wraps internally if still too wide. */
  .inbox-shell .chat-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .inbox-shell .chat-actions .ai-segmented button {
    font-size: 10.5px;
    padding: 5px 6px;
  }

  .inbox-shell .chat-actions button {
    padding: 7px 9px;
  }
}
