/*
 * Rockstar Music chat widget — teal brand edition.
 *
 * Palette mirrors the lesson-page premium aesthetic: teal gradients,
 * white backgrounds, subtle shadows, rounded corners. The dark-theme
 * teacher cards are replaced with a light, elevated card style that
 * echoes TeacherBlock on the main site.
 */

/* ── Brand tokens ── */
:root {
  --rsm-teal-light: #20dbc8;
  --rsm-teal: #20a89a;
  --rsm-teal-dark: #168375;
  --rsm-text: #0f1a1d;
  --rsm-text-secondary: #6b7075;
  --rsm-muted: #9aa0a4;
  --rsm-bg: #ffffff;
  --rsm-bg-subtle: #f6fbfa;
  --rsm-card: #ffffff;
  --rsm-border: #e6eaec;
  --rsm-chip-bg: #f4f6f7;
  --rsm-chip-border: #e6eaec;
  --rsm-shadow: 0 8px 28px rgba(15, 26, 29, 0.12);
  --rsm-radius: 16px;
  --rsm-accent: var(--rsm-teal);
  --rsm-accent-light: var(--rsm-teal-light);
}

/* ── Launcher button ── */
#rockstar-chat-launcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--rsm-teal-light) 0%, var(--rsm-teal) 100%);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 10px 24px -8px rgba(32, 168, 154, 0.50),
    0 4px 10px -4px rgba(32, 219, 200, 0.30);
  z-index: 2147483647;
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
#rockstar-chat-launcher:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow:
    0 16px 32px -10px rgba(32, 168, 154, 0.55),
    0 6px 14px -6px rgba(32, 219, 200, 0.35);
}
#rockstar-chat-launcher img {
  width: 60%;
  height: 60%;
  pointer-events: none;
}

/* ── Chat panel ── */
#rockstar-chat-panel {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background-color: var(--rsm-bg);
  border: 1px solid var(--rsm-border);
  border-radius: 20px;
  box-shadow:
    0 30px 60px -20px rgba(15, 26, 29, 0.18),
    0 10px 24px -10px rgba(15, 26, 29, 0.08);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483646;
}
#rockstar-chat-panel.open {
  display: flex;
}

/* ── Header ── */
.rockstar-chat-header {
  background: linear-gradient(135deg, var(--rsm-teal-light) 0%, var(--rsm-teal) 100%);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.005em;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
}
.rockstar-chat-close {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #ffffff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 160ms ease;
}
.rockstar-chat-close:hover {
  background: rgba(255, 255, 255, 0.30);
}

/* ── Body ── */
.rockstar-chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--rsm-bg-subtle);
  min-height: 0;
}

/* ── Messages ── */
.rockstar-chat-messages {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  font-size: 0.92rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rockstar-chat-message {
  margin-bottom: 0;
  padding: 10px 14px;
  border-radius: 16px;
  max-width: 82%;
  word-wrap: break-word;
  font-size: 0.88rem;
  line-height: 1.5;
}
.rockstar-chat-message.user {
  background: linear-gradient(135deg, var(--rsm-teal-light), var(--rsm-teal));
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(32, 168, 154, 0.22);
}
.rockstar-chat-message.bot {
  background-color: #ffffff;
  color: var(--rsm-text);
  align-self: flex-start;
  border: 1px solid var(--rsm-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(15, 26, 29, 0.04);
}

/* ── Input area ── */
.rockstar-chat-input-area {
  display: flex;
  padding: 10px 12px;
  gap: 8px;
  border-top: 1px solid var(--rsm-border);
  background-color: #ffffff;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
}
.rockstar-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--rsm-border);
  border-radius: 12px;
  font-size: 0.88rem;
  font-family: inherit;
  background: var(--rsm-bg-subtle);
  color: var(--rsm-text);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.rockstar-chat-input:focus {
  outline: none;
  border-color: var(--rsm-teal);
  box-shadow: 0 0 0 3px rgba(32, 168, 154, 0.15);
  background: #ffffff;
}
.rockstar-chat-send {
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--rsm-teal-light) 0%, var(--rsm-teal) 100%);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  transition: transform 160ms ease, box-shadow 160ms ease;
  box-shadow: 0 4px 12px -4px rgba(32, 168, 154, 0.40);
}
.rockstar-chat-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -4px rgba(32, 168, 154, 0.50);
}

/* ── CTA button (fallback "Book a Free Trial") ── */
.rockstar-chat-cta {
  margin: 8px 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--rsm-teal-light) 0%, var(--rsm-teal) 100%);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  width: calc(100% - 24px);
  box-sizing: border-box;
  box-shadow: 0 8px 20px -8px rgba(32, 168, 154, 0.45);
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.rockstar-chat-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -8px rgba(32, 168, 154, 0.55);
}

/* ── Lead form ── */
.rockstar-lead-form {
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  height: 100%;
}
.rockstar-lead-instructions {
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--rsm-text);
}
.rockstar-lead-field {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
}
.rockstar-lead-field label {
  margin-bottom: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--rsm-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.rockstar-lead-field input,
.rockstar-lead-field select {
  padding: 10px 12px;
  border: 1px solid var(--rsm-border);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--rsm-text);
  transition: border-color 160ms ease;
}
.rockstar-lead-field input:focus,
.rockstar-lead-field select:focus {
  outline: none;
  border-color: var(--rsm-teal);
  box-shadow: 0 0 0 3px rgba(32, 168, 154, 0.15);
}
.rockstar-lead-submit {
  margin-top: 12px;
  padding: 11px 18px;
  background: linear-gradient(135deg, var(--rsm-teal-light) 0%, var(--rsm-teal) 100%);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  align-self: flex-start;
  box-shadow: 0 6px 16px -6px rgba(32, 168, 154, 0.45);
  transition: transform 160ms ease;
}
.rockstar-lead-submit:hover {
  transform: translateY(-1px);
}
.rockstar-lead-thanks,
.rockstar-lead-error {
  margin-top: 20px;
  font-size: 0.9rem;
}

/* ── Quick start options (welcome screen) ── */
.rockstar-chat-quick-options {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.rockstar-chat-quick-option {
  padding: 8px 14px;
  background: linear-gradient(135deg, var(--rsm-teal-light) 0%, var(--rsm-teal) 100%);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  transition: transform 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 2px 8px rgba(32, 168, 154, 0.22);
}
.rockstar-chat-quick-option:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(32, 168, 154, 0.35);
}

/* ── Quickbar chips ── */
.rockstar-chat-quickbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 12px 8px;
}
.rockstar-chip {
  background: #ffffff;
  border: 1px solid var(--rsm-border);
  color: var(--rsm-text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}
.rockstar-chip:hover {
  background: var(--rsm-bg-subtle);
  border-color: rgba(32, 168, 154, 0.35);
  color: var(--rsm-teal-dark);
}

/* ── Action buttons (CTAs + phone) ── */
.rockstar-chat-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 12px 8px;
}
.rockstar-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 9px 16px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1;
  border: 1px solid transparent;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.rockstar-cta--primary {
  background: linear-gradient(135deg, var(--rsm-teal-light) 0%, var(--rsm-teal) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(32, 168, 154, 0.35);
}
.rockstar-cta--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(32, 168, 154, 0.50);
}
.rockstar-cta--ghost {
  background: transparent;
  border-color: var(--rsm-border);
  color: var(--rsm-text);
}
.rockstar-cta--ghost:hover {
  border-color: rgba(32, 168, 154, 0.45);
  color: var(--rsm-teal-dark);
}

/* ── Teacher cards (light theme) ── */
.rockstar-chat-cards {
  flex: 0 0 auto;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 12px 10px;
  scroll-snap-type: x proximity;
}
.rockstar-chat-cards::-webkit-scrollbar { height: 6px; }
.rockstar-chat-cards::-webkit-scrollbar-thumb {
  background: rgba(32, 168, 154, 0.25);
  border-radius: 6px;
}
.rockstar-chat-cards::-webkit-scrollbar-track { background: transparent; }

.rsm-card {
  background: var(--rsm-card);
  color: var(--rsm-text);
  border: 1px solid var(--rsm-border);
  border-radius: var(--rsm-radius);
  box-shadow: 0 2px 8px rgba(15, 26, 29, 0.06);
  padding: 16px;
  display: grid;
  grid-template-columns: 56px 1fr;
  grid-template-areas:
    "avatar header"
    "avatar tags"
    "actions actions";
  gap: 8px 14px;
  min-width: 280px;
  max-width: 340px;
  scroll-snap-align: start;
  opacity: 0;
  transform: translateY(8px);
  transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 280ms cubic-bezier(0.16, 1, 0.3, 1),
              border-color 200ms ease,
              opacity 200ms ease;
}
.rsm-card.rsm-in {
  opacity: 1;
  transform: none;
}
.rsm-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -10px rgba(15, 26, 29, 0.14);
  border-color: rgba(32, 168, 154, 0.30);
}

.rsm-avatar {
  grid-area: avatar;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--rsm-bg-subtle);
  border: 3px solid var(--rsm-teal-light);
  text-decoration: none;
  box-shadow: 0 4px 10px -4px rgba(32, 168, 154, 0.30);
}
.rsm-avatar__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.rsm-avatar__initials {
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--rsm-teal-dark);
  font-size: 16px;
  text-transform: uppercase;
}

.rsm-card__header {
  grid-area: header;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.rsm-card__name {
  color: var(--rsm-text);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
  text-decoration: none;
  display: inline-block;
  max-width: 100%;
}
.rsm-card__name:hover {
  color: var(--rsm-teal-dark);
}
.rsm-card__sub {
  margin-top: 2px;
  color: var(--rsm-text-secondary);
  font-size: 0.78rem;
}

.rsm-card__tags {
  grid-area: tags;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.rsm-chip {
  background: var(--rsm-chip-bg);
  border: 1px solid var(--rsm-chip-border);
  color: var(--rsm-text-secondary);
  font-size: 0.72rem;
  line-height: 18px;
  padding: 0 8px;
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 500;
}

.rsm-card__actions {
  grid-area: actions;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
}
.rsm-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.rsm-btn:active {
  transform: translateY(1px);
}
.rsm-btn--primary {
  background: linear-gradient(135deg, var(--rsm-teal-light) 0%, var(--rsm-teal) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(32, 168, 154, 0.35);
}
.rsm-btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(32, 168, 154, 0.50);
}
.rsm-btn--ghost {
  background: transparent;
  color: var(--rsm-text);
  border-color: var(--rsm-border);
}
.rsm-btn--ghost:hover {
  border-color: rgba(32, 168, 154, 0.45);
  color: var(--rsm-teal-dark);
}

.rsm-card__meta {
  grid-column: 1 / -1;
  margin-top: 4px;
  color: var(--rsm-text-secondary);
  font-size: 0.78rem;
}
.rsm-meta-line {
  margin-top: 3px;
}
.rsm-meta-line strong {
  color: var(--rsm-text);
  font-weight: 600;
}

/* ── Responsive ── */
@media (max-width: 420px) {
  #rockstar-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }
  /* Keep input visible above mobile keyboard */
  #rockstar-chat-panel .rockstar-chat-body {
    height: 100%;
    max-height: none;
  }
  #rockstar-chat-panel .rockstar-chat-input-area {
    position: sticky;
    bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 8px);
    background: #ffffff;
    z-index: 2;
  }
  .rsm-card {
    min-width: 260px;
    grid-template-columns: 48px 1fr;
    grid-template-areas:
      "avatar header"
      "tags tags"
      "actions actions";
  }
  .rsm-avatar { width: 48px; height: 48px; }
  /* Hide launcher when chat is open on mobile */
  #rockstar-chat-panel.open ~ #rockstar-chat-launcher {
    display: none;
  }
}

/* ── Layout improvements (V2.2 compat) ── */
#rockstar-chat-panel .rockstar-chat-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#rockstar-chat-panel .rockstar-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-bottom: 8px;
}
#rockstar-chat-panel .rockstar-chat-input-area {
  margin-top: 0;
  flex: 0 0 auto;
}
