/*
  Luma AI — site-wide widget styles
  Drop this file next to luma-widget.js and load both on every page
  (global layout / footer include). Scoped under #luma-root so it can't
  leak into or be broken by the host page's CSS.
*/
#luma-root {
  --luma-white: #FFF6E5;
  --luma-amber: #FFB020;
  --luma-ember: #FF7A1A;
  --luma-ink: #141414;
  --luma-panel: #1D1D1B;
  --luma-panel-2: #232320;
  --luma-panel-3: #292722;
  --luma-text: #F0EEEA;
  --luma-text-dim: #A7A49C;
  --luma-rule: #38372F;
  --luma-user-bubble: #3A2A1C;
  all: initial;
  font-family: 'IBM Plex Sans', Arial, sans-serif;
}
#luma-root * { box-sizing: border-box; }

/* ---------- Backdrop (dims the page behind the open panel) ---------- */
#luma-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 9, 6, 0.5);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  z-index: 2147482999;
}
#luma-backdrop.show { opacity: 1; pointer-events: auto; }

/* ---------- Launcher ---------- */
#luma-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: radial-gradient(circle at 50% 42%, #2a2115 0%, var(--luma-ink) 72%);
  box-shadow: 0 0 0 4px rgba(255,140,20,0.12), 0 6px 18px rgba(0,0,0,0.35);
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: luma-pulse 3.2s ease-in-out infinite;
  transition: transform 0.15s ease;
}
#luma-launcher:hover { transform: scale(1.05); }
#luma-launcher:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
@keyframes luma-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255,140,20,0.12), 0 6px 18px rgba(0,0,0,0.35); }
  50%      { box-shadow: 0 0 0 9px rgba(255,140,20,0.05), 0 6px 18px rgba(0,0,0,0.35); }
}
@media (prefers-reduced-motion: reduce) { #luma-launcher, #luma-panel, #luma-backdrop { animation: none; transition: none; } }
#luma-launcher .luma-logo {
  width: 46px;
  height: 42px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 0 6px rgba(255, 176, 32, 0.5));
}
#luma-launcher .unread {
  position: absolute; top: -2px; right: -2px; width: 12px; height: 12px; border-radius: 50%;
  background: #FF3B30; border: 2px solid var(--luma-ink); display: none;
}
#luma-launcher .unread.show { display: block; }

/* ---------- Panel ---------- */
#luma-panel {
  position: fixed;
  right: 20px;
  bottom: 86px;
  width: 348px;
  max-height: min(500px, 72vh);
  background: var(--luma-panel);
  border: 1px solid var(--luma-rule);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483000;
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#luma-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

#luma-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  background: linear-gradient(180deg, var(--luma-panel-3), var(--luma-panel-2));
  border-bottom: 1px solid var(--luma-rule);
  flex-shrink: 0;
}
#luma-head .luma-logo {
  width: 36px;
  height: 33px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 0 5px rgba(255, 176, 32, 0.35));
}
#luma-head .htext { flex: 1; min-width: 0; }
#luma-head .htext b { display: block; font-size: 13px; letter-spacing: 0.06em; color: var(--luma-text); font-family: 'IBM Plex Mono', ui-monospace, monospace; }
#luma-head .htext span { font-size: 9.5px; letter-spacing: 0.03em; color: var(--luma-text-dim); font-family: 'IBM Plex Mono', ui-monospace, monospace; }
#luma-close {
  background: none; border: none; color: var(--luma-text-dim); font-size: 15px; cursor: pointer;
  width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  line-height: 1; flex-shrink: 0; transition: background 0.15s ease, color 0.15s ease;
}
#luma-close:hover { color: var(--luma-text); background: rgba(255,255,255,0.06); }

#luma-context {
  margin: 10px 14px 0; font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: #FFD9A0;
  background: #2A2115; border: 1px solid #4A3418; padding: 7px 10px; border-radius: 8px; display: none;
}
#luma-context.show { display: block; }

#luma-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
#luma-body::-webkit-scrollbar { width: 8px; }
#luma-body::-webkit-scrollbar-thumb { background: var(--luma-rule); border-radius: 8px; }

.luma-msg { font-size: 13.5px; line-height: 1.55; max-width: 86%; padding: 10px 13px; border-radius: 12px; white-space: pre-wrap; }
.luma-msg.bot { background: var(--luma-panel-2); color: var(--luma-text); border-left: 2px solid var(--luma-ember); border-radius: 3px 12px 12px 12px; align-self: flex-start; }
.luma-msg.user { background: var(--luma-user-bubble); color: var(--luma-text); border-radius: 12px 3px 12px 12px; align-self: flex-end; }
.luma-msg.typing { opacity: 0.55; font-style: italic; }

#luma-photo-row { display: none; align-items: center; gap: 8px; padding: 0 14px 10px; }
#luma-photo-row.show { display: flex; }
#luma-photo-row img { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; border: 1px solid var(--luma-rule); }
#luma-photo-row span { font-size: 10.5px; color: var(--luma-text-dim); font-family: 'IBM Plex Mono', monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
#luma-photo-remove { margin-left: auto; background: none; border: none; color: var(--luma-text-dim); cursor: pointer; font-size: 11px; flex-shrink: 0; }

#luma-inputrow { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--luma-rule); background: var(--luma-panel-2); flex-shrink: 0; }
#luma-photo-btn {
  background: none; border: 1px solid var(--luma-rule); color: var(--luma-text-dim); border-radius: 10px;
  width: 36px; height: 36px; cursor: pointer; font-size: 15px; flex-shrink: 0; transition: border-color 0.15s ease, color 0.15s ease;
}
#luma-photo-btn:hover { color: var(--luma-amber); border-color: var(--luma-ember); }
#luma-input {
  flex: 1; background: var(--luma-ink); border: 1px solid var(--luma-rule); color: var(--luma-text);
  border-radius: 10px; padding: 9px 11px; font-size: 13.5px; font-family: inherit; resize: none; min-width: 0;
  transition: border-color 0.15s ease;
}
#luma-input:focus { outline: none; border-color: var(--luma-ember); }
#luma-send {
  background: var(--luma-ember); border: none; color: #1a0d00; font-weight: 600; border-radius: 10px;
  padding: 0 16px; cursor: pointer; font-size: 13px; flex-shrink: 0; transition: background 0.15s ease;
}
#luma-send:hover { background: var(--luma-amber); }
#luma-send:disabled { opacity: 0.5; cursor: default; }

.luma-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 12px; flex-shrink: 0; }
.luma-chip {
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: var(--luma-text);
  background: var(--luma-panel-2); border: 1px solid var(--luma-rule); padding: 6px 11px; border-radius: 999px;
  cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.luma-chip:hover { border-color: var(--luma-ember); color: var(--luma-amber); transform: translateY(-1px); }

.luma-handoff { margin-top: 4px; background: #2A2115; border: 1px solid #4A3418; border-radius: 10px; padding: 11px 13px; align-self: flex-start; max-width: 92%; font-size: 13px; line-height: 1.5; color: var(--luma-text); }
.luma-handoff b { display: block; font-size: 11.5px; color: #FFD9A0; margin-bottom: 6px; font-family: 'IBM Plex Mono', monospace; letter-spacing: 0.02em; }
.luma-handoff-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.luma-handoff-actions a { display: inline-block; font-weight: 600; font-size: 12px; padding: 7px 13px; border-radius: 8px; text-decoration: none; transition: background 0.15s ease, border-color 0.15s ease; }
.luma-handoff-primary { background: var(--luma-ember); color: #1a0d00; border: 1px solid transparent; }
.luma-handoff-primary:hover { background: var(--luma-amber); }
.luma-handoff-secondary { background: transparent; border: 1px solid #4A3418; color: #FFD9A0; }
.luma-handoff-secondary:hover { border-color: var(--luma-ember); background: rgba(255,122,26,0.1); }

/* ---------- Mobile: full-width bottom sheet ---------- */
@media (max-width: 480px) {
  #luma-panel {
    left: 10px; right: 10px; bottom: 10px; width: auto;
    max-height: 82vh;
    border-radius: 18px;
    transform: translateY(16px) scale(0.99);
  }
  #luma-panel.open { transform: translateY(0) scale(1); }
  #luma-launcher { right: 14px; bottom: 14px; }
  .luma-handoff-actions { flex-direction: column; align-items: stretch; }
  .luma-handoff-actions a { text-align: center; }
}
