/* ===========================
   iChatBoot — Visitor Chat
   =========================== */

.chat-body {
  background: var(--color-surface);
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Pre-chat form ---------- */
.pre-chat {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-5);
  background:
    radial-gradient(800px 400px at 20% 0%, rgba(127,27,255,0.10), transparent 60%),
    radial-gradient(800px 400px at 80% 100%, rgba(98,0,232,0.08), transparent 60%),
    var(--color-surface);
}
.pre-card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: var(--radius-card);
  padding: var(--space-6);
  box-shadow: var(--shadow-elev);
  border: 1px solid var(--color-border);
}

/* ---------- App layout ---------- */
.chat-app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  background: var(--color-bg);
}
.chat-side {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: var(--space-5);
  overflow-y: auto;
}
.info-block { margin-top: var(--space-4); }
.info-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  font-weight: 600;
  margin-bottom: 4px;
}
.info-value { font-size: 15px; font-weight: 600; color: var(--color-text); }
.info-value-small { font-size: 13px; color: var(--color-text); word-break: break-all; }
.info-sub { font-size: 13px; color: var(--color-text-secondary); }

/* ---------- Chat main ---------- */
.chat-main {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  height: 100vh;
  min-width: 0;
}
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  background: #fff;
}
.chat-title { font-family: var(--font-heading); font-size: 18px; }
.chat-subtitle { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.messages {
  padding: var(--space-5);
  overflow-y: auto;
  background:
    radial-gradient(600px 400px at 50% 0%, rgba(127,27,255,0.04), transparent 60%),
    var(--color-bg);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ---------- Bubbles ---------- */
.bubble-row {
  display: flex; flex-direction: column;
  max-width: 78%;
  animation: slide-in 0.18s ease-out;
}
@keyframes slide-in { from { opacity:0; transform: translateY(4px); } to { opacity:1; transform:none; } }

.bubble-row.visitor { align-self: flex-end; align-items: flex-end; }
.bubble-row.agent { align-self: flex-start; align-items: flex-start; }
.bubble-row.system { align-self: center; max-width: 90%; align-items: center; }

.bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.bubble-row.visitor .bubble {
  background: var(--color-primary-light);
  color: var(--color-text);
  border-bottom-right-radius: 4px;
}
.bubble-row.agent .bubble {
  background: #fff;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
}
.bubble-row.system .bubble {
  background: rgba(127,27,255,0.06);
  color: var(--color-text-secondary);
  font-size: 13px;
  text-align: center;
  border-radius: 999px;
  padding: 6px 14px;
}

.bubble-meta {
  display: flex; gap: 6px; align-items: center;
  font-size: 11px; color: var(--color-text-secondary);
  margin-top: 4px;
}
.bubble-meta .sender-name { font-weight: 600; color: var(--color-text); }
.tick { display: inline-flex; }
.tick svg { width: 14px; height: 14px; }
.tick.read { color: var(--color-primary); }
.tick.sent { color: var(--color-text-secondary); }

.bubble img.attached {
  max-width: 260px; border-radius: 10px; margin-top: 6px;
  border: 1px solid var(--color-border);
}
.file-card {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: #fff; border: 1px solid var(--color-border);
  border-radius: 10px; margin-top: 6px;
  color: var(--color-text); text-decoration: none; font-size: 14px;
}
.file-card:hover { background: var(--color-surface); text-decoration: none; }
.file-card svg { color: var(--color-primary); }

/* ---------- Typing indicator ---------- */
.typing-indicator {
  display: flex; align-items: center; gap: 6px;
  padding: 6px var(--space-5);
  color: var(--color-text-secondary); font-size: 13px;
}
.typing-indicator .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-primary);
  animation: bounce 1.2s infinite;
}
.typing-indicator .dot:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Offline banner ---------- */
.offline-banner {
  background: rgba(247,144,9,0.10);
  color: #B5660B;
  padding: 10px var(--space-5);
  font-size: 13px;
  border-top: 1px solid rgba(247,144,9,0.20);
  border-bottom: 1px solid rgba(247,144,9,0.20);
}

/* ---------- Composer ---------- */
.chat-footer {
  background: #fff;
  border-top: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-5);
}
.composer {
  display: flex; gap: 6px; align-items: end;
}
.composer-input {
  flex: 1;
  resize: none;
  max-height: 140px;
  min-height: 40px;
  padding: 10px 14px;
  font-family: var(--font-body); font-size: 15px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease;
  background: #fff; color: var(--color-text);
}
.composer-input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(127,27,255,0.15); }
.composer-btn { color: var(--color-text-secondary); }
.composer-btn:hover { color: var(--color-primary); background: var(--color-primary-light); }
.composer-send { padding: 0 14px; height: 40px; min-width: 44px; }

.emoji-picker {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  padding: 8px;
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  max-height: 200px;
  overflow: auto;
  box-shadow: var(--shadow-soft);
}
.emoji-picker button {
  background: transparent; border: 0;
  font-size: 22px; padding: 4px;
  border-radius: 6px; cursor: pointer;
}
.emoji-picker button:hover { background: var(--color-primary-light); }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .chat-app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .chat-side {
    display: none;
  }
  .chat-side.open {
    display: block;
    position: fixed; inset: 0; z-index: 100;
  }
  .chat-header { padding: var(--space-3); }
  .messages { padding: var(--space-3); }
  .chat-footer { padding: var(--space-2) var(--space-3); }
  .pre-card { padding: var(--space-5); }
  .emoji-picker { grid-template-columns: repeat(8, 1fr); }
}
