/* ──────────────────────────────────────────────────────────────────
   Your School Compass — chat widget styles
   ──────────────────────────────────────────────────────────────────
   Matches the Quiet Authority brand: cream + ink, serif type,
   8px black accent bar on the left edge of the open panel.
   ────────────────────────────────────────────────────────────────── */

:root {
  --ysc-chat-bg:    #FAFAF7;   /* paper cream */
  --ysc-chat-ink:   #000000;   /* true black */
  --ysc-chat-gray:  #6E6C69;   /* secondary */
  --ysc-chat-soft:  #5F5D5A;   /* body soft */
  --ysc-chat-rule:  #B4B2AC;   /* hairline */
  --ysc-chat-serif: 'Playfair Display', 'CrimsonPro', Georgia, serif;
  --ysc-chat-sans:  'Inter', 'InstrumentSans', system-ui, sans-serif;
}

/* ── Trigger (resting state) ────────────────────────────────── */
.ysc-chat-trigger {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px 8px 18px;
  background: var(--ysc-chat-bg);
  border: 1px solid var(--ysc-chat-rule);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--ysc-chat-serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ysc-chat-gray);
  transition: color 180ms ease, border-color 180ms ease, transform 180ms ease;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.ysc-chat-trigger:hover {
  color: var(--ysc-chat-ink);
  border-color: var(--ysc-chat-ink);
  transform: translateY(-1px);
}
.ysc-chat-trigger img {
  width: 28px;
  height: 28px;
  display: block;
}
.ysc-chat-trigger.is-open { display: none; }

/* ── Panel (open state) ─────────────────────────────────────── */
.ysc-chat-panel {
  position: fixed;
  top: 20px;
  right: 20px;
  bottom: 20px;
  width: 440px;
  max-width: calc(100vw - 40px);
  z-index: 9999;
  display: none;
  flex-direction: column;
  background: var(--ysc-chat-bg);
  border-radius: 8px;
  /* The black accent bar on the left edge — the signature detail */
  border-left: 8px solid var(--ysc-chat-ink);
  box-shadow: 0 8px 32px rgba(0,0,0,0.16);
  font-family: var(--ysc-chat-serif);
  overflow: hidden;
}
.ysc-chat-panel.is-open {
  display: flex;
}

/* ── Header ─────────────────────────────────────────────────── */
.ysc-chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--ysc-chat-rule);
}
.ysc-chat-header img {
  width: 32px;
  height: 32px;
}
.ysc-chat-header h2 {
  flex: 1;
  margin: 0;
  font-family: var(--ysc-chat-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 24px;
  color: var(--ysc-chat-ink);
  line-height: 1.2;
}
.ysc-chat-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  font-family: var(--ysc-chat-sans);
  font-size: 24px;
  color: var(--ysc-chat-gray);
  cursor: pointer;
  border-radius: 4px;
  transition: color 120ms ease, background 120ms ease;
}
.ysc-chat-close:hover {
  color: var(--ysc-chat-ink);
  background: rgba(0,0,0,0.04);
}

/* ── Messages ───────────────────────────────────────────────── */
.ysc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.ysc-chat-message {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ysc-chat-message-label {
  font-family: var(--ysc-chat-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--ysc-chat-gray);
  text-transform: uppercase;
}
.ysc-chat-message.is-user .ysc-chat-message-label {
  text-align: right;
}
.ysc-chat-message.is-user .ysc-chat-message-body {
  /* Constrain user messages so long ones don't span the full panel.
     Block aligns to the right; text inside reads naturally left-to-right. */
  max-width: 80%;
  margin-left: auto;
  padding: 10px 14px;
  background: var(--ysc-chat-bg);
  border: 1px solid var(--ysc-chat-rule);
  border-radius: 6px;
  text-align: left;
}
.ysc-chat-message-body {
  font-family: var(--ysc-chat-serif);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ysc-chat-ink);
}
.ysc-chat-message-body p {
  margin: 0 0 12px 0;
}
.ysc-chat-message-body p:last-child {
  margin-bottom: 0;
}
.ysc-chat-message-body a {
  color: var(--ysc-chat-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--ysc-chat-rule);
}
.ysc-chat-message-body a:hover {
  text-decoration-color: var(--ysc-chat-ink);
}

/* ── Typing indicator ───────────────────────────────────────── */
.ysc-chat-typing {
  font-family: var(--ysc-chat-serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ysc-chat-gray);
  padding: 4px 0;
}
.ysc-chat-typing::after {
  content: '...';
  display: inline-block;
  animation: ysc-dots 1.4s infinite;
}
@keyframes ysc-dots {
  0%, 20%   { opacity: 0.2; }
  50%       { opacity: 1; }
  80%, 100% { opacity: 0.2; }
}

/* ── Input ──────────────────────────────────────────────────── */
.ysc-chat-input-wrap {
  display: flex;
  align-items: flex-end;   /* send button stays anchored to bottom as textarea grows */
  gap: 8px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--ysc-chat-rule);
}
.ysc-chat-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--ysc-chat-serif);
  font-style: italic;
  font-size: 17px;
  color: var(--ysc-chat-ink);
  padding: 8px 0;
  /* Textarea-specific: kill the manual resize handle, allow soft wrap,
     auto-grow up to ~5 lines, then scroll inside. */
  resize: none;
  line-height: 1.5;
  max-height: 140px;
  overflow-y: auto;
  width: 100%;
  display: block;
  box-sizing: border-box;
}
.ysc-chat-input::placeholder {
  color: var(--ysc-chat-gray);
}
.ysc-chat-send {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--ysc-chat-ink);
  font-size: 18px;
  border-radius: 4px;
  transition: background 120ms ease;
}
.ysc-chat-send:hover {
  background: rgba(0,0,0,0.04);
}
.ysc-chat-send:disabled {
  color: var(--ysc-chat-gray);
  cursor: not-allowed;
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .ysc-chat-panel {
    top: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    border-radius: 0;
    border-left: 6px solid var(--ysc-chat-ink);
  }
  .ysc-chat-trigger {
    font-size: 14px;
    padding: 6px 12px 6px 14px;
  }
  .ysc-chat-trigger img { width: 24px; height: 24px; }
}
