/* ===== Holdz N Chill – INDEX (Full-Screen Chat) ===== */

/* -- Theme Tokens -- */
:root {
  --bg: #0b1220;
  --ink: #e8eef7;
  --bubble-bot: rgba(255, 255, 255, 0.08);
  --bubble-border: rgba(255, 255, 255, 0.12);
  --composer-bg: rgba(0, 0, 0, 0.82);
  --accent: #7bd3ff;
  --accent-2: #9d7bff;
  --container-border: rgba(255, 255, 255, 0.15);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* -- Base Page Styles -- */
html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.chat-open {
  overflow: hidden;
}

/* -- Force Chat Window to Full-Screen -- */
#chat-window {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10 !important;
  display: flex !important;
  flex-direction: column !important;
  width: 100vw !important;
  height: 100dvh !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* -- Chat Background Image -- */
#chat-window::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 60% at 50% 10%, transparent, rgba(11, 18, 32, 0.88)),
    url("/assets/spooky.png") center/cover no-repeat;
  filter: brightness(0.65);
}

/* -- Chat Header -- */
.chat-header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--container-border);
}
.chat-header h3 { margin: 0; font-weight: 800; font-size: 1.1rem; }
#close-chat-btn { background: none; border: 0; color: var(--ink); font-size: 1.6rem; cursor: pointer; }

/* -- Chat Message Area -- */
.chat-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.chat-messages { padding: 12px 10px 0; display: flex; flex-direction: column; }

/* -- Chat Bubbles -- */
.message { max-width: 86%; padding: 10px 12px; border-radius: 16px; margin: 4px 12px; }
.bot-message { background: var(--bubble-bot); border: 1px solid var(--bubble-border); align-self: flex-start; }
.user-message { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #0b1020; font-weight: 700; align-self: flex-end; }

/* -- High Quality In-Chat Card Images (CORRECTED) -- */
.message .card-img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(85vw, 260px); /* Let JS determine the optimal width */
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,.4);
  cursor: zoom-in;
  background-color: #1a2233; /* Dark background for any letterboxing */
  
  /* THIS IS THE FIX: Never stretch or crop the image content */
  object-fit: contain;

  /* Hints for crisp rendering */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* -- Typing Indicator -- */
.typing-indicator { display: flex; align-items: center; gap: 6px; padding: 0.45rem 0.6rem; }
.typing-indicator span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.9); animation: ti 1.2s infinite ease-in-out; }
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ti { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.6; } 40% { transform: scale(1); opacity: 1; } }

/* -- Chat Composer -- */
.chat-composer { flex: 0 0 auto; background: var(--composer-bg); border-top: 1px solid var(--container-border); padding: 0.5rem 0.75rem calc(0.75rem + var(--safe-bottom)); }
#quick-replies { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 6px 6px; }
.quick-reply-chip { padding: 0.5rem 0.9rem; border-radius: 18px; border: 0; cursor: pointer; background: #fff; color: #2c3e50; font-weight: 800; }
#chat-form { display: flex; gap: 0.5rem; padding: 6px 6px 8px; margin-top: 0.25rem; }
#chat-input { flex: 1 1 auto; border: 1px solid #333; border-radius: 12px; padding: 0.9rem 0.95rem; background: rgba(28,28,30,0.85); color: var(--ink); font-size: 1rem; }
#chat-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(123,211,255,0.25); }
#send-btn { border: 0; border-radius: 12px; padding: 0 1.1rem; font-weight: 800; min-height: 44px; cursor: pointer; color: #0b1020; background: var(--accent); }

/* -- Image Zoom Modal -- */
.img-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(5px); z-index: 999; display: none; flex-direction: column; align-items: center; justify-content: center; }
.img-modal-show { display: flex; }
#img-close { position: absolute; top: 16px; right: 20px; font-size: 28px; background: transparent; border: 0; color: #fff; cursor: pointer; }
#img-full { max-width: 90vw; max-height: 80vh; border-radius: 8px; }
#img-download { margin-top: 12px; padding: 0.75rem 1.5rem; border: 0; border-radius: 8px; background: var(--accent); color: #0b1020; font-weight: 800; cursor: pointer; }