/* LF Audio warranty portal — matches help.lf-audio.com theme */

:root {
  --color-bg: #ffffff;
  --color-text: #444444;
  --color-heading: #111111;
  --color-accent: #3357d8;
  --color-accent-light: #eef1fb;
  --color-border: #e5e7eb;
  --color-surface: #f9fafb;
  --color-surface-alt: #f1f3f7;
  --color-muted: #6b7280;
  --color-danger: #dc2626;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --font-family: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 820px;
}

[data-theme="dark"] {
  --color-bg: #1a1a2e;
  --color-text: #d1d5db;
  --color-heading: #f3f4f6;
  --color-accent: #6b8cff;
  --color-accent-light: #1e2a4a;
  --color-border: #2d2d44;
  --color-surface: #22223a;
  --color-surface-alt: #2a2a45;
  --color-muted: #9ca3af;
  --color-danger: #f87171;
  --color-success: #34d399;
  --color-warning: #f59e0b;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: light dark; }

body {
  font-family: var(--font-family);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--color-accent); text-decoration: underline; }
a:hover { color: var(--color-accent); text-decoration: none; }

/* --- Header (matches help center) --- */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-heading);
  font-weight: 600;
  font-size: 1.1rem;
  white-space: nowrap;
  text-decoration: none;
}
.logo-link:hover { text-decoration: none; color: var(--color-heading); }
.logo-img { height: 18px; width: auto; }
.logo-divider { color: var(--color-border); font-weight: 300; }
.logo-sub { color: var(--color-muted); font-weight: 400; }

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.theme-toggle:hover { border-color: var(--color-accent); color: var(--color-accent); }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.user-email {
  color: var(--color-muted);
  font-size: 0.875rem;
  white-space: nowrap;
}
.btn-small-ghost {
  padding: 0.4rem 0.9rem;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn-small-ghost:hover { border-color: var(--color-accent); color: var(--color-accent); }

/* --- Main content --- */
main.wrap {
  max-width: var(--max-width);
  margin: 2rem auto;
  padding: 0 1.5rem;
  flex: 1;
  width: 100%;
}

.sub-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}
.sub-nav a {
  padding: 0.6rem 1rem;
  color: var(--color-muted);
  text-decoration: none;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.sub-nav a:hover { color: var(--color-heading); }
.sub-nav a.active {
  color: var(--color-heading);
  border-bottom-color: var(--color-accent);
}

/* --- Cards --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
}
.card h2 {
  color: var(--color-heading);
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.card h3 {
  color: var(--color-heading);
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem 0;
}
.card p { margin: 0.5rem 0; }
.muted { color: var(--color-muted); }
.small { font-size: 0.85rem; }

/* --- Forms --- */
form label {
  display: block;
  margin: 1rem 0 0.4rem 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-muted);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
input[type="email"],
input[type="text"],
input[type="tel"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-accent);
}
textarea { resize: vertical; line-height: 1.5; }

.btn {
  display: inline-block;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary {
  background: var(--color-accent);
  color: #ffffff;
  margin-top: 1.25rem;
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-accent);
  filter: brightness(1.1);
  text-decoration: none;
  color: #ffffff;
}
.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  text-decoration: none;
}

.status {
  margin-top: 0.85rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.status-info {
  background: var(--color-accent-light);
  color: var(--color-accent);
  border-color: var(--color-accent);
}
.status-error {
  background: rgba(220, 38, 38, 0.08);
  color: var(--color-danger);
  border-color: var(--color-danger);
}
.status-success {
  background: rgba(22, 163, 74, 0.08);
  color: var(--color-success);
  border-color: var(--color-success);
}

/* --- Order picker --- */
.order-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}
.order-row {
  text-align: left;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.order-row:hover { border-color: var(--color-accent); }
.order-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
}
.order-row-head strong { color: var(--color-heading); }

.order-row-unlisted {
  border-style: dashed;
}
.order-row-unlisted:hover {
  border-style: solid;
}

.line-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.5rem;
  padding: 0.75rem 0.9rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.line-item-row {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--color-text);
  line-height: 1.4;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  margin: 0;
}
.line-item-row input[type="checkbox"] {
  margin-top: 0.2rem;
  width: auto;
  accent-color: var(--color-accent);
}

.return-tracking-block {
  margin-top: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--color-bg);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
}
.return-tracking-block label {
  text-transform: none;
  font-weight: 400;
  color: var(--color-muted);
  letter-spacing: 0;
  font-size: 0.85rem;
  margin: 0 0 0.5rem 0;
  display: block;
}
.return-tracking-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.return-tracking-row .rt-number {
  flex: 2 1 180px;
}
.return-tracking-row .rt-carrier {
  flex: 1 1 120px;
}
.return-tracking-row .rt-submit {
  flex: 0 0 auto;
  margin-top: 0;
}

.rma-id {
  font-family: ui-monospace, "JetBrains Mono", "Menlo", "Consolas", monospace;
  letter-spacing: 0.5px;
  color: var(--color-heading);
}

.shipping-block {
  margin-top: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: var(--color-accent-light);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.shipping-block .btn-inline {
  align-self: flex-start;
  margin-top: 0;
}

.message-thread { margin-top: 1.2rem; }
.message-thread h4 {
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 0.7rem;
  margin-bottom: 0.6rem;
  color: var(--color-muted);
}
.msg-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.msg {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
}
.msg-staff {
  background: var(--color-accent-light);
  border-color: rgba(51, 87, 216, 0.2);
  border-left: 3px solid var(--color-accent);
}
.msg-customer {
  background: var(--color-surface);
}
.msg-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.msg-meta strong {
  font-size: 0.85rem;
  color: var(--color-heading);
}
.msg-meta .muted {
  font-size: 0.75rem;
}
.msg-body {
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--color-text);
}
/* Quoted text toggle */
.msg-quoted {
  margin-top: 0.6rem;
}
.msg-quoted summary {
  font-size: 0.78rem;
  color: var(--color-muted);
  cursor: pointer;
  user-select: none;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: var(--color-surface-alt);
  display: inline-block;
  list-style: none;
}
.msg-quoted summary::-webkit-details-marker { display: none; }
.msg-quoted summary::before { content: "··· "; color: var(--color-muted); }
.msg-quoted[open] summary::before { content: "▾ "; }
.msg-quoted summary:hover { background: var(--color-border); }
.msg-quoted pre {
  margin: 0.5rem 0 0 0;
  padding: 0.6rem 0.8rem;
  background: var(--color-surface-alt);
  border-left: 2px solid var(--color-border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--color-muted);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
}
.msg-compose {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.msg-compose-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}
.msg-compose .msg-attach-label {
  cursor: pointer;
  user-select: none;
}

/* Image attachments inside a message card */
.msg-body .msg-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.msg-body .msg-image {
  display: block;
  width: 140px;
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  text-decoration: none;
}
.msg-body .msg-image img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
}

/* Staff impersonation banner (?staff=1 on continueUrl) — flag at the
   top so the operator knows they're not looking at their own account. */
.staff-impersonation-banner {
  background: #fef3c7;
  color: #78350f;
  border-bottom: 1px solid #fbbf24;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

/* When staff is impersonating, hide every write surface so they can't
   accidentally post as the customer. JS handlers also refuse the
   callables as a belt-and-braces. */
body.staff-impersonation .msg-compose,
body.staff-impersonation .rt-form,
body.staff-impersonation #form-card,
body.staff-impersonation button[type="submit"],
body.staff-impersonation .rt-submit,
body.staff-impersonation .msg-send,
body.staff-impersonation .msg-attach-label {
  display: none !important;
}

/* Staged thumbnails in the compose area before send */
.msg-staged {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.msg-staged:empty { display: none; }
.msg-staged-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.msg-staged-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.msg-staged-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.msg-body .msg-image-loading,
.msg-body .msg-image-failed {
  padding: 0.75rem 1rem;
  background: #f2f2f2;
  color: #666;
  font-size: 0.85rem;
  border-radius: 8px;
  margin-top: 0.5rem;
}
.msg-body .msg-image-failed {
  background: #fbeaea;
  color: #b23a3a;
}

/* --- Request list (status page) --- */
.request-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}
.status-pill {
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--color-surface-alt);
  color: var(--color-text);
  white-space: nowrap;
}
.status-pill.status-submitted { background: var(--color-accent-light); color: var(--color-accent); }
.status-pill.status-awaiting_unit { background: rgba(217, 119, 6, 0.12); color: var(--color-warning); }
.status-pill.status-received { background: var(--color-accent-light); color: var(--color-accent); }
.status-pill.status-resolved { background: rgba(22, 163, 74, 0.12); color: var(--color-success); }
.status-pill.status-denied { background: rgba(220, 38, 38, 0.12); color: var(--color-danger); }

details { margin-top: 0.75rem; font-size: 0.9rem; }
details summary { cursor: pointer; color: var(--color-muted); }
details summary:hover { color: var(--color-heading); }
.history-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0 0;
}
.history-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.88rem;
}
.history-list li:last-child { border-bottom: none; }

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  margin-top: 3rem;
  padding: 1.25rem 1.5rem;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  color: var(--color-muted);
  font-size: 0.85rem;
}
.site-footer a { color: var(--color-muted); text-decoration: none; }
.site-footer a:hover { color: var(--color-accent); }

@media (max-width: 600px) {
  .header-inner { padding: 0.65rem 1rem; }
  .user-email { display: none; }
  main.wrap { margin: 1rem auto; padding: 0 1rem; }
  .card { padding: 1.25rem; }
  .logo-sub { display: none; }
  .logo-divider { display: none; }
}
