/* Shared customer/admin ticket conversation; no global form overrides. */
.ticket-thread-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .75rem;
  margin: 0 0 1rem;
}
.ticket-conversation {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  min-width: 0;
  max-height: min(52vh, 32rem);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: .5rem .25rem;
}
.ticket-message {
  flex: 0 0 auto;
  min-width: 0;
  max-width: 96%;
  padding: .8rem 1rem;
  border: 1px solid var(--account-border, #cbd5e1);
  border-radius: 1rem;
  background: var(--account-bg, #f8fafc);
  color: var(--account-text, #0f172a);
}
.ticket-message-customer { align-self: flex-end; }
.ticket-message-admin {
  align-self: flex-start;
  background: #edf8ff;
  border-color: #bae6fd;
}
.ticket-message-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .4rem 1rem;
  font-size: .75rem;
}
.ticket-message-meta time { color: var(--account-muted, #64748b); font-size: .7rem; }
.ticket-message p {
  margin: .5rem 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: .875rem;
  line-height: 1.65;
}
.ticket-original-image { max-width: 100%; max-height: 12rem; border-radius: .7rem; margin: .75rem 0; }
.ticket-reply-composer { display: grid; gap: .6rem; margin-top: 1rem; }
.ticket-reply-composer label { font-size: .875rem; font-weight: 700; }
.ticket-reply-composer textarea {
  width: 100%;
  min-height: 6rem;
  max-height: 16rem;
  resize: vertical;
  padding: .75rem;
  border: 1px solid var(--account-border, #cbd5e1);
  border-radius: .75rem;
  background: var(--account-bg, #fff);
  color: var(--account-text, #0f172a);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
}
.ticket-reply-composer textarea:focus { outline: 2px solid #10b981; outline-offset: 2px; }
.ticket-reply-composer p { margin: 0; font-size: .8rem; line-height: 1.5; }
.ticket-reply-composer button[type="submit"] {
  justify-self: end;
  min-height: 2.75rem;
  padding: .65rem 1.25rem;
  border-radius: .75rem;
  background: #047857;
  color: white;
  font-weight: 700;
}
.ticket-reply-composer button:disabled { opacity: .55; cursor: wait; }
.ticket-reply-feedback:not(:empty) { color: var(--account-muted, #475569); }
html.dark .ticket-message { color: #e2e8f0; background: #111c2e; border-color: #334155; }
html.dark .ticket-message-admin { background: #0c2a3d; border-color: #155e75; }
html.dark .ticket-message-meta time { color: #94a3b8; }
#admin-reply-ticket-modal .ticket-message { color: #e2e8f0; background: #111c2e; border-color: #334155; }
#admin-reply-ticket-modal .ticket-message-admin { background: #0c2a3d; border-color: #155e75; }
#admin-reply-ticket-modal .ticket-message-meta time { color: #94a3b8; }
#admin-reply-ticket-modal .ticket-message-admin { align-self: flex-end; }
#admin-reply-ticket-modal .ticket-message-customer { align-self: flex-start; }
#admin-reply-ticket-modal .ticket-admin-image-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  margin-top: .5rem;
  color: #94a3b8;
  font-size: 11px;
}
#admin-reply-ticket-modal .ticket-admin-attach-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  border: 1px solid #475569;
  border-radius: .65rem;
  color: #e2e8f0;
  background: #111c2e;
  font-size: 12px;
}
#admin-reply-ticket-modal .ticket-admin-attach-button svg,
#admin-reply-ticket-modal #admin-ticket-remove-image svg { width: 18px; height: 18px; }
#admin-reply-ticket-modal .ticket-admin-image-preview {
  display: flex;
  align-items: center;
  gap: .65rem;
  min-width: 0;
  margin-top: .6rem;
  padding: .6rem;
  border: 1px solid #334155;
  border-radius: .75rem;
  background: #111c2e;
}
#admin-reply-ticket-modal .ticket-admin-image-preview[hidden] { display: none; }
#admin-reply-ticket-modal .ticket-admin-image-preview img {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  object-fit: contain;
  border-radius: .5rem;
}
#admin-reply-ticket-modal #admin-ticket-image-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  color: #cbd5e1;
  font-size: 12px;
}
#admin-reply-ticket-modal #admin-ticket-remove-image {
  display: grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid #475569;
  border-radius: .5rem;
  color: #e2e8f0;
}
#admin-reply-ticket-modal .ticket-admin-image-status { color: #94a3b8; font-size: 11px; }
#admin-reply-ticket-modal .ticket-admin-image-status:empty { display: none; }
#admin-reply-ticket-modal :is(.ticket-admin-attach-button, #admin-ticket-remove-image):disabled { opacity: .5; cursor: wait; }
#admin-reply-ticket-form { min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; }
#admin-reply-ticket-form > .ticket-conversation { max-height: none; overflow: visible; }
#admin-ticket-thread {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  max-height: 38vh;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 640px) {
  .ticket-message { max-width: 100%; padding: .65rem .75rem; }
  .ticket-conversation { max-height: 42dvh; }
  .ticket-reply-composer button[type="submit"] { width: 100%; }
  #admin-reply-note-input { font-size: 1rem; }
}

/* Customer conversation: one scrollable transcript and a persistent composer. */
.ticket-new-messages { flex: 0 0 auto; align-self: center; padding: 8px 16px; border-radius: 999px; background: #047857; color: white; font-size: 12px; }
.ticket-new-messages[hidden] { display: none; }
[data-ticket-live] { font-size: 11px; color: #64748b; }
html.dark [data-ticket-live] { color: #a5b4c8; }
#account-center-modal.ticket-chat-active {
  --ticket-surface: #fff;
  --ticket-canvas: #fff;
  --ticket-admin-bubble: #f1f5f9;
  --ticket-divider: #e2e8f0;
  --ticket-ink: #0f172a;
  --ticket-muted: #64748b;
}
#account-center-modal.ticket-mobile-active {
  inset: auto 0;
  top: var(--ticket-viewport-top, 0px);
  height: var(--ticket-viewport-height, 100dvh);
  padding: 0;
  place-items: stretch;
  background: var(--ticket-canvas);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body #account-center-modal.account-center-overlay.ticket-mobile-active:not(.hidden) { z-index: 160; }
html:has(#account-center-modal.ticket-mobile-active:not(.hidden)),
body:has(#account-center-modal.ticket-mobile-active:not(.hidden)) { overflow: hidden !important; }
html.dark #account-center-modal.ticket-chat-active {
  --ticket-surface: #0f172a;
  --ticket-canvas: #0f172a;
  --ticket-admin-bubble: #233247;
  --ticket-divider: #2a3b52;
  --ticket-ink: #f1f5f9;
  --ticket-muted: #a5b4c8;
}
#account-center-modal.ticket-mobile-active .account-center-shell {
  width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0; box-shadow: none;
}
#account-center-modal.ticket-mobile-active .account-center-header,
#account-center-modal.ticket-mobile-active .account-center-navigation { display: none; }
#account-center-modal.ticket-mobile-active .account-center-workspace {
  display: flex; flex: 1; min-height: 0; overflow: hidden;
}
#account-center-modal.ticket-chat-active .account-center-content {
  display: flex; flex: 1; min-height: 0; padding: 0; overflow: hidden; background: var(--ticket-canvas);
}
.ticket-mobile-chat {
  display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0;
  color: var(--ticket-ink); font-family: var(--font-sans, 'Prompt', sans-serif);
}
.ticket-chat-header {
  display: flex; flex: 0 0 auto; align-items: center; gap: 8px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 12px;
  border-bottom: 1px solid var(--ticket-divider); background: var(--ticket-surface);
}
.ticket-chat-icon-button {
  display: grid; flex: 0 0 44px; width: 44px; height: 44px; place-items: center;
  border: 0; border-radius: 12px; color: var(--ticket-ink); background: transparent;
}
.ticket-chat-icon-button:hover { background: var(--ticket-admin-bubble); }
.ticket-chat-icon-button svg { width: 24px; height: 24px; stroke-width: 1.8; }
.ticket-chat-brand { flex: 0 0 40px; }
.ticket-chat-brand img { display: block; width: 40px; height: 40px; object-fit: contain; }
.ticket-chat-heading { flex: 1; min-width: 0; }
.ticket-chat-heading h3 { margin: 0; font-size: 18px; line-height: 1.5; font-weight: 700; }
.ticket-chat-heading p { margin: 2px 0 0; overflow-wrap: anywhere; color: var(--ticket-muted); font-size: 11px; }
.ticket-chat-summary {
  display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--ticket-divider);
}
.ticket-chat-summary h4 { margin: 0; min-width: 0; flex: 1 1 140px; overflow-wrap: anywhere; font-size: 14px; font-weight: 600; }
.ticket-chat-status { max-width: 100%; padding: 4px 10px; border: 1px solid #f59e0b; border-radius: 999px; color: #92400e; font-size: 11px; line-height: 1.5; }
.ticket-chat-status.is-resolved { border-color: #059669; color: #047857; }
html.dark .ticket-chat-status { color: #fbbf24; border-color: #a16207; }
html.dark .ticket-chat-status.is-resolved { color: #6ee7b7; border-color: #047857; }
.ticket-chat-messages {
  flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch; overflow-anchor: none; padding: 16px;
  scroll-padding: 16px; outline-offset: -3px;
}
.ticket-chat-date { display: flex; align-items: center; gap: 14px; margin: 4px 0 24px; color: var(--ticket-muted); font-size: 12px; text-align: center; }
.ticket-chat-date::before, .ticket-chat-date::after { content: ''; flex: 1; height: 1px; background: var(--ticket-divider); }
.ticket-chat-message { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 20px; }
.ticket-chat-message.from-customer { justify-content: flex-end; }
.ticket-chat-avatar { flex: 0 0 28px; padding-top: 23px; }
.ticket-chat-avatar img { display: block; width: 28px; height: 28px; object-fit: contain; }
.ticket-chat-message-body { min-width: 0; max-width: 84%; }
.from-admin .ticket-chat-message-body { max-width: calc(100% - 48px); }
.ticket-chat-sender { display: block; margin: 0 0 5px; font-size: 11px; font-weight: 500; color: var(--ticket-muted); }
.from-customer .ticket-chat-sender, .ticket-chat-label {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
.ticket-chat-bubble { margin: 0; padding: 11px 14px; border-radius: 17px 17px 17px 4px; background: var(--ticket-admin-bubble); color: var(--ticket-ink); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.65; }
.from-customer .ticket-chat-bubble { border-radius: 17px 17px 4px 17px; background: #047857; color: #fff; }
html.dark .from-customer .ticket-chat-bubble { background: #047857; }
.ticket-chat-message time { display: block; margin-top: 5px; font-size: 11px; color: var(--ticket-muted); }
.from-customer time { text-align: right; }
.ticket-chat-older { display: block; min-height: 44px; margin: 0 auto 20px; padding: 8px 16px; border: 1px solid var(--ticket-divider); border-radius: 999px; color: var(--ticket-ink); font-size: 12px; }
.ticket-chat-attachment { display: block; width: fit-content; max-width: 100%; margin-bottom: 16px; }
.ticket-chat-attachment img { margin: 0; }
.ticket-chat-composer {
  flex: 0 0 auto; margin: 0; padding: 10px 16px max(12px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--ticket-divider); background: var(--ticket-surface);
}
.ticket-chat-hint { margin: 0 0 8px; color: var(--ticket-muted); font-size: 11px; line-height: 1.5; }
.ticket-chat-composer .ticket-reply-feedback { margin: 0 0 8px; max-height: 64px; overflow-y: auto; color: var(--ticket-muted); font-size: 12px; overflow-wrap: anywhere; }
.ticket-chat-composer .ticket-reply-feedback:empty { display: none; }
.ticket-chat-composer .ticket-reply-feedback.has-error { color: #be123c; }
html.dark .ticket-chat-composer .ticket-reply-feedback.has-error { color: #fda4af; }
.ticket-chat-compose-row { display: flex; align-items: flex-end; gap: 8px; }
.ticket-chat-compose-row textarea {
  display: block; flex: 1; width: 100%; min-width: 0; min-height: 48px; max-height: 128px;
  padding: 11px 14px; border: 1px solid var(--ticket-divider); border-radius: 24px;
  background: var(--ticket-surface); color: var(--ticket-ink); font: inherit; font-size: 16px; line-height: 24px;
  resize: none; overflow-y: auto;
}
.ticket-chat-compose-row textarea::placeholder { color: var(--ticket-muted); opacity: 1; }
html.dark .ticket-chat-compose-row textarea { background: #1b2b3f; }
.ticket-chat-compose-row button {
  display: grid; flex: 0 0 48px; width: 48px; height: 48px; place-items: center;
  border: 0; border-radius: 50%; background: #047857; color: white;
}
.ticket-chat-compose-row button:hover { background: #065f46; }
.ticket-chat-compose-row button svg { width: 23px; height: 23px; }
.ticket-mobile-chat button:disabled { opacity: .5; cursor: wait; }
.ticket-mobile-chat :is(button, textarea):focus-visible { outline: 2px solid #10b981; outline-offset: 2px; }
.ticket-chat-unavailable { flex: 0 0 auto; margin: 0; padding: 16px; border-top: 1px solid var(--ticket-divider); color: var(--ticket-muted); font-size: 14px; }
@media (max-height: 500px) {
  .ticket-chat-header { padding-top: max(6px, env(safe-area-inset-top, 0px)); padding-bottom: 6px; }
  .ticket-chat-summary { padding-top: 6px; padding-bottom: 6px; }
  .ticket-chat-composer { padding-top: 6px; }
  .ticket-chat-hint { display: none; }
  .ticket-chat-compose-row textarea { max-height: 72px; }
}

/* Desktop uses the same transcript/composer as mobile, inside the account shell. */
#account-center-modal.ticket-chat-active .account-center-workspace { overflow: hidden; }
#account-center-modal.ticket-chat-active:not(.ticket-mobile-active) .account-center-header {
  flex: 0 0 auto; min-height: 76px; padding-block: 10px;
}
#account-center-modal.ticket-chat-active:not(.ticket-mobile-active) .ticket-chat-header { padding: 10px 16px; }
#account-center-modal.ticket-chat-active:not(.ticket-mobile-active) .ticket-chat-summary { padding: 8px 20px; }
#account-center-modal.ticket-chat-active:not(.ticket-mobile-active) .ticket-chat-messages { padding: 16px 24px; }
#account-center-modal.ticket-chat-active:not(.ticket-mobile-active) .ticket-chat-message-body { max-width: 78%; }
#account-center-modal.ticket-chat-active:not(.ticket-mobile-active) .ticket-chat-message { margin-bottom: 14px; }
#account-center-modal.ticket-chat-active:not(.ticket-mobile-active) .ticket-chat-composer { padding: 10px 20px 14px; }
#account-center-modal.ticket-chat-active:not(.ticket-mobile-active) .ticket-chat-compose-row button {
  display: flex; flex-basis: auto; width: auto; gap: 8px; padding: 0 20px; border-radius: 16px;
}
.ticket-chat-send-label { font-size: 14px; font-weight: 600; }
.ticket-mobile-active .ticket-chat-send-label { display: none; }

#account-center-modal.ticket-chat-active .ticket-chat-compose-row button.ticket-chat-attach {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--ticket-divider);
  border-radius: 14px;
  background: var(--ticket-surface);
  color: var(--ticket-ink);
}
.ticket-chat-image-preview {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid var(--ticket-divider);
  border-radius: 12px;
}
.ticket-chat-image-preview img {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: contain;
}
.ticket-chat-image-preview span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--ticket-muted);
}
.ticket-chat-image-preview button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: var(--ticket-admin-bubble);
  color: var(--ticket-ink);
}
.ticket-chat-image-preview button svg { width: 20px; height: 20px; }
