/* Global Support Chat — Messenger-style floating widget (storefront blues/neutrals, RTL logical) */
.aw-sc {
  --aw-sc-accent: #1d4ed8;
  --aw-sc-accent-soft: #eff6ff;
  --aw-sc-surface: #ffffff;
  --aw-sc-ink: #0f172a;
  --aw-sc-muted: #64748b;
  --aw-sc-border: #e2e8f0;
  --aw-sc-danger: #b91c1c;
  --aw-sc-danger-bg: #fef2f2;
  --aw-sc-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
  --aw-sc-radius: 1.15rem;
  --aw-sc-z: 950;
  /* Chat bubble tokens (messages no longer sit under .aw-chat-panel) */
  --aw-chat-accent: var(--primary, var(--accent, var(--aw-sc-accent)));
  --aw-chat-surface: #fff;
  --aw-chat-muted: var(--aw-sc-muted);
  --aw-chat-border: color-mix(in srgb, var(--aw-sc-border) 90%, transparent);
  position: relative;
  z-index: var(--aw-sc-z);
  font-family: var(--font-body, 'Inter', 'Noto Sans Arabic', system-ui, sans-serif);
  color: var(--aw-sc-ink);
}

.aw-sc-launcher {
  position: fixed;
  bottom: var(--aw-float-chat-bottom, 92px);
  inset-inline-end: var(--aw-float-inline-end, 24px);
  z-index: calc(var(--aw-sc-z) + 1);
  width: var(--aw-float-chat-size, 56px);
  height: var(--aw-float-chat-size, 56px);
  border: 0;
  border-radius: 50%;
  background: linear-gradient(160deg, #2563eb, #1e40af);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.aw-sc-launcher:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.42);
}

.aw-sc-launcher.is-loading {
  pointer-events: none;
  cursor: wait;
}

.aw-sc-launcher.is-loading .aw-sc-launcher-icon--open,
.aw-sc-launcher.is-loading .aw-sc-launcher-icon--close {
  opacity: 0;
}

.aw-sc-launcher.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1.35rem;
  height: 1.35rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: aw-sc-spin 0.7s linear infinite;
}

@keyframes aw-sc-spin {
  to { transform: rotate(360deg); }
}

.aw-sc-launcher:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 3px;
}

/* Author styles with display:flex|inline-flex override UA [hidden]{display:none}.
   Without this, the panel/loading/chat views stay visible despite the hidden attribute. */
.aw-sc [hidden],
.aw-sc-panel[hidden],
.aw-sc-loading[hidden],
.aw-sc-view[hidden],
.aw-sc-chat-view[hidden],
.aw-sc-alert[hidden],
.aw-sc-launcher-icon[hidden],
.aw-sc-badge[hidden],
.aw-sc-rating[hidden],
.aw-sc .aw-chat-composer[hidden],
.aw-sc .aw-chat-closed-banner[hidden],
.aw-sc .aw-chat-status-row > [hidden] {
  display: none !important;
}

.aw-sc-badge {
  position: absolute;
  top: -4px;
  inset-inline-end: -4px;
  min-width: 1.35rem;
  height: 1.35rem;
  padding-inline: 0.3rem;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.35rem;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}

.aw-sc-panel {
  position: fixed;
  bottom: var(--aw-sc-panel-bottom, 160px);
  inset-inline-end: var(--aw-float-inline-end, 24px);
  z-index: var(--aw-sc-z);
  width: min(380px, calc(100vw - 1.5rem));
  /* Prefer a comfortable chat size, but never exceed remaining viewport above the float stack */
  height: var(--aw-sc-panel-max-height, min(560px, calc(100dvh - 11rem)));
  max-height: var(--aw-sc-panel-max-height, min(560px, calc(100dvh - 11rem)));
  display: flex;
  flex-direction: column;
  background: var(--aw-sc-surface);
  color: var(--aw-sc-ink);
  border: 1px solid var(--aw-sc-border);
  border-radius: var(--aw-sc-radius);
  box-shadow: var(--aw-sc-shadow);
  overflow: hidden;
  transform-origin: bottom end;
  animation: aw-sc-pop 0.2s ease-out;
}

@keyframes aw-sc-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.aw-sc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 55%, #3b82f6 100%);
  color: #fff;
  flex: 0 0 auto;
}

.aw-sc-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
}

.aw-sc-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  opacity: 0.9;
}

.aw-sc-header-actions {
  display: inline-flex;
  gap: 0.25rem;
}

.aw-sc-icon-btn {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.aw-sc-icon-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}

.aw-sc-alert {
  margin: 0.65rem 0.85rem 0;
  padding: 0.55rem 0.75rem;
  border-radius: 0.65rem;
  background: var(--aw-sc-danger-bg);
  color: var(--aw-sc-danger);
  font-size: 0.82rem;
  border: 1px solid color-mix(in srgb, var(--aw-sc-danger) 20%, transparent);
  flex: 0 0 auto;
}

.aw-sc-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.aw-sc-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.85rem;
}

.aw-sc-chat-view {
  display: flex;
  flex-direction: column;
  padding-block-end: 0.5rem;
  overflow: hidden;
  min-height: 0;
  flex: 1 1 auto;
}

.aw-sc-chat-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  -webkit-overflow-scrolling: touch;
}

.aw-sc-chat-scroll > #awScNewRequestBtn {
  align-self: stretch;
  margin-block: 0.15rem 0.35rem;
}

.aw-sc-form {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.aw-sc-hint {
  margin: 0 0 0.35rem;
  color: var(--aw-sc-muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.aw-sc-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--aw-sc-muted);
  margin-block-start: 0.25rem;
}

.aw-sc-input,
.aw-sc-textarea,
.aw-sc-composer-input {
  width: 100%;
  border: 1px solid var(--aw-sc-border);
  border-radius: 0.65rem;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: inherit;
  background: #fff;
}

.aw-sc-textarea,
.aw-sc-composer-input {
  resize: vertical;
  min-height: 2.5rem;
}

.aw-sc-input:focus,
.aw-sc-textarea:focus,
.aw-sc-composer-input:focus {
  outline: 2px solid color-mix(in srgb, var(--aw-sc-accent) 35%, transparent);
  border-color: var(--aw-sc-accent);
}

.aw-sc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.aw-sc-btn--primary {
  background: var(--aw-sc-accent);
  color: #fff;
  margin-block-start: 0.45rem;
}

.aw-sc-btn--primary:hover {
  background: #1e40af;
}

.aw-sc-btn--ghost {
  background: transparent;
  border-color: var(--aw-sc-border);
  color: var(--aw-sc-ink);
}

.aw-sc-btn--sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  margin-block-start: 0;
}

.aw-sc-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.aw-sc-ticket-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-block-end: 0.55rem;
  flex: 0 0 auto;
}

.aw-sc-ticket-subject {
  font-weight: 700;
  font-size: 0.9rem;
}

.aw-sc-ticket-status {
  font-size: 0.75rem;
  color: var(--aw-sc-muted);
}

.aw-sc .aw-chat-messages {
  min-height: min(8rem, 30%);
  max-height: none;
  flex: 0 0 auto;
  overflow: visible;
  border-radius: 0.85rem;
}

.aw-sc .aw-chat-composer {
  flex: 0 0 auto;
  border-radius: 0.85rem;
  padding: 0.55rem;
  background: var(--aw-sc-accent-soft);
  border: 1px solid color-mix(in srgb, var(--aw-sc-accent) 12%, var(--aw-sc-border));
}

.aw-sc .aw-chat-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-block-start: 0.4rem;
}

.aw-sc-attach-label {
  width: 2.1rem;
  height: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.55rem;
  color: var(--aw-sc-accent);
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--aw-sc-border);
}

/* TEMP: attach UI hidden unless html.aw-chat-attachments-enabled (ChatSettings:AttachmentsEnabled). */
html:not(.aw-chat-attachments-enabled) .aw-sc-attach-label,
html:not(.aw-chat-attachments-enabled) #awScAttachInput,
html:not(.aw-chat-attachments-enabled) #awScPendingFiles {
  display: none !important;
}

.aw-sc-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 2rem 1rem;
  color: var(--aw-sc-muted);
  font-size: 0.9rem;
}

.aw-sc-spinner {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid #cbd5e1;
  border-top-color: var(--aw-sc-accent);
  border-radius: 50%;
  animation: aw-sc-spin 0.7s linear infinite;
}

@keyframes aw-sc-spin {
  to { transform: rotate(360deg); }
}

.aw-sc .visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 575.98px) {
  .aw-sc-launcher {
    bottom: var(--aw-float-chat-bottom, 82px);
    inset-inline-end: var(--aw-float-inline-end, 16px);
  }

  .aw-sc-panel {
    inset-inline: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    height: min(92dvh, 100%);
    max-height: min(92dvh, 100%);
    border-radius: 1rem 1rem 0 0;
    border-inline: 0;
    border-block-end: 0;
  }
}

[data-theme="dark"] .aw-sc {
  --aw-sc-surface: #0f172a;
  --aw-sc-ink: #e2e8f0;
  --aw-sc-muted: #94a3b8;
  --aw-sc-border: #334155;
  --aw-sc-accent-soft: #172554;
  --aw-sc-danger-bg: #450a0a;
}

[data-theme="dark"] .aw-sc-input,
[data-theme="dark"] .aw-sc-textarea,
[data-theme="dark"] .aw-sc-composer-input,
[data-theme="dark"] .aw-sc-attach-label {
  background: #1e293b;
  color: var(--aw-sc-ink);
  border-color: var(--aw-sc-border);
}

.aw-sc-closed-title {
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.aw-sc-closed-help {
  margin: 0;
  font-size: 0.88rem;
  color: var(--aw-sc-muted);
}

.aw-sc-rating {
  margin: 0;
  padding: 0.9rem 0.95rem;
  border: 1px solid var(--aw-sc-border);
  border-radius: 0.85rem;
  background: var(--aw-sc-accent-soft);
  flex: 0 0 auto;
}

.aw-sc-rating-prompt,
.aw-sc-rating-thanks {
  font-weight: 600;
  margin: 0 0 0.55rem;
}

.aw-sc-stars {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.35rem;
  font-size: 1.85rem;
  line-height: 1;
}

.aw-sc-star {
  border: 0;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  padding: 0.25rem;
  min-width: 2rem;
  min-height: 2rem;
}

.aw-sc-star.is-on {
  color: #f59e0b;
}

.aw-sc-star:disabled {
  cursor: default;
}

.aw-sc-star-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--aw-sc-muted);
  margin-bottom: 0.45rem;
}

.aw-sc-rating-comment {
  min-height: 5.5rem;
  resize: vertical;
}

.aw-sc-rating .aw-sc-btn {
  margin-top: 0.55rem;
  width: 100%;
}

.aw-sc-rating .aw-sc-btn[aria-busy="true"] {
  gap: 0.5rem;
}

.aw-sc-rating .aw-sc-btn .aw-sc-spinner {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
}

.aw-sc-rating-readonly {
  white-space: pre-wrap;
  font-size: 0.9rem;
}

.aw-sc .aw-chat-closed-banner {
  flex: 0 0 auto;
  margin: 0;
}
