/* ── Gorgias HIL widget ──
 * Extracted from the inline <style> in layouts/hil.html.erb and the inline
 * style= attributes of app/views/gorgias/hil/*. Everything is scoped to
 * .hil-card (the layout root) so nothing leaks to other pages.
 * Data-driven values (rating button + badge colours computed in Ruby) stay
 * inline in the Haml — they cannot live in a static stylesheet.
 */

/* ── Layout chrome (was the <style> block in layouts/hil.html.erb) ── */
body:has(.hil-card) * { box-sizing: border-box; margin: 0; padding: 0; }
body:has(.hil-card) { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; background: radial-gradient(900px 420px at 50% -120px, #dbf1fa 0%, rgba(219,241,250,0) 65%), linear-gradient(180deg, #f8fafc 0%, #eef4f8 100%); background-attachment: fixed; color: #1f2937; min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 44px 16px; }
.hil-card { background: #fff; border: 1px solid #e6eef4; border-radius: 18px; padding: 36px 42px; max-width: 640px; width: 100%; box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 16px 48px -16px rgba(8,145,178,.22); }
.hil-card .hil-header { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid #f3f4f6; }
.hil-card .hil-logo { font-size: 22px; }
.hil-card .hil-brand { font-weight: 700; font-size: 15px; background: linear-gradient(90deg, #0891b2, #6366f1); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hil-card .hil-action-title { font-size: 20px; font-weight: 800; letter-spacing: -0.015em; margin-bottom: 9px; }
.hil-card .hil-description { color: #6b7280; font-size: 13px; line-height: 1.6; margin-bottom: 24px; }
.hil-card .hil-preview { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 12px 14px; font-size: 13px; line-height: 1.6; color: #374151; margin-bottom: 18px; white-space: pre-wrap; }
.hil-card .hil-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px; }
.hil-card .hil-badge-green  { background: #d1fae5; color: #065f46; }
.hil-card .hil-badge-yellow { background: #fef3c7; color: #92400e; }
.hil-card .hil-badge-red    { background: #fee2e2; color: #991b1b; }
.hil-card .hil-badge-gray   { background: #f3f4f6; color: #374151; }
.hil-card .hil-meta { font-size: 11px; color: #9ca3af; margin-top: 26px; padding-top: 18px; border-top: 1px solid #f3f4f6; }
.hil-card .hil-meta code { background: #f3f4f6; padding: 1px 5px; border-radius: 3px; font-size: 10px; }
.hil-card .btn { display: inline-block; padding: 8px 18px; border-radius: 6px; font-weight: 600; font-size: 13px; text-decoration: none; cursor: pointer; border: none; }
.hil-card .btn-primary { background: #0891b2; color: #fff; }
.hil-card .btn-gray    { background: #e5e7eb; color: #374151; }
.hil-card .hil-note { background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 10px 14px; font-size: 12px; color: #92400e; margin-bottom: 14px; }

/* ── Shared view helpers ── */
.hil-card .hil-field-label { font-size: 12px; font-weight: 700; color: #374151; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.hil-card .hil-field-label--mb10 { margin-bottom: 10px; }
.hil-card .hil-badge--lg { font-size: 13px; padding: 4px 12px; }
.hil-card .hil-note--warn { border-color: #fcd34d; }
.hil-card .hil-error { background: #fee2e2; border: 1px solid #fca5a5; border-radius: 6px; padding: 8px 12px; font-size: 12px; color: #991b1b; margin-bottom: 12px; }
.hil-card .hil-hidden { display: none; }
.hil-card .hil-btn-row { display: flex; gap: 8px; }
.hil-card .hil-rate-option { flex: 1; cursor: pointer; }

/* ── refine ── */
.hil-card .hil-refine-textarea { width: 100%; padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 13px; background: #f9fafb; color: #9ca3af; resize: vertical; min-height: 80px; margin-bottom: 14px; font-family: inherit; cursor: not-allowed; }
.hil-card .hil-refine-disabled { cursor: default; opacity: 0.5; background: #7c3aed; color: #fff; }

/* ── chat (session history timeline) ── */
.hil-card .hil-chat-ticket { font-size: 13px; font-weight: 500; color: #6b7280; margin-left: 8px; }
.hil-card .hil-chat-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.hil-card .hil-chip { padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.hil-card .hil-chip--brand { background: #eff6ff; color: #1d4ed8; }
.hil-card .hil-chip--category { background: #f0fdf4; color: #15803d; }
.hil-card .hil-chip--language { background: #faf5ff; color: #7e22ce; }
.hil-card .hil-events { display: flex; flex-direction: column; gap: 10px; }
.hil-card .hil-event { padding: 10px 14px; border-radius: 0 6px 6px 0; }
.hil-card .hil-event--start { border-left: 3px solid #6b7280; background: #f9fafb; }
.hil-card .hil-event--text { border-left: 3px solid #0891b2; background: #f0f9ff; }
.hil-card .hil-event--result { border-left: 3px solid #16a34a; background: #f0fdf4; }
.hil-card .hil-event--error { border-left: 3px solid #ef4444; background: #fef2f2; }
.hil-card .hil-event-label { font-size: 10px; margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.hil-card .hil-event--start .hil-event-label { color: #9ca3af; }
.hil-card .hil-event--text .hil-event-label { color: #0e7490; }
.hil-card .hil-event--result .hil-event-label { color: #15803d; margin-bottom: 4px; }
.hil-card .hil-event--error .hil-event-label { color: #dc2626; margin-bottom: 4px; }
.hil-card .hil-event--start .hil-event-content { font-size: 12px; color: #374151; white-space: pre-wrap; line-height: 1.6; }
.hil-card .hil-event--text .hil-event-content { font-size: 13px; color: #1e293b; white-space: pre-wrap; line-height: 1.7; }
.hil-card .hil-event--result .hil-event-content { font-size: 11px; color: #16a34a; }
.hil-card .hil-event--error .hil-event-content { font-size: 12px; color: #b91c1c; }
.hil-card .hil-event-details { padding: 8px 14px; border-radius: 0 6px 6px 0; }
.hil-card .hil-event-details--tool { border-left: 3px solid #d1d5db; background: #f9fafb; }
.hil-card .hil-event-details--thinking { border-left: 3px solid #e9d5ff; background: #fdf4ff; }
.hil-card .hil-event-summary { font-size: 11px; cursor: pointer; font-weight: 600; }
.hil-card .hil-event-details--tool .hil-event-summary { color: #6b7280; }
.hil-card .hil-event-details--thinking .hil-event-summary { color: #7e22ce; }
.hil-card .hil-event-time { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.hil-card .hil-event-details--tool .hil-event-time { color: #9ca3af; }
.hil-card .hil-event-details--thinking .hil-event-time { color: #a855f7; }
.hil-card .hil-event-pre { margin-top: 8px; font-size: 11px; white-space: pre-wrap; }
.hil-card .hil-event-details--tool .hil-event-pre { color: #374151; background: #fff; border: 1px solid #e5e7eb; border-radius: 4px; padding: 8px 10px; font-family: monospace; overflow-x: auto; }
.hil-card .hil-event-details--thinking .hil-event-pre { color: #6b21a8; line-height: 1.6; }
.hil-card .hil-event-toolname { background: #e5e7eb; padding: 1px 5px; border-radius: 3px; font-size: 10px; }

/* ── rate (.rating-btn / .hil-rate-option names are referenced by inline JS) ── */
.hil-card .hil-rate-saved { text-align: center; padding: 14px 0 20px; }
.hil-card .hil-rate-emoji { font-size: 52px; margin-bottom: 10px; animation: hil-pop .45s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes hil-pop { 0% { transform: scale(.3) rotate(-12deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.hil-card .hil-rate-badge-wrap { margin-top: 8px; }
.hil-card .hil-rate-reason { font-size: 12px; color: #6b7280; margin-top: 12px; font-style: italic; max-width: 440px; margin-left: auto; margin-right: auto; line-height: 1.6; }
.hil-card .hil-rate-by { font-size: 11px; color: #9ca3af; margin-top: 6px; }
.hil-card .hil-rate-close-note { font-size: 12px; color: #9ca3af; text-align: center; margin-bottom: 16px; }
.hil-card .hil-rate-greeter { font-size: 14px; color: #374151; margin-bottom: 14px; }

/* rating tiles */
.hil-card .hil-rate-row { display: flex; gap: 12px; margin-bottom: 26px; }
.hil-card .rating-btn { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 18px 10px 14px; border-radius: 14px; border: 2px solid #e8edf2; background: #fbfdfe; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease; }
.hil-card .rating-btn-emoji { font-size: 28px; line-height: 1; transition: transform .18s ease; filter: grayscale(.25); }
.hil-card .rating-btn-label { font-size: 13px; font-weight: 700; color: #64748b; letter-spacing: .01em; transition: color .18s ease; }
.hil-card .hil-rate-option:hover .rating-btn { transform: translateY(-2px); border-color: #cbd5e1; box-shadow: 0 10px 24px -10px rgba(15,23,42,.22); }
.hil-card .hil-rate-option:hover .rating-btn-emoji { transform: scale(1.18); filter: none; }
.hil-card .hil-rate-option.is-selected .rating-btn { border-color: transparent; }
.hil-card .hil-rate-option.is-selected .rating-btn-emoji { filter: none; transform: scale(1.12); }
.hil-card .hil-rate-option.is-selected .rating-btn-label { color: #fff; }
.hil-card .hil-rate-option--good.is-selected .rating-btn { background: linear-gradient(140deg, #34d399, #059669); box-shadow: 0 12px 26px -10px rgba(5,150,105,.55); }
.hil-card .hil-rate-option--ok.is-selected  .rating-btn { background: linear-gradient(140deg, #fbbf24, #d97706); box-shadow: 0 12px 26px -10px rgba(217,119,6,.55); }
.hil-card .hil-rate-option--bad.is-selected .rating-btn { background: linear-gradient(140deg, #f87171, #dc2626); box-shadow: 0 12px 26px -10px rgba(220,38,38,.55); }

/* form fields */
.hil-card .hil-rate-reason-group { margin-bottom: 20px; }
.hil-card .hil-rate-reason-label { display: block; font-size: 12px; font-weight: 700; color: #334155; margin-bottom: 7px; }
.hil-card .hil-rate-reason-hint { font-weight: 400; color: #94a3b8; }
.hil-card .hil-rate-textarea { width: 100%; border: 1.5px solid #e2e8f0; border-radius: 10px; padding: 10px 13px; font-size: 13px; line-height: 1.6; resize: vertical; font-family: inherit; background: #fff; transition: border-color .15s ease, box-shadow .15s ease; }
.hil-card .hil-rate-name-input { flex: 1; width: 100%; border: 1.5px solid #e2e8f0; border-radius: 10px; padding: 10px 13px; font-size: 13px; font-family: inherit; background: #fff; transition: border-color .15s ease, box-shadow .15s ease; }
.hil-card .hil-rate-textarea:focus, .hil-card .hil-rate-name-input:focus { outline: none; border-color: #0891b2; box-shadow: 0 0 0 4px rgba(8,145,178,.12); }
.hil-card .hil-rate-submit { background: linear-gradient(135deg, #06b6d4, #0e7490); color: #fff; padding: 13px 20px; border-radius: 10px; font-weight: 700; font-size: 13px; letter-spacing: .01em; border: none; cursor: pointer; width: 100%; box-shadow: 0 8px 18px -8px rgba(8,145,178,.6); transition: transform .15s ease, box-shadow .15s ease, filter .15s ease; }
.hil-card .hil-rate-submit:hover { transform: translateY(-1px); box-shadow: 0 12px 24px -8px rgba(8,145,178,.65); filter: brightness(1.05); }
.hil-card .hil-rate-submit--inline { width: auto; padding: 10px 16px; white-space: nowrap; }

/* ── rate: reviewer identity (SSO preferred, or one-time name → cookie) ── */
.hil-card .hil-rate-identity { border: 1px solid transparent; border-radius: 14px; padding: 20px 22px; margin-bottom: 14px; background: linear-gradient(#fdfeff, #f3fafd) padding-box, linear-gradient(135deg, #7dd3fc, #0891b2 45%, #a5b4fc) border-box; }
.hil-card .hil-rate-identity-title { font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: #0e7490; margin-bottom: 12px; }
.hil-card .hil-rate-sso-btn { display: inline-flex; align-items: center; gap: 9px; background: #fff; color: #374151; border: 1.5px solid #dbe3ea; padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: 13px; text-decoration: none; box-shadow: 0 1px 2px rgba(15,23,42,.05); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.hil-card .hil-rate-sso-btn:hover { transform: translateY(-1px); border-color: #94a3b8; box-shadow: 0 8px 18px -8px rgba(15,23,42,.25); }
.hil-card .hil-rate-sso-btn--slim { padding: 7px 13px; font-size: 12px; border-radius: 8px; gap: 7px; }
.hil-card .hil-rate-sso-logo { flex: none; }
.hil-card .hil-rate-identity-divider { display: flex; align-items: center; gap: 12px; margin: 14px 0 10px; color: #94a3b8; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.hil-card .hil-rate-identity-divider::before, .hil-card .hil-rate-identity-divider::after { content: ""; flex: 1; height: 1px; background: #dbe6ee; }
.hil-card .hil-rate-identity-or { font-size: 12px; color: #64748b; margin-bottom: 9px; }
.hil-card .hil-rate-name-row { display: flex; gap: 8px; align-items: stretch; }
.hil-card .hil-rate-alt-hint { font-size: 12px; color: #94a3b8; margin-bottom: 22px; }

/* slim SSO offer (shown whenever there is no SSO session) */
.hil-card .hil-rate-sso-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: -8px 0 22px; }
.hil-card .hil-rate-sso-row--center { justify-content: center; margin: 0 0 18px; }
.hil-card .hil-rate-sso-note { font-size: 11px; color: #94a3b8; }

/* ── fire (.fire-rating-btn name is referenced by inline JS) ── */
.hil-card .hil-fire-ticket { font-size: 12px; color: #6b7280; margin-bottom: 14px; }
.hil-card .hil-fire-message { width: 100%; font-size: 13px; line-height: 1.6; resize: vertical; border: 1px solid #e5e7eb; border-radius: 6px; padding: 12px 14px; font-family: inherit; color: #1f2937; margin-bottom: 16px; }
.hil-card .hil-fire-disclosure-hint { font-size: 12px; color: #6b7280; background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 6px; padding: 7px 12px; margin: -8px 0 14px; }
.hil-card .hil-fire-checkbox-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.hil-card .hil-fire-checkbox-label { display: flex; align-items: center; gap: 7px; font-size: 13px; color: #374151; cursor: pointer; }
.hil-card .hil-fire-checkbox { width: 15px; height: 15px; accent-color: #0891b2; }
.hil-card .hil-fire-rate-section { border-top: 1px solid #e5e7eb; padding-top: 16px; margin-bottom: 20px; }
.hil-card .hil-fire-rated { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px 14px; }
.hil-card .hil-fire-rated-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.hil-card .hil-fire-rated-badge { color: #fff; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.hil-card .hil-fire-rated-tag { font-size: 11px; color: #9ca3af; }
.hil-card .hil-fire-rated-reason { font-size: 12px; color: #4b5563; font-style: italic; }
.hil-card .hil-fire-rated-by { font-size: 11px; color: #9ca3af; margin-top: 4px; }
.hil-card .hil-fire-rate-row { display: flex; gap: 10px; margin-bottom: 12px; }
.hil-card .fire-rating-btn { text-align: center; padding: 8px 6px; border-radius: 6px; font-size: 13px; font-weight: 600; transition: all .15s; }
.hil-card .hil-fire-reason { width: 100%; font-size: 12px; line-height: 1.5; resize: vertical; border: 1px solid #e5e7eb; border-radius: 6px; padding: 8px 10px; font-family: inherit; color: #374151; }
.hil-card .hil-fire-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.hil-card .hil-fire-sending { font-size: 12px; color: #9ca3af; }

/* ── lucas_opt_in (enable / disable) ── */
.hil-card .hil-optin-header { text-align: center; padding: 10px 0 18px; }
.hil-card .hil-optin-emoji { font-size: 36px; margin-bottom: 8px; }
.hil-card .hil-optin-ticket { font-size: 13px; color: #374151; margin-top: 8px; }
.hil-card .hil-description--mb16 { margin-bottom: 16px; }
.hil-card .hil-optin-beta { background: #fef9c3; border: 1px solid #fde047; border-radius: 6px; padding: 8px 12px; font-size: 12px; color: #713f12; margin-bottom: 16px; }
.hil-card .hil-optin-back-wrap { text-align: center; margin-bottom: 16px; }
.hil-card .hil-optin-back { font-size: 13px; padding: 8px 16px; text-decoration: none; }
.hil-card .hil-optin-footer { font-size: 12px; color: #9ca3af; text-align: center; }

/* ── BM-AI research details (collapsible, default closed) on Fire/Rate ── */
.hil-card .hil-research { margin-top: 28px; border-top: 1px solid #f3f4f6; padding-top: 22px; }
.hil-card .hil-research-summary {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: #6b7280;
  background: #f3f4f6; padding: 9px 16px; border-radius: 999px;
  cursor: pointer; list-style: none; user-select: none;
  transition: background .15s ease, color .15s ease;
}
.hil-card .hil-research-summary:hover { background: #e5e7eb; color: #374151; }
.hil-card .hil-research-summary::-webkit-details-marker { display: none; }
.hil-card .hil-research-summary::after { content: "▾"; font-size: 10px; color: #9ca3af; transition: transform .15s ease; }
.hil-card details[open] .hil-research-summary { background: #e0f2fe; color: #0e7490; }
.hil-card details[open] .hil-research-summary::after { transform: rotate(180deg); color: #0891b2; }
.hil-card .hil-research-summary:focus { outline: none; }
.hil-card .hil-research-summary:focus-visible { box-shadow: 0 0 0 3px rgba(8,145,178,.18); }
.hil-card .hil-research-body { margin-top: 20px; }
