/* ============================================================
   HAMMER BRICK & HOME — ULTRA-ADVANCED CHAT AI UI v2.1
   Desktop + Mobile • iPhone Keyboard Safe • Luxury Dark+Gold
=============================================================== */

:root {
  --hb-chat-bg: #090e1a;
  --hb-chat-surface: #121a2e;
  --hb-chat-gold: #e7bf63;
  --hb-chat-gold-dim: #bba060;
  --hb-chat-accent: #3a4b70;
  --hb-chat-text: #ececec;
  --hb-chat-shadow: 0 20px 50px rgba(0,0,0,0.8);
  --hb-bot-msg-bg: #1c263b;
  --hb-user-msg-bg: linear-gradient(135deg, #e7bf63, #c9a045);
}

/* --- FAB (Floating Action Button) --------------------------- */

.hb-chat-fab {
  position: fixed;
  right: 25px;
  bottom: 25px;
  z-index: 2147483647; /* max z */
  background: radial-gradient(circle at top left, #2a2235, #000);
  border: 1px solid rgba(231,191,99,0.6);
  border-radius: 50px;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.3s ease;
}

.hb-chat-fab:hover {
  transform: scale(1.05) translateY(-4px);
  box-shadow: 0 14px 40px rgba(0,0,0,0.7);
}

.hb-fab-text {
  color: var(--hb-chat-gold);
  font-weight: 700;
  font-size: 14px;
}

.hb-fab-icon {
  font-size: 20px;
}

/* --- Main Window ------------------------------------------- */

.hb-chat-wrapper {
  position: fixed;
  bottom: 100px;
  right: 25px;
  width: 400px;
  max-width: calc(100vw - 50px);
  height: 650px;
  max-height: calc(100vh - 140px);
  background: var(--hb-chat-bg);
  border-radius: 20px;
  border: 1px solid rgba(231,191,99,0.3);
  box-shadow: var(--hb-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  pointer-events: none;
  transition: opacity 0.28s ease-out,
              transform 0.32s cubic-bezier(0.19,1,0.22,1);
  z-index: 2147483646;
  font-family: -apple-system, system-ui, sans-serif;
}

/* Use dynamic viewport height on modern mobile browsers */
@supports (height: 100dvh) {
  .hb-chat-wrapper {
    max-height: 100dvh;
  }
}

.hb-chat-wrapper.hb-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* --- Header & Progress ------------------------------------- */

.hb-chat-header {
  background: rgba(18,26,46,0.95);
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(10px);
}

.hb-chat-title h3 {
  margin: 0;
  font-size: 15px;
  color: #fff;
}

.hb-chat-title span {
  font-size: 11px;
  color: var(--hb-chat-gold);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hb-chat-close {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
}

/* Progress Bar */
.hb-progress-container {
  height: 3px;
  background: #1c263b;
  width: 100%;
}

.hb-progress-bar {
  height: 100%;
  background: var(--hb-chat-gold);
  width: 0%;
  transition: width 0.5s ease;
}

/* --- Message Area ------------------------------------------ */

.hb-chat-body {
  flex: 1;
  padding: 20px;
  padding-bottom: 120px; /* space for footer on desktop */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Bubbles */
.hb-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  animation: hbPopIn 0.3s ease forwards;
}

.hb-msg-bot {
  background: var(--hb-bot-msg-bg);
  color: #ddd;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  border: 1px solid rgba(255,255,255,0.05);
}

.hb-msg-user {
  background: var(--hb-user-msg-bg);
  color: #1a120f;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(231,191,99,0.25);
}

@keyframes hbPopIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* --- Choice Chips (Grid Layout) ---------------------------- */

.hb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 5px;
}

.hb-chip {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(231,191,99,0.4);
  color: var(--hb-chat-gold);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  transition: 0.2s;
  flex: 1 1 auto;
  text-align: center;
}

.hb-chip:hover {
  background: rgba(231,191,99,0.15);
  transform: translateY(-2px);
  border-color: var(--hb-chat-gold);
}

/* Primary / Gold Button */
.hb-chip.hb-primary-btn {
  background: var(--hb-chat-gold) !important;
  color: #000 !important;
  font-weight: 700;
  border: 1px solid var(--hb-chat-gold);
  box-shadow: 0 4px 15px rgba(231,191,99,0.5);
  transition: all 0.2s ease;
}

.hb-chip.hb-primary-btn:hover {
  background: #ffcc66 !important;
  transform: scale(1.02);
  box-shadow: 0 6px 20px rgba(231,191,99,0.7);
}

/* --- Receipt Card ------------------------------------------ */

.hb-receipt {
  background: #fff;
  color: #111;
  padding: 20px;
  border-radius: 12px;
  font-family: "Courier New", monospace;
  position: relative;
  margin-top: 10px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.3);
  border-top: 5px solid var(--hb-chat-gold);
}

.hb-receipt h4 {
  margin: 0 0 10px 0;
  text-align: center;
  text-transform: uppercase;
  border-bottom: 2px dashed #ccc;
  padding-bottom: 10px;
}

.hb-receipt-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
}

.hb-receipt-total {
  border-top: 2px dashed #111;
  margin-top: 10px;
  padding-top: 10px;
  font-weight: 900;
  font-size: 16px;
  display: flex;
  justify-content: space-between;
}

.hb-receipt-footer {
  font-size: 10px;
  text-align: center;
  margin-top: 12px;
  color: #666;
}

/* --- Footer / Input Area ----------------------------------- */

.hb-chat-footer {
  position: relative; /* desktop: inside wrapper bottom */
  padding: 16px;
  background: rgba(9,14,26,0.95);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  gap: 10px;
  align-items: center;
  box-sizing: border-box;
}

.hb-chat-input {
  flex: 1;
  background: #1c263b;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 25px;
  padding: 12px 18px;
  color: #fff;
  outline: none;
  font-size: 16px;             /* iPhone zoom fix */
  -webkit-text-size-adjust: 100%;
}

.hb-chat-input::placeholder {
  color: rgba(255,255,255,0.55);
}

.hb-chat-send {
  background: var(--hb-chat-gold);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #000;
  transition: 0.2s;
  flex-shrink: 0;
}

.hb-chat-send:hover {
  transform: rotate(-10deg) scale(1.1);
}

/* --- Typing Animation -------------------------------------- */

.hb-typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 4px 8px;
}

.hb-dot {
  width: 6px;
  height: 6px;
  background: #888;
  border-radius: 50%;
  animation: hbBounce 1.4s infinite ease-in-out both;
}

.hb-dot:nth-child(1) { animation-delay: -0.32s; }
.hb-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes hbBounce {
  0%, 80%, 100% { transform: scale(0); }
  40%          { transform: scale(1); }
}

/* ============================================================
   MOBILE OPTIMIZATION
   Full-screen, keyboard-safe layout for phones
=============================================================== */

@media (max-width: 768px) {

  .hb-chat-wrapper {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .hb-chat-header {
    padding: 14px;
  }

  .hb-chat-body {
    padding: 14px;
    padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px));
  }

  .hb-chat-footer {
    position: absolute;      /* anchor to bottom of chat window */
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .hb-chat-input {
    padding: 10px 14px;
  }

  .hb-chat-send {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .hb-msg {
    font-size: 13px;
  }
}

/* Even tighter tweaks for very small phones */
@media (max-width: 480px) {
  .hb-chat-title h3 {
    font-size: 14px;
  }
  .hb-chat-title span {
    font-size: 10px;
  }
}

/* Safety Override */
.hb-chat-fab {
  opacity: 1;
  visibility: visible;
}
