/* ============================================================
   Ask Mira — embeddable chat widget (LIGHT theme)
   Matches the redesigned "Beta: For you" chat UI.
   Scoped under #mira-root / #mira-panel to avoid host clashes.
   ============================================================ */

#mira-root, #mira-root * { box-sizing: border-box; }

#mira-root {
  --mira-text:    #1c2024;   /* near-black body text          */
  --mira-muted:   #6b7280;   /* secondary / disclaimer text   */
  --mira-link:    #2f5fd6;   /* link blue                     */
  --mira-blue:    #5566b8;   /* Play button / accent          */
  --mira-blue-d:  #44539c;   /* Play button shadow rim        */
  --mira-bg:      #ffffff;   /* panel background              */
  --mira-user:    #ececec;   /* user bubble grey              */
  --mira-card:    #f4f5f7;   /* casino card / banner grey     */
  --mira-line:    #e6e8eb;   /* hairline borders              */
  --mira-radius:  18px;

  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--mira-text);
}

/* ---------------- launcher ---------------- */
#mira-launch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: #111317;
  color: #fff;
  font: 600 15px/1 inherit;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  transition: transform .15s ease, box-shadow .15s ease;
}
#mira-launch:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(0,0,0,.28); }
#mira-launch svg { width: 20px; height: 20px; }
#mira-root.open #mira-launch { display: none; }

/* ---------------- panel ---------------- */
#mira-panel {
  display: none;
  flex-direction: column;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 680px;
  max-height: calc(100vh - 40px);
  background: var(--mira-bg);
  border: 1px solid var(--mira-line);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(15,20,30,.28);
  position: relative;   /* anchor for the chat-history overlay */
}
#mira-root.open #mira-panel { display: flex; }

/* ---------------- header ---------------- */
#mira-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--mira-line);
  background: #fff;
  flex: 0 0 auto;
}
#mira-spark { width: 26px; height: 26px; color: #111317; flex: 0 0 auto; }
#mira-brand { font: 800 21px/1 inherit; letter-spacing: -.01em; }
#mira-beta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding: 8px 14px;
  border: 1px solid var(--mira-line);
  border-radius: 999px;
  background: #fafbfc;
  font: 600 14px/1 inherit;
  color: #2a2f36;
  cursor: pointer;
}
#mira-beta svg { width: 14px; height: 14px; opacity: .7; transition: transform .18s ease; }
#mira-mode { position: relative; }
#mira-mode.open #mira-beta svg { transform: rotate(180deg); }
#mira-mode-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--mira-line);
  border-radius: 16px;
  box-shadow: 0 12px 34px rgba(17, 19, 23, .14);
  padding: 8px;
  z-index: 30;
}
#mira-mode-menu[hidden] { display: none; }
.mira-mode-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: none;
  font: 600 16px/1.1 inherit;
  color: #111317;
  cursor: pointer;
  text-align: left;
}
.mira-mode-item:hover:not([disabled]) { background: #f3f4f6; }
.mira-mode-item[disabled] { cursor: default; color: #9aa1ab; }
.mira-mode-check { width: 18px; height: 18px; color: #111317; opacity: 0; flex: 0 0 auto; }
.mira-mode-check svg { width: 18px; height: 18px; }
.mira-mode-item.selected .mira-mode-check { opacity: 1; }
.mira-mode-soon {
  font: 600 11px/1 inherit;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #6b7280;
  background: #eef0f3;
  border-radius: 999px;
  padding: 4px 8px;
  flex: 0 0 auto;
}
#mira-head-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
#mira-head-actions .mira-ic {
  width: 22px; height: 22px; color: #111317; cursor: pointer;
  background: none; border: 0; padding: 0;
}
#mira-close {
  width: 34px; height: 34px; border-radius: 999px;
  border: 1px solid var(--mira-line); background: #fff; color: #6b7280;
  font-size: 20px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#mira-close:hover { background: #f4f5f7; }

/* ---------------- messages ---------------- */
#mira-msgs {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* AI disclaimer banner */
#mira-disclaimer {
  background: var(--mira-card);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 14px;
  color: var(--mira-muted);
}
#mira-disclaimer a { color: var(--mira-muted); text-decoration: underline; }

/* user bubble (right) */
.mira-msg.user {
  align-self: flex-end;
  max-width: 82%;
  background: var(--mira-user);
  color: var(--mira-text);
  padding: 14px 18px;
  border-radius: 20px;
  font-size: 16px;
}

/* bot text (left, plain — no bubble) */
.mira-msg.bot {
  align-self: flex-start;
  max-width: 92%;
  color: var(--mira-text);
  font-size: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.mira-msg.bot a { color: var(--mira-link); text-decoration: underline; }
.mira-msg.bot.error { color: #b42318; }

/* affiliate disclosure subline under a bot intro */
.mira-disclosure {
  align-self: flex-start;
  margin-top: -8px;
  font-size: 14px;
  color: var(--mira-muted);
}
.mira-disclosure a { color: var(--mira-muted); text-decoration: underline; }

/* ---------------- casino card ---------------- */
.mira-card {
  align-self: stretch;
  background: var(--mira-card);
  border-radius: 16px;
  padding: 18px 18px 16px;
}
.mira-card-top { display: flex; align-items: center; gap: 14px; }
.mira-card-logo {
  width: 64px; height: 64px;
  border-radius: 12px;
  background: #1b1340;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.mira-card-logo img { width: 100%; height: 100%; object-fit: contain; }
.mira-card-logo .mira-logo-fallback {
  color: #fff; font: 700 13px/1.1 inherit; text-align: center; padding: 4px;
}
.mira-card-name { font: 800 21px/1.2 inherit; letter-spacing: -.01em; }

.mira-card-list { list-style: none; margin: 14px 0 0; padding: 0; }
.mira-card-list li {
  position: relative;
  padding-left: 22px;
  margin: 8px 0;
  font-size: 16px;
}
.mira-card-list li::before {
  content: "•";
  position: absolute; left: 4px; top: 0;
  color: var(--mira-text);
}
.mira-card-list b { font-weight: 700; }
.mira-card-list .mira-card-val { color: #2a2f36; }
.mira-card-list a { color: var(--mira-link); font-weight: 700; text-decoration: underline; }

.mira-card-play {
  display: block;
  width: 100%;
  margin: 16px 0 0;
  padding: 16px;
  border: 0;
  border-radius: 999px;
  background: var(--mira-blue);
  box-shadow: 0 4px 0 var(--mira-blue-d);
  color: #fff;
  font: 800 18px/1 inherit;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform .1s ease, filter .15s ease;
}
.mira-card-play:hover { filter: brightness(1.05); }
.mira-card-play:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--mira-blue-d); }
.mira-card-tc {
  margin: 12px 0 0;
  text-align: center;
  font-size: 14px;
  color: var(--mira-muted);
}

/* ---------------- news-link suggestions ---------------- */
.mira-links { list-style: none; margin: 0; padding: 0; align-self: stretch; }
.mira-links li {
  position: relative;
  padding-left: 22px;
  margin: 14px 0;
}
.mira-links li::before {
  content: "•";
  position: absolute; left: 4px; top: 0;
  color: var(--mira-muted);
}
.mira-links a { color: var(--mira-link); text-decoration: underline; font-size: 16px; }

/* responsible-play line */
.mira-responsible {
  display: flex; align-items: center; gap: 10px;
  align-self: flex-start;
  font-size: 15px; color: var(--mira-muted);
}
.mira-responsible .mira-rp-ic {
  width: 26px; height: 26px; flex: 0 0 auto;
  border-radius: 999px; background: #111317; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font: 700 16px/1 inherit;
}
.mira-responsible a { color: var(--mira-muted); text-decoration: underline; }

/* feedback thumbs */
.mira-feedback { display: flex; gap: 16px; align-self: flex-start; }
.mira-feedback button {
  background: none; border: 0; padding: 4px; cursor: pointer;
  color: #9aa1ab; line-height: 0;
}
.mira-feedback button svg { width: 22px; height: 22px; }
.mira-feedback button:hover { color: #4b5563; }
.mira-feedback button.active { color: var(--mira-blue); }

/* typing dots */
.mira-typing { display: inline-flex; gap: 5px; padding: 4px 0; }
.mira-typing span {
  width: 8px; height: 8px; border-radius: 50%;
  background: #c2c7cf;
  animation: mira-bounce 1.2s infinite ease-in-out;
}
.mira-typing span:nth-child(2) { animation-delay: .15s; }
.mira-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes mira-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ---------------- composer ---------------- */
#mira-form {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 18px 18px;
  padding: 8px 8px 8px 22px;
  border: 1px solid var(--mira-line);
  border-radius: 999px;
  background: #fff;
}
#mira-input {
  flex: 1 1 auto;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font: 400 16px/1.4 inherit;
  color: var(--mira-text);
  max-height: 96px;
  padding: 8px 0;
}
#mira-input::placeholder { color: #9aa1ab; }
#mira-send {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border: 0; border-radius: 999px;
  background: #111317; color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s ease, filter .15s ease;
}
#mira-send:hover { filter: brightness(1.15); }
#mira-send:active { transform: scale(.94); }
#mira-send:disabled { opacity: .5; cursor: default; }
#mira-send svg { width: 20px; height: 20px; }

/* ============================================================
   Standalone full-page mode (public/chat.html sets body class)
   ============================================================ */
body.mira-standalone { margin: 0; background: #eef0f3; }
body.mira-standalone #mira-root {
  position: static;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px;
}
body.mira-standalone #mira-launch { display: none; }
body.mira-standalone #mira-panel {
  display: flex;
  width: 460px;
  height: calc(100vh - 48px);
  max-height: 900px;
}

@media (max-width: 480px) {
  #mira-root { right: 0; bottom: 0; left: 0; }
  #mira-panel {
    width: 100vw; max-width: 100vw;
    height: 100vh; max-height: 100vh;
    border-radius: 0; border: 0;
  }
  #mira-root.open #mira-launch { display: none; }
}

/* ---------- registration / login gate ---------- */
.mira-auth {
  align-self: stretch;
  margin: 6px 0 4px;
  background: var(--mira-card);
  border: 1px solid var(--mira-line);
  border-radius: 16px;
  padding: 16px;
}
.mira-auth-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--mira-text);
  margin-bottom: 12px;
}
.mira-auth-form { display: flex; flex-direction: column; gap: 8px; }
.mira-auth-row { display: flex; gap: 8px; }
.mira-auth-row .mira-auth-in { flex: 1; min-width: 0; }
.mira-auth-in {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--mira-line);
  border-radius: 10px;
  background: #fff;
  color: var(--mira-text);
  padding: 11px 12px;
  font-size: 15px;
  font-family: inherit;
}
.mira-auth-in:focus { outline: none; border-color: var(--mira-blue); }
.mira-auth-btn {
  margin-top: 4px;
  border: none;
  border-radius: 12px;
  background: var(--mira-blue);
  box-shadow: 0 4px 0 var(--mira-blue-d);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 16px;
  cursor: pointer;
}
.mira-auth-btn:hover { filter: brightness(1.04); }
.mira-auth-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--mira-blue-d); }
.mira-auth-btn:disabled { opacity: .7; cursor: default; }
.mira-auth-err {
  color: #b42318;
  font-size: 13.5px;
  margin-top: 2px;
}
.mira-auth-switch {
  margin-top: 12px;
  font-size: 14px;
  color: var(--mira-muted);
}
.mira-auth-switch a { color: var(--mira-link); text-decoration: underline; cursor: pointer; }
.mira-auth-legal {
  margin-top: 8px;
  font-size: 12px;
  color: var(--mira-muted);
}
.mira-quota-note {
  align-self: flex-start;
  max-width: 90%;
  margin: 2px 0 6px;
  font-size: 13px;
  color: var(--mira-muted);
  background: var(--mira-card);
  border: 1px dashed var(--mira-line);
  border-radius: 10px;
  padding: 8px 12px;
}

/* ============================================================
   Chat History panel (registered members) — overlays the chat
   body, light theme to match the mockup.
   ============================================================ */
/* When history is open, the panel hides the chat body + composer and
   lets the history view fill the remaining space below the header. This
   avoids brittle pixel offsets across floating / standalone / mobile. */
#mira-root.history-open #mira-msgs,
#mira-root.history-open #mira-form { display: none; }

#mira-history {
  flex: 1 1 auto;
  min-height: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  animation: mira-hist-in .16s ease;
}
#mira-history[hidden] { display: none; }
@keyframes mira-hist-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.mira-hist-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 10px;
  flex: 0 0 auto;
}
.mira-hist-title { font: 800 18px/1 inherit; letter-spacing: -.01em; color: var(--mira-text); }
.mira-hist-close {
  margin-left: auto;
  width: 30px; height: 30px; border-radius: 999px;
  border: 1px solid var(--mira-line); background: #fff; color: var(--mira-muted);
  font-size: 19px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.mira-hist-close:hover { background: var(--mira-card); }

.mira-hist-search { padding: 0 18px 12px; flex: 0 0 auto; }
.mira-hist-search input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--mira-line);
  border-radius: 12px;
  background: var(--mira-card);
  font: 500 15px/1.2 inherit;
  color: var(--mira-text);
  outline: none;
}
.mira-hist-search input::placeholder { color: var(--mira-muted); }
.mira-hist-search input:focus { border-color: var(--mira-blue); background: #fff; }

.mira-hist-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px 10px 16px;
}
.mira-hist-group {
  padding: 14px 8px 6px;
  font: 700 11px/1 inherit;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--mira-muted);
}
.mira-hist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px;
  border-radius: 10px;
  transition: background .12s ease, opacity .15s ease;
}
.mira-hist-row:hover { background: var(--mira-card); }
.mira-hist-row.active { background: #eef0fb; }
.mira-hist-row.removing { opacity: 0; }
.mira-hist-link {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  border: 0; background: none; cursor: pointer;
  padding: 9px 6px;
  font: 600 15px/1.3 inherit;
  color: var(--mira-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mira-hist-row.active .mira-hist-link { color: var(--mira-blue-d); }
.mira-hist-del {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border: 0; background: none; cursor: pointer;
  color: var(--mira-muted);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .12s ease, color .12s ease, background .12s ease;
}
.mira-hist-del svg { width: 17px; height: 17px; }
.mira-hist-row:hover .mira-hist-del,
.mira-hist-row.active .mira-hist-del { opacity: 1; }
.mira-hist-del:hover { color: #d23b3b; background: rgba(210,59,59,.10); }
.mira-hist-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--mira-muted);
  font-size: 14px;
}

/* ---------------- entry chips ---------------- */
.mira-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 6px;
  align-self: flex-start;
  max-width: 92%;
}
.mira-chip {
  display: inline-flex;
  align-items: center;
  padding: 9px 14px;
  border: 1px solid var(--mira-line);
  border-radius: 999px;
  background: #fff;
  color: var(--mira-text);
  font: 600 14px/1.2 inherit;
  cursor: pointer;
  text-align: left;
  transition: background .14s ease, border-color .14s ease, transform .12s ease, box-shadow .14s ease;
}
.mira-chip:hover {
  background: #f3f4f6;
  border-color: #d4d8dd;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.mira-chip:active { transform: translateY(1px); }

/* ---------------- markdown tables in bot replies ---------------- */
.mira-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 8px 0;
  -webkit-overflow-scrolling: touch;
}
.mira-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
  line-height: 1.4;
  background: #fff;
  border: 1px solid var(--mira-line);
  border-radius: 10px;
  overflow: hidden;
}
.mira-table thead th {
  background: #f5f6f8;
  color: var(--mira-text);
  font-weight: 700;
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--mira-line);
  white-space: nowrap;
}
.mira-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--mira-line);
  vertical-align: top;
  white-space: normal;
}
.mira-table tbody tr:last-child td { border-bottom: 0; }
.mira-table tbody tr:nth-child(even) td { background: #fafbfc; }
.mira-table a { color: var(--mira-link); text-decoration: underline; }
