/* ── 865 Titan Project Concierge Widget ────────────────────────────────── */

:root {
  --tc-bg: #1a120a;
  --tc-bg2: #120d06;
  --tc-bronze: #bd7a30;
  --tc-bronze-soft: #dca35a;
  --tc-paper: #f7f4ee;
  --tc-muted: rgba(247,244,238,0.45);
  --tc-border: rgba(189,122,48,0.18);
  --tc-user-bg: rgba(189,122,48,0.22);
  --tc-agent-bg: rgba(255,255,255,0.05);
  --tc-radius: 16px;
  --tc-z: 9997;
}

/* ── Floating Button ──────────────────────────────────────────────────── */

.tc-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--tc-z);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  background: linear-gradient(135deg, var(--tc-bronze) 0%, var(--tc-bronze-soft) 100%);
  color: #0e0701;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(189,122,48,0.45), 0 2px 8px rgba(0,0,0,0.35);
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s, opacity 0.2s;
  overflow: hidden;
  white-space: nowrap;
}

.tc-fab::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,.25), transparent);
  transform: translateX(-130%) skewX(-15deg);
  animation: tc-fab-shine 6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes tc-fab-shine {
  0%, 100% { transform: translateX(-130%) skewX(-15deg); }
  50% { transform: translateX(130%) skewX(-15deg); }
}

.tc-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(189,122,48,0.55), 0 4px 12px rgba(0,0,0,0.3);
}

.tc-fab:active { transform: translateY(0); }

.tc-fab.tc-open .tc-fab-icon-chat { display: none; }
.tc-fab.tc-open .tc-fab-icon-close { display: block; }
.tc-fab-icon-close { display: none; }

.tc-fab-text-m { display: none; }

.tc-fab-icon { width: 17px; height: 17px; flex-shrink: 0; }

/* Notification dot */
.tc-fab-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 9px;
  height: 9px;
  background: #e54b4b;
  border: 2px solid var(--tc-bg);
  border-radius: 50%;
  animation: tc-dot-pulse 2s ease-in-out infinite;
}

@keyframes tc-dot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.8; }
}

/* ── Panel ─────────────────────────────────────────────────────────────── */

.tc-panel {
  position: fixed;
  z-index: calc(var(--tc-z) + 1);
  background: var(--tc-bg);
  border: 1px solid var(--tc-border);
  border-radius: var(--tc-radius);
  box-shadow: 0 24px 64px rgba(0,0,0,0.65), 0 4px 20px rgba(189,122,48,0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.22s ease, transform 0.25s cubic-bezier(.34,1.56,.64,1);
  transform-origin: bottom right;
}

.tc-panel.tc-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.94) translateY(8px);
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.tc-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(189,122,48,0.12) 0%, rgba(14,7,1,0.4) 100%);
  border-bottom: 1px solid var(--tc-border);
  flex-shrink: 0;
}

.tc-avatar {
  width: 38px;
  height: 38px;
  background: #1a1208;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 3px;
}

.tc-header-info { flex: 1; min-width: 0; }

.tc-header-name {
  font-family: 'Fraunces', serif;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--tc-paper);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tc-header-sub {
  font-family: 'Inter', sans-serif;
  font-size: 10.5px;
  color: var(--tc-muted);
  margin-top: 1px;
  letter-spacing: 0.03em;
}

.tc-close {
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 50%;
  color: var(--tc-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  font-family: 'Inter', sans-serif;
}

.tc-close:hover { background: rgba(255,255,255,0.12); color: var(--tc-paper); }

/* ── Messages ────────────────────────────────────────────────────────────── */

.tc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  padding-bottom: calc(var(--footer-height, 120px) + env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

/* Push messages to bottom when conversation is short (iMessage style) */
.tc-messages::before {
  content: '';
  flex: 1 0 0;
  min-height: 0;
}

.tc-messages::-webkit-scrollbar { width: 4px; }
.tc-messages::-webkit-scrollbar-track { background: transparent; }
.tc-messages::-webkit-scrollbar-thumb { background: rgba(189,122,48,0.25); border-radius: 2px; }

.tc-msg { display: flex; max-width: 88%; }

.tc-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.tc-msg-assistant { align-self: flex-start; }

.tc-bubble {
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  padding: 9px 13px;
  border-radius: 12px;
  word-break: break-word;
}

.tc-msg-user .tc-bubble {
  background: var(--tc-user-bg);
  color: var(--tc-paper);
  border-radius: 12px 12px 2px 12px;
  border: 1px solid rgba(189,122,48,0.25);
}

.tc-msg-assistant .tc-bubble {
  background: var(--tc-agent-bg);
  color: var(--tc-paper);
  border-radius: 2px 12px 12px 12px;
  border: 1px solid rgba(255,255,255,0.07);
}

/* Typing indicator */
.tc-typing-msg .tc-bubble {
  padding: 11px 15px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.tc-dot {
  width: 7px;
  height: 7px;
  background: var(--tc-muted);
  border-radius: 50%;
  animation: tc-bounce 1.3s ease-in-out infinite;
  flex-shrink: 0;
}

.tc-dot:nth-child(2) { animation-delay: 0.18s; }
.tc-dot:nth-child(3) { animation-delay: 0.36s; }

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

/* Quick reply chips */
.tc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-self: flex-start;
  margin-top: 2px;
}

.tc-chip {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid rgba(189,122,48,0.4);
  color: var(--tc-bronze-soft);
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
  white-space: nowrap;
}

.tc-chip:hover {
  background: rgba(189,122,48,0.15);
  border-color: var(--tc-bronze-soft);
  color: var(--tc-paper);
  transform: translateY(-1px);
}

/* Photo thumbnails */
.tc-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-self: flex-end;
}

.tc-photo-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--tc-border);
}

.tc-upload-thumb {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  border: 1px solid var(--tc-border);
  background-color: rgba(189,122,48,0.08);
  background-size: cover;
  background-position: center;
}

.tc-upload-thumb.tc-uploading {
  animation: tc-pulse 1.2s ease-in-out infinite;
}

@keyframes tc-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.tc-upload-err {
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  color: #e57373;
  align-self: flex-start;
  background: rgba(229,115,115,0.08);
  border: 1px solid rgba(229,115,115,0.2);
  border-radius: 8px;
  padding: 7px 11px;
}

/* ── Persistent footer handoff link ──────────────────────────────────────── */

.tc-send-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px 8px;
  background: transparent;
  border-top: none;
  flex-shrink: 0;
}

.tc-send-bar-text {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--tc-muted);
}

.tc-send-bar-btn {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 0;
  background: none;
  color: var(--tc-bronze-soft);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s;
  letter-spacing: 0.01em;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tc-send-bar-btn:hover { color: var(--tc-paper); }
.tc-send-bar-btn:disabled { opacity: 0.4; cursor: wait; }

/* ── Input Area ──────────────────────────────────────────────────────────── */

.tc-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--tc-border);
  background: var(--tc-bg2);
  flex-shrink: 0;
}

.tc-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 50%;
  color: var(--tc-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.tc-upload-label:hover { background: rgba(189,122,48,0.15); color: var(--tc-bronze-soft); }

.tc-input {
  flex: 1;
  background: rgba(36, 24, 10, 0.95);
  border: 1px solid rgba(189,122,48,0.22);
  border-radius: 10px;
  color: var(--tc-paper);
  caret-color: var(--tc-bronze);
  font-family: 'Inter', sans-serif;
  font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
  line-height: 1.5;
  padding: 7px 11px;
  outline: none;
  min-height: 36px;
  max-height: 120px;
  overflow-y: auto;
  overflow-x: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
  cursor: text;
  transition: border-color 0.15s;
}

.tc-input:empty::before {
  content: attr(data-placeholder);
  color: var(--tc-muted);
  pointer-events: none;
}
.tc-input:focus { border-color: rgba(189,122,48,0.5); }

.tc-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--tc-bronze), var(--tc-bronze-soft));
  color: #0e0701;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}

.tc-send:hover { opacity: 0.9; transform: scale(1.05); }
.tc-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Confirmation Screen ─────────────────────────────────────────────────── */

.tc-confirm {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px;
  gap: 12px;
  height: 100%;
  min-height: 200px;
}

.tc-confirm-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--tc-bronze), var(--tc-bronze-soft));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #0e0701;
  font-weight: 700;
}

.tc-confirm-title {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--tc-paper);
}

.tc-confirm-text {
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  color: var(--tc-muted);
  line-height: 1.6;
  max-width: 260px;
}

.tc-confirm-phone {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--tc-muted);
  margin-top: 4px;
}

.tc-confirm-phone a {
  color: var(--tc-bronze-soft);
  text-decoration: none;
  font-weight: 600;
}

/* ── Contact Input Row ───────────────────────────────────────────────────── */

.tc-contact-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
}

.tc-contact-input {
  flex: 1;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--tc-border);
  border-radius: 10px;
  color: var(--tc-paper);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  min-height: 44px;
}

.tc-contact-input:focus {
  border-color: var(--tc-bronze);
}

.tc-contact-input::placeholder {
  color: var(--tc-muted);
}

/* ── Desktop Layout ──────────────────────────────────────────────────────── */

@media (min-width: 641px) {
  .tc-panel {
    bottom: 86px;
    right: 24px;
    width: 376px;
    height: 540px;
  }

  .tc-fab-text-m { display: none; }
}

/* ── Mobile Layout ───────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  /* Compact circle icon — sits above the site's existing sticky CTA bar */
  .tc-fab {
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    width: 54px;
    height: 54px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    gap: 0;
  }

  .tc-fab-text-d { display: none; }
  .tc-fab-text-m { display: none; }
  .tc-fab .tc-fab-icon { width: 22px; height: 22px; }
  .tc-fab-dot { top: 5px; right: 5px; }

  /* Full-screen panel — tracks visual viewport so keyboard push-up is handled */
  .tc-panel {
    position: fixed !important;
    top: var(--vv-top, 0) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: none !important;
    height: var(--vvh, 100dvh) !important;
    max-height: none !important;
    border-radius: 0 !important;
    border: none !important;
    bottom: auto !important;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    transform-origin: bottom center;
  }

  .tc-panel.tc-hidden {
    transform: translateY(30px) scale(0.97);
  }

  /* Bigger close button on mobile so it's easy to tap */
  .tc-close {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  /* Messages area fills the middle grid row */
  .tc-messages {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 16px;
  }

  /* Footer (send-bar + input-area) sits in last grid row */
  .tc-input-area {
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 10px);
  }
}

/* ── Finish Cards ────────────────────────────────────────────────────────────── */

.tc-finish-cards {
  padding: 12px 16px;
}
.tc-finish-note {
  font-size: 11px;
  color: var(--tc-muted, #888);
  margin: 0 0 12px;
  font-style: italic;
  font-family: 'Inter', sans-serif;
}
.tc-finish-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.tc-finish-card {
  border: 1px solid var(--tc-border, rgba(189,122,48,0.18));
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255,255,255,0.03);
}
.tc-finish-img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  display: block;
}
.tc-finish-placeholder {
  background: rgba(189,122,48,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--tc-bronze-soft, #dca35a);
  font-family: 'Inter', sans-serif;
}
.tc-finish-info {
  padding: 8px;
}
.tc-finish-info strong {
  font-size: 13px;
  display: block;
  margin-bottom: 4px;
  color: var(--tc-paper, #f7f4ee);
  font-family: 'Inter', sans-serif;
}
.tc-finish-info p {
  font-size: 12px;
  color: var(--tc-muted, rgba(247,244,238,0.45));
  margin: 0 0 8px;
  line-height: 1.4;
  font-family: 'Inter', sans-serif;
}
.tc-finish-select {
  font-size: 12px !important;
  padding: 6px 10px !important;
  width: 100%;
  text-align: center;
}
.tc-chip-secondary {
  margin-top: 10px;
  width: calc(100% - 0px);
  display: block;
  text-align: center;
}

/* ── Keyboard-open state ─────────────────────────────────────────────────────── */

.chat-kb-open .tc-send-bar,
.chat-keyboard-open .tc-send-bar {
  display: none !important;
}

.chat-kb-open .tc-input-area,
.chat-keyboard-open .tc-input-area {
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 6px) !important;
}

/* Hide non-essential controls while keyboard is open */
.chat-keyboard-open .tc-persistent-cta,
.chat-keyboard-open .tc-direct-contact,
.chat-keyboard-open [class*="persistent"],
.chat-keyboard-open [class*="project-cta"],
.chat-keyboard-open [class*="direct-contact"] {
  display: none !important;
  visibility: hidden !important;
}

/* ── Reduced Motion ──────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .tc-fab, .tc-panel, .tc-chip, .tc-dot {
    transition: none;
    animation: none;
  }
  .tc-dot { opacity: 0.6; }
}
