/* Butterchat support portal — styled to match the Butterchat marketing site
   (try.studiobutterfly.io): neutral black / near-white monochrome system,
   Inter body + Archivo display + Instrument Serif accent italic, class-based
   dark mode. Tokens mirror the site's globals.css so the two feel like one
   product. */

/* ---- tokens: clean neutral monochrome (black / near-white / grays) ---- */
:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --muted: oklch(0.985 0 0);
  --muted-foreground: oklch(0.47 0 0);
  --border: oklch(0.915 0 0);
  --input: oklch(0.915 0 0);
  --ring: oklch(0.145 0 0);
  --primary: oklch(0.145 0 0);
  --primary-foreground: oklch(0.99 0 0);
  --danger: oklch(0.55 0.21 27);

  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;

  --font-sans: var(--font-inter), ui-sans-serif, system-ui, -apple-system,
    "Segoe UI", Roboto, Helvetica, Arial, "Kohinoor Bangla", "Nirmala UI",
    "Noto Sans Bengali", sans-serif;
  --font-display: var(--font-archivo), var(--font-inter), ui-sans-serif,
    system-ui, sans-serif;
  --font-accent: "Instrument Serif", Georgia, "Times New Roman", serif;

  --shadow-card: rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;
}

html.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.97 0 0);
  --card: oklch(0.185 0 0);
  --card-foreground: oklch(0.97 0 0);
  --muted: oklch(0.205 0 0);
  --muted-foreground: oklch(0.68 0 0);
  --border: oklch(1 0 0 / 11%);
  --input: oklch(1 0 0 / 14%);
  --ring: oklch(0.87 0 0);
  --primary: oklch(0.97 0 0);
  --primary-foreground: oklch(0.145 0 0);
  --danger: oklch(0.7 0.17 25);
  --shadow-card: rgba(0, 0, 0, 0.3) 0px 1px 2px 0px;
}

/* Font faces — Inter (body), Archivo (display), Instrument Serif (accent) are
   loaded from Google Fonts in the page <head>. These variables let the stacks
   above resolve before the webfonts land. */
:root {
  --font-inter: "Inter";
  --font-archivo: "Archivo";
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.accent {
  font-family: var(--font-accent);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
}

a { color: inherit; }

::selection {
  background: color-mix(in oklch, var(--foreground) 16%, transparent);
}

/* ---- header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklch, var(--background) 95%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
}
.site-header .inner {
  max-width: 1160px;
  margin: 0 auto;
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--foreground);
}
.brand img { height: 28px; width: auto; display: block; }
.brand .mark-dark { display: none; }
html.dark .brand .mark-light { display: none; }
html.dark .brand .mark-dark { display: block; }
.brand .word { font-size: 18px; }
.brand .tag {
  margin-left: 2px;
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
}
.header-actions { display: flex; align-items: center; gap: 6px; }

.ghost-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground);
  text-decoration: none;
  transition: background-color 0.15s ease;
}
.ghost-link:hover { background: var(--muted); }
@media (max-width: 520px) {
  .ghost-link .label { display: none; }
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.theme-toggle:hover { background: var(--muted); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
html.dark .theme-toggle .icon-sun { display: none; }
html.dark .theme-toggle .icon-moon { display: block; }

/* ---- layout ---- */
.wrap {
  flex: 1 0 auto;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 20px 72px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted-foreground);
  margin: 0 0 16px;
}

h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  margin: 0 0 10px;
}
.lede {
  color: var(--muted-foreground);
  font-size: 17px;
  margin: 0 0 28px;
  max-width: 48ch;
}

/* ---- cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-card);
  padding: 28px;
}
@media (max-width: 520px) { .card { padding: 20px; } }

/* ---- form ---- */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin: 18px 0 7px;
}
label:first-of-type { margin-top: 0; }
label .opt { color: var(--muted-foreground); font-weight: 400; }

input, textarea, select {
  width: 100%;
  padding: 11px 13px;
  background: var(--background);
  color: var(--foreground);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted-foreground); }
input:focus, textarea:focus, select:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 16%, transparent);
}
textarea { min-height: 150px; resize: vertical; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}

.row { display: flex; gap: 14px; }
.row > div { flex: 1; min-width: 0; }
@media (max-width: 520px) { .row { flex-direction: column; gap: 0; } }

/* ---- buttons (pill, matches buttonVariants) ---- */
button.primary {
  margin-top: 22px;
  width: 100%;
  padding: 0 24px;
  height: 52px;
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: opacity 0.15s ease, transform 0.1s ease;
}
button.primary:hover { opacity: 0.9; }
button.primary:active { transform: scale(0.98); }
button.primary:disabled { opacity: 0.5; cursor: default; }

.cf-turnstile { margin-top: 18px; }

.note { font-size: 13px; color: var(--muted-foreground); margin-top: 16px; }
.note a { color: var(--foreground); text-decoration: underline; text-underline-offset: 2px; }

/* ---- alerts ---- */
.alert {
  margin-top: 16px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  display: none;
}
/* An alert with no message never shows a bar, whatever classes it carries. */
.alert:empty { display: none !important; }
.alert.err {
  display: block;
  background: color-mix(in oklch, var(--danger) 12%, transparent);
  color: var(--danger);
  border: 1px solid color-mix(in oklch, var(--danger) 30%, transparent);
}

/* ---- success panel ---- */
.success { text-align: center; padding: 14px 6px; }
.success .check {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--foreground);
  color: var(--background);
  display: grid; place-items: center;
  margin: 4px auto 18px; font-size: 26px;
}

/* ---- ticket thread ---- */
.meta {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 10px 16px; color: var(--muted-foreground);
  font-size: 14px; margin-bottom: 22px;
}
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600; text-transform: capitalize;
  border: 1px solid var(--border); color: var(--foreground);
}
.pill::before {
  content: ""; width: 7px; height: 7px; border-radius: 999px;
  background: var(--muted-foreground);
}
.pill.OPEN::before { background: oklch(0.72 0.17 65); }
.pill.IN_PROGRESS::before { background: oklch(0.6 0.18 255); }
.pill.RESOLVED::before, .pill.CLOSED::before { background: oklch(0.6 0.16 150); }

.msg { margin: 16px 0; display: flex; }
.msg .bubble {
  max-width: 85%; padding: 12px 15px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--muted);
}
.msg.studio { justify-content: flex-start; }
.msg.me { justify-content: flex-end; }
.msg.me .bubble {
  background: var(--foreground); color: var(--background); border-color: transparent;
}
.msg.me .bubble .when { color: color-mix(in oklch, var(--background) 65%, transparent); }
.msg .who { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.email-tag {
  font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: #0369a1; border: 1px solid rgba(2, 132, 199, 0.4);
  border-radius: 999px; padding: 1px 6px; margin-left: 4px; vertical-align: middle;
}
/* thread message attachments — inline image previews + file cards */
.msg-atts { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
/* image grid */
.att-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 6px; max-width: 300px; }
.att-grid.single { display: block; }
.att-img {
  display: block; position: relative; overflow: hidden; border-radius: 12px;
  border: 1px solid var(--border); background: var(--muted); transition: opacity 0.15s ease;
}
.att-img { cursor: pointer; }
.att-img:hover { opacity: 0.9; }

/* image lightbox / viewer modal */
.lightbox {
  position: fixed; inset: 0; z-index: 1000; display: none;
  align-items: center; justify-content: center; padding: 24px; box-sizing: border-box;
  background: rgba(0, 0, 0, 0.82); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.lightbox.open { display: flex; animation: lb-fade 0.16s ease; }
@keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }
body.lb-lock { overflow: hidden; }
.lb-stage { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 100%; max-height: 100%; }
.lb-stage img {
  max-width: min(92vw, 1200px); max-height: 82vh; object-fit: contain;
  border-radius: 8px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55); background: #0b0b0b;
}
.lb-cap { color: rgba(255, 255, 255, 0.72); font-size: 13px; text-align: center; }
.lb-close, .lb-nav {
  position: fixed; border: none; cursor: pointer; color: #fff; line-height: 1;
  background: rgba(255, 255, 255, 0.13); display: grid; place-items: center;
  border-radius: 999px; transition: background-color 0.15s ease;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, 0.26); }
.lb-close { top: 16px; right: 18px; width: 40px; height: 40px; font-size: 26px; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 46px; height: 46px; font-size: 28px; }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }
@media (max-width: 560px) {
  .lb-nav { width: 40px; height: 40px; }
  .lb-prev { left: 8px; } .lb-next { right: 8px; }
}
.att-grid:not(.single) .att-img { aspect-ratio: 1; }
.att-grid:not(.single) .att-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-grid.single .att-img img { display: block; max-width: 300px; max-height: 320px; width: auto; height: auto; }
.att-img .att-img-name { display: none; }
/* broken image → show filename like a file card */
.att-img.broken { aspect-ratio: auto; padding: 9px 11px; background: var(--background); }
.att-img.broken img { display: none; }
.att-img.broken .att-img-name {
  display: inline-flex; align-items: center; gap: 7px; max-width: 220px;
  font-size: 12.5px; font-weight: 500; color: var(--foreground); text-decoration: none;
}
.att-img.broken .att-img-name svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--muted-foreground); }
.att-img.broken .att-img-name .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* non-image file cards */
.att-files { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; max-width: 100%; }
.att-file {
  display: inline-flex; align-items: center; gap: 10px; max-width: 320px; text-decoration: none;
  color: var(--foreground); background: var(--background); border: 1px solid var(--border);
  border-radius: 12px; padding: 9px 12px; transition: border-color 0.15s ease;
}
.att-file:hover { border-color: var(--foreground); }
.att-file > svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--muted-foreground); }
.att-file .att-file-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.att-file .name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file .size { font-size: 11px; color: var(--muted-foreground); }
.att-file .dl { margin-left: auto; padding-left: 10px; display: inline-flex; }
.att-file .dl svg { width: 16px; height: 16px; color: var(--muted-foreground); opacity: 0.7; }
/* inverted inside the customer (dark) bubble */
.msg.me .att-img { border-color: color-mix(in oklch, var(--background) 30%, transparent); }
.msg.me .att-file {
  background: color-mix(in oklch, var(--background) 14%, transparent);
  border-color: color-mix(in oklch, var(--background) 32%, transparent);
  color: var(--background);
}
.msg.me .att-file > svg, .msg.me .att-file .size, .msg.me .att-file .dl svg {
  color: color-mix(in oklch, var(--background) 70%, transparent);
}
.msg.me .att-file:hover { border-color: var(--background); }

/* pending reply upload chips */
.reply-files { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.reply-files:empty { margin: 0; }
.reply-files .chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 240px;
  font-size: 13px; font-weight: 500; color: var(--foreground);
  background: var(--muted); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px 7px 6px 10px;
}
.reply-files .chip.uploading { color: var(--muted-foreground); }
.reply-files .chip svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--muted-foreground); }
.reply-files .chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-files .chip .spin {
  width: 13px; height: 13px; flex-shrink: 0; border-radius: 999px;
  border: 2px solid color-mix(in oklch, var(--foreground) 22%, transparent);
  border-top-color: var(--foreground); animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.reply-files .chip button {
  display: grid; place-items: center; width: 18px; height: 18px; flex-shrink: 0;
  border: none; background: none; color: var(--muted-foreground); cursor: pointer;
  border-radius: 999px; font-size: 16px; line-height: 1; padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.reply-files .chip button:hover {
  background: color-mix(in oklch, var(--foreground) 10%, transparent); color: var(--foreground);
}
/* image preview chips in the composer */
.reply-files .chip.img {
  padding: 0; width: 54px; height: 54px; max-width: 54px; position: relative; overflow: hidden; border-radius: 10px;
}
.reply-files .chip.img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reply-files .chip.img .name { display: none; }
.reply-files .chip.img button {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; z-index: 3;
  background: color-mix(in oklch, var(--foreground) 72%, transparent); color: var(--background);
}
.reply-files .chip.img button:hover { background: var(--foreground); color: var(--background); }
.reply-files .chip.img.uploading::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: color-mix(in oklch, var(--background) 55%, transparent);
}
.reply-files .chip.img .spin { position: absolute; inset: 0; margin: auto; z-index: 2; }
/* attach button disabled at the file limit */
#attachBtn:disabled, #attachBtn.disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* reply action row — attach (ghost pill) + send (solid pill), same height */
.reply-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.reply-actions .primary { width: auto; margin-top: 0; height: 46px; padding: 0 22px; font-size: 15px; }
.attach-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 46px; padding: 0 16px;
  background: transparent; color: var(--muted-foreground); border: 1px solid var(--border);
  border-radius: 999px; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.attach-btn:hover { background: var(--muted); color: var(--foreground); border-color: var(--foreground); }
.attach-btn svg { width: 16px; height: 16px; }
.msg .body { white-space: pre-wrap; line-height: 1.55; }
.msg .when { font-size: 11px; color: var(--muted-foreground); margin-top: 5px; }

.loading, .empty { text-align: center; color: var(--muted-foreground); padding: 48px 0; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ---- footer ---- */
.site-footer {
  flex-shrink: 0;
  background: #000;
  color: #fff;
}
.site-footer .inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 40px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.site-footer .brand { color: #fff; }
.site-footer .brand .word { color: #fff; }
.site-footer .f-links {
  display: flex; flex-wrap: wrap; gap: 20px;
  list-style: none; margin: 0; padding: 0;
}
.site-footer .f-links a {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  text-decoration: none;
  transition: color 0.2s ease;
}
.site-footer .f-links a:hover { color: #fff; }
.site-footer .copy {
  width: 100%;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 20px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}
