/* ─── CacherooAI Support Chat Widget ─────────────────────────────── */
/* Light-themed, standalone, no dependencies                          */

:root {
  --sc-accent: #d4a574;
  --sc-accent-hover: #c49464;
  --sc-bg: #faf9f7;
  --sc-card: #f3f1f6;
  --sc-border: #e0dde4;
  --sc-text: #0c0a12;
  --sc-muted: #9a959f;
  --sc-header-bg: #0c0a12;
  --sc-header-text: #faf9f7;
  --sc-user-bg: #d4a574;
  --sc-user-text: #faf9f7;
  --sc-assistant-bg: #f3f1f6;
  --sc-assistant-text: #0c0a12;
  --sc-input-bg: #faf9f7;
  --sc-input-border: #e0dde4;
  --sc-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --sc-radius: 12px;
  --sc-shadow: 0 8px 32px rgba(12, 10, 18, 0.12);
}

/* ─── Bubble ─────────────────────────────────────────────────────── */

.sc-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sc-header-bg);
  border: none;
  cursor: pointer;
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  transition: transform 250ms cubic-bezier(0.25, 1, 0.5, 1), box-shadow 250ms cubic-bezier(0.25, 1, 0.5, 1);
}

.sc-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.sc-bubble svg {
  width: 24px;
  height: 24px;
  fill: var(--sc-header-text);
}

.sc-bubble .sc-close { display: none; }
.sc-bubble.open .sc-chat-icon { display: none; }
.sc-bubble.open .sc-close { display: block; }

/* ─── Backdrop (maximize mode) ───────────────────────────────────── */

.sc-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9988;
}

.sc-backdrop.visible { display: block; }

/* ─── Panel ──────────────────────────────────────────────────────── */

.sc-panel {
  display: none;
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  height: 520px;
  background: var(--sc-bg);
  border-radius: var(--sc-radius);
  box-shadow: var(--sc-shadow);
  flex-direction: column;
  overflow: hidden;
  z-index: 9989;
  font-family: var(--sc-font);
  border: 1px solid var(--sc-border);
  transition: width 350ms cubic-bezier(0.25, 1, 0.5, 1), height 350ms cubic-bezier(0.25, 1, 0.5, 1), bottom 350ms cubic-bezier(0.25, 1, 0.5, 1), right 350ms cubic-bezier(0.25, 1, 0.5, 1), border-radius 350ms cubic-bezier(0.25, 1, 0.5, 1), transform 350ms cubic-bezier(0.25, 1, 0.5, 1);
}

.sc-panel.open {
  display: flex;
}

/* Maximize mode */
.sc-panel.maximized {
  width: 560px;
  height: 80vh;
  bottom: 50%;
  right: 50%;
  transform: translate(50%, 50%);
  border-radius: 16px;
}

/* ─── Header ─────────────────────────────────────────────────────── */

.sc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--sc-header-bg);
  color: var(--sc-header-text);
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.sc-header span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sc-maximize {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.sc-maximize:hover { background: rgba(255, 255, 255, 0.15); }

.sc-maximize svg {
  width: 18px;
  height: 18px;
  fill: var(--sc-header-text);
}

/* ─── Messages ───────────────────────────────────────────────────── */

.sc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sc-messages::-webkit-scrollbar { width: 4px; }
.sc-messages::-webkit-scrollbar-track { background: transparent; }
.sc-messages::-webkit-scrollbar-thumb { background: var(--sc-border); border-radius: 2px; }

.sc-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
}

.sc-msg.user {
  align-self: flex-end;
  background: var(--sc-user-bg);
  color: var(--sc-user-text);
  border-bottom-right-radius: 4px;
}

.sc-msg.assistant {
  align-self: flex-start;
  background: var(--sc-assistant-bg);
  color: var(--sc-assistant-text);
  border-bottom-left-radius: 4px;
}

/* ─── Markdown in messages ───────────────────────────────────────── */

.sc-msg h1, .sc-msg h2, .sc-msg h3, .sc-msg h4 {
  margin: 8px 0 4px;
  font-size: 14px;
  font-weight: 700;
}

.sc-msg h1 { font-size: 16px; }
.sc-msg h2 { font-size: 15px; }

.sc-msg strong { font-weight: 600; }
.sc-msg em { font-style: italic; }
.sc-msg del { text-decoration: line-through; }

.sc-msg code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 12.5px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.sc-msg pre {
  background: #f0ede8;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}

.sc-msg pre code {
  background: none;
  padding: 0;
  font-size: 12px;
}

.sc-msg ul, .sc-msg ol {
  margin: 6px 0;
  padding-left: 20px;
}

.sc-msg li { margin: 3px 0; }

.sc-msg table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12.5px;
}

.sc-msg th, .sc-msg td {
  border: 1px solid var(--sc-border);
  padding: 6px 8px;
  text-align: left;
}

.sc-msg th {
  background: var(--sc-card);
  font-weight: 600;
}

.sc-msg a {
  color: var(--sc-accent);
  text-decoration: underline;
}

/* ─── Typing Indicator ───────────────────────────────────────────── */

.sc-typing {
  display: none;
  align-self: flex-start;
  padding: 10px 14px;
  background: var(--sc-assistant-bg);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  margin: 0 16px 8px;
  gap: 4px;
}

.sc-typing.visible { display: flex; }

/* impeccable.style: no bounce/elastic — use subtle pulse instead */
.sc-typing span {
  width: 7px;
  height: 7px;
  background: var(--sc-muted);
  border-radius: 50%;
  animation: sc-pulse 1.4s infinite both;
}

.sc-typing span:nth-child(2) { animation-delay: 0.16s; }
.sc-typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes sc-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* ─── Quick-Reply Buttons ────────────────────────────────────────── */

.sc-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 8px;
}

.sc-btn {
  background: var(--sc-bg);
  border: 1px solid var(--sc-accent);
  color: var(--sc-accent);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12.5px;
  font-family: var(--sc-font);
  cursor: pointer;
  transition: background 150ms cubic-bezier(0.25, 1, 0.5, 1), color 150ms cubic-bezier(0.25, 1, 0.5, 1);
}

.sc-btn:hover {
  background: var(--sc-accent);
  color: var(--sc-user-text);
}

/* ─── Escalation Notice ──────────────────────────────────────────── */

.sc-escalation {
  margin: 0 16px 8px;
  padding: 8px 12px;
  background: #fff8f0;
  border: 1px solid #f0d8c0;
  border-radius: 8px;
  font-size: 12px;
  color: #8a6535;
}

/* ─── Input Area ─────────────────────────────────────────────────── */

.sc-input-area {
  display: flex;
  align-items: flex-end;
  padding: 12px;
  border-top: 1px solid var(--sc-border);
  gap: 8px;
  flex-shrink: 0;
  background: var(--sc-bg);
}

.sc-input {
  flex: 1;
  border: 1px solid var(--sc-input-border);
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-family: var(--sc-font);
  resize: none;
  outline: none;
  max-height: 100px;
  line-height: 1.4;
  background: var(--sc-input-bg);
  color: var(--sc-text);
  transition: border-color 150ms cubic-bezier(0.25, 1, 0.5, 1);
}

.sc-input:focus { border-color: var(--sc-accent); }

.sc-input::placeholder { color: var(--sc-muted); }

.sc-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sc-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 150ms cubic-bezier(0.25, 1, 0.5, 1);
}

.sc-send:hover { background: var(--sc-accent-hover); }

.sc-send svg {
  width: 16px;
  height: 16px;
  fill: white;
}

/* ─── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .sc-panel.open {
    width: 100vw;
    height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }

  .sc-panel.maximized {
    width: 100vw;
    height: 100vh;
    bottom: 0;
    right: 0;
    transform: none;
    border-radius: 0;
  }

  .sc-bubble {
    bottom: 16px;
    right: 16px;
  }
}
