/* =========================================================
   Exemplar Services — Chat Widget
   
   =========================================================
   To retheme: edit the :root block only.
   Do not edit below the COMPONENT STYLES marker.
   ========================================================= */

/* ── EXEMPLAR BRAND TOKENS ─────────────────────────────── */
:root {
  /* Brand Colours */
  --ac-primary:        #33495E;   /* Exemplar Navy — header, launcher */
  --ac-primary-dark:   #14232D;   /* Deep Charcoal — hover states */
  --ac-accent:         #B68D40;   /* Exemplar Gold — send btn, badge */
  --ac-accent-light:   #D6AD61;   /* Warm Ochre — hover, highlights */
  --ac-sand:           #F4EBD0;   /* Light Sand — decorative tints */

  /* Surface Colours */
  --ac-bg-widget:      #ffffff;
  --ac-bg-header:      var(--ac-primary);
  --ac-bg-messages:    #F8F6F2;
  --ac-bg-bubble-agent:#ffffff;
  --ac-bg-bubble-user: #33495E;
  --ac-bg-input:       #ffffff;

  /* Text Colours */
  --ac-text-header:    #ffffff;
  --ac-text-agent:     #14232D;
  --ac-text-user:      #ffffff;
  --ac-text-system:    #7a8a96;
  --ac-text-input:     #14232D;
  --ac-text-placeholder: #a0adb6;
  --ac-text-label:     #33495E;

  /* Borders & Shadows */
  --ac-border-color:   #e8e2d8;
  --ac-shadow-widget:  0 12px 40px rgba(20,35,45,0.18), 0 2px 8px rgba(20,35,45,0.10);
  --ac-shadow-launcher:0 4px 20px rgba(20,35,45,0.28);

  /* Sizing */
  --ac-widget-width:   400px;
  --ac-widget-height:  600px;
  --ac-launcher-size:  62px;
  --ac-launcher-right: 28px;
  --ac-launcher-bottom:28px;
  --ac-border-radius:  16px;
  --ac-bubble-radius:  16px;

  /* Typography — Exemplar brand fonts */
  --ac-font-body:    "Source Sans 3", "Source Sans Pro", -apple-system, BlinkMacSystemFont, sans-serif;
  --ac-font-heading: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --ac-font-size-base: 14px;
  --ac-font-size-sm:   12px;
  --ac-font-size-lg:   16px;

  /* Transitions */
  --ac-transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ── COMPONENT STYLES ──────────────────────────────────── */

/* Launcher button */
#ac-launcher {
  position: fixed;
  right: var(--ac-launcher-right);
  bottom: var(--ac-launcher-bottom);
  width: var(--ac-launcher-size);
  height: var(--ac-launcher-size);
  border-radius: 50%;
  background: var(--ac-primary);
  color: var(--ac-text-header);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--ac-shadow-launcher);
  transition: background var(--ac-transition), transform var(--ac-transition), box-shadow var(--ac-transition);
  z-index: 9998;
  outline: none;
}
#ac-launcher:hover {
  background: var(--ac-primary-dark);
  transform: scale(1.07);
  box-shadow: 0 6px 24px rgba(20,35,45,0.38);
}
#ac-launcher:active { transform: scale(0.96); }
#ac-launcher:focus-visible { outline: 3px solid var(--ac-accent); outline-offset: 3px; }

/* Unread badge */
#ac-unread-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #ec4444;
  color: #ffffff;
  font-family: var(--ac-font-body);
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  padding: 0 5px;
  display: none;
  pointer-events: none;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
#ac-unread-badge.visible { display: block; }

/* Widget container */
#ac-widget {
  position: fixed;
  right: var(--ac-launcher-right);
  bottom: calc(var(--ac-launcher-bottom) + var(--ac-launcher-size) + 14px);
  width: var(--ac-widget-width);
  height: var(--ac-widget-height);
  background: var(--ac-bg-widget);
  border-radius: var(--ac-border-radius);
  box-shadow: var(--ac-shadow-widget);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: var(--ac-font-body);
  font-size: var(--ac-font-size-base);
  transform-origin: bottom right;
  transition: opacity var(--ac-transition), transform var(--ac-transition);
  opacity: 0;
  transform: scale(0.92) translateY(14px);
  pointer-events: none;
  border: 1px solid rgba(51,73,94,0.12);
}
#ac-widget.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* Header */
#ac-header {
  background: var(--ac-bg-header);
  color: var(--ac-text-header);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 13px;
  flex-shrink: 0;
  user-select: none;
  border-bottom: 2px solid var(--ac-accent);
}
#ac-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(182,141,64,0.15);
  border: 1.5px solid rgba(214,173,97,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#ac-header-info { flex: 1; min-width: 0; }
#ac-header-title {
  font-family: var(--ac-font-heading);
  font-size: var(--ac-font-size-lg);
  font-weight: 600;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}
#ac-header-subtitle {
  font-family: var(--ac-font-body);
  font-size: 10px;
  opacity: 0.7;
  margin-top: 2px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
#ac-header-close {
  background: none;
  border: none;
  color: var(--ac-text-header);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 6px;
  border-radius: 6px;
  transition: background var(--ac-transition);
  flex-shrink: 0;
  opacity: 0.75;
}
#ac-header-close:hover { background: rgba(255,255,255,0.15); opacity: 1; }
#ac-header-close:focus-visible { outline: 2px solid rgba(214,173,97,0.8); }

/* Status bar */
#ac-status-bar {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 16px;
  font-size: var(--ac-font-size-sm);
  font-weight: 500;
  flex-shrink: 0;
  font-family: var(--ac-font-body);
}
#ac-status-bar.info    { display: flex; background: #eef3f7; color: #33495E; border-bottom: 1px solid #d4dde5; }
#ac-status-bar.success { display: flex; background: #f0f7f0; color: #2d6a2d; }
#ac-status-bar.error   { display: flex; background: #fdf0f0; color: #8b2020; }
#ac-status-bar.warning { display: flex; background: #fdf8ec; color: #7a5c1a; }
.ac-spinner {
  width: 13px; height: 13px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: ac-spin 0.7s linear infinite;
}
@keyframes ac-spin { to { transform: rotate(360deg); } }

/* Pre-chat form */
#ac-prechat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 22px;
  background: var(--ac-bg-messages);
  gap: 13px;
  overflow-y: auto;
}
#ac-prechat h2 {
  font-family: var(--ac-font-heading);
  font-size: 20px;
  font-weight: 600;
  font-style: italic;
  color: var(--ac-primary);
  text-align: center;
}
#ac-prechat > p {
  font-size: var(--ac-font-size-sm);
  color: var(--ac-text-system);
  text-align: center;
  line-height: 1.6;
}
.ac-gold-bar {
  width: 40px;
  height: 2px;
  background: var(--ac-accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* Form fields */
.ac-field-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ac-field-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ac-text-label);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ac-input {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--ac-border-color);
  border-radius: 8px;
  font-size: var(--ac-font-size-base);
  font-family: var(--ac-font-body);
  color: var(--ac-text-input);
  background: var(--ac-bg-input);
  transition: border-color var(--ac-transition), box-shadow var(--ac-transition);
  outline: none;
}
.ac-input:focus {
  border-color: var(--ac-accent);
  box-shadow: 0 0 0 3px rgba(182,141,64,0.15);
}
.ac-input.error { border-color: #c0392b; }
.ac-field-error {
  font-size: 11px;
  color: #c0392b;
  display: none;
  font-family: var(--ac-font-body);
}
.ac-field-error.visible { display: block; }

/* Primary button */
.ac-btn-primary {
  width: 100%;
  padding: 12px 20px;
  background: var(--ac-accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--ac-font-body);
  cursor: pointer;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background var(--ac-transition), transform var(--ac-transition), box-shadow var(--ac-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 10px rgba(182,141,64,0.3);
}
.ac-btn-primary:hover {
  background: var(--ac-accent-light);
  box-shadow: 0 4px 16px rgba(182,141,64,0.4);
}
.ac-btn-primary:active  { transform: scale(0.98); }
.ac-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.ac-btn-primary:focus-visible { outline: 3px solid var(--ac-primary); outline-offset: 2px; }

/* Messages area */
#ac-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  background: var(--ac-bg-messages);
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
#ac-messages::-webkit-scrollbar { width: 4px; }
#ac-messages::-webkit-scrollbar-thumb { background: #c8bfb0; border-radius: 4px; }

/* Typing indicator */
#ac-typing-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 2px 16px 0;
  font-size: var(--ac-font-size-sm);
  color: var(--ac-text-system);
  font-family: var(--ac-font-body);
  font-style: italic;
}
#ac-typing-indicator.visible { display: flex; }
.ac-typing-dots { display: flex; gap: 3px; align-items: center; }
.ac-typing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ac-accent);
  animation: ac-bounce 1.2s ease-in-out infinite;
}
.ac-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ac-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ac-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Message bubbles */
.ac-msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: ac-fade-in 0.18s ease;
}
@keyframes ac-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }
.ac-msg.agent  { align-self: flex-start; }
.ac-msg.user   { align-self: flex-end; }
.ac-msg.system { align-self: center; max-width: 100%; }

.ac-bubble {
  padding: 10px 15px;
  border-radius: var(--ac-bubble-radius);
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  font-family: var(--ac-font-body);
}
.ac-msg.agent .ac-bubble {
  background: var(--ac-bg-bubble-agent);
  color: var(--ac-text-agent);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(20,35,45,0.08);
  border: 1px solid var(--ac-border-color);
}
.ac-msg.user .ac-bubble {
  background: var(--ac-bg-bubble-user);
  color: var(--ac-text-user);
  border-bottom-right-radius: 4px;
}
.ac-msg.system .ac-bubble {
  background: transparent;
  color: var(--ac-text-system);
  font-size: var(--ac-font-size-sm);
  text-align: center;
  padding: 2px 8px;
  font-style: italic;
}
.ac-msg-meta {
  font-size: 10px;
  color: var(--ac-text-system);
  margin-top: 4px;
  font-family: var(--ac-font-body);
  letter-spacing: 0.02em;
}
.ac-msg.user .ac-msg-meta { text-align: right; }

/* Composer */
#ac-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: var(--ac-bg-widget);
  border-top: 1px solid var(--ac-border-color);
  flex-shrink: 0;
}
#ac-message-input {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--ac-border-color);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: var(--ac-font-size-base);
  font-family: var(--ac-font-body);
  color: var(--ac-text-input);
  background: var(--ac-bg-input);
  outline: none;
  max-height: 100px;
  line-height: 1.5;
  transition: border-color var(--ac-transition), box-shadow var(--ac-transition);
}
#ac-message-input:focus {
  border-color: var(--ac-accent);
  box-shadow: 0 0 0 3px rgba(182,141,64,0.12);
}
#ac-message-input::placeholder { color: var(--ac-text-placeholder); }
#ac-message-input:disabled { background: #f9f8f6; color: #a0adb6; cursor: not-allowed; }

#ac-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--ac-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #ffffff;
  transition: background var(--ac-transition), transform var(--ac-transition), box-shadow var(--ac-transition);
  box-shadow: 0 2px 6px rgba(182,141,64,0.3);
}
#ac-send-btn:hover {
  background: var(--ac-accent-light);
  box-shadow: 0 3px 10px rgba(182,141,64,0.4);
}
#ac-send-btn:active  { transform: scale(0.93); }
#ac-send-btn:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }
#ac-send-btn:focus-visible { outline: 3px solid var(--ac-primary); outline-offset: 2px; }
#ac-send-btn svg { pointer-events: none; }

/* Attach button */
#ac-attach-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: none;
  border: 1.5px solid var(--ac-border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--ac-text-system);
  transition: background var(--ac-transition), color var(--ac-transition), border-color var(--ac-transition);
}
#ac-attach-btn:hover {
  background: var(--ac-bg-messages);
  color: var(--ac-primary);
  border-color: var(--ac-accent);
}
#ac-attach-btn:active { transform: scale(0.93); }
#ac-attach-btn:focus-visible { outline: 3px solid var(--ac-primary); outline-offset: 2px; }
#ac-attach-btn svg { pointer-events: none; }

/* Attachment bubble */
.ac-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  min-width: 160px;
}
.ac-att-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  opacity: 0.75;
}
.ac-att-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ac-att-name {
  font-weight: 600;
  font-size: var(--ac-font-size-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.ac-att-size {
  font-size: 10px;
  opacity: 0.65;
}
.ac-att-link {
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  margin-top: 3px;
  letter-spacing: 0.04em;
}
.ac-msg.user  .ac-att-link { color: rgba(255,255,255,0.85); text-decoration: underline; }
.ac-msg.agent .ac-att-link { color: var(--ac-accent); }
.ac-att-link:hover { opacity: 0.8; }

/* Wait-or-ticket choice buttons (SYSTEM:STILL_WAITING) */
.ac-choice-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 6px;
}
.ac-choice-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--ac-accent);
  background: transparent;
  color: var(--ac-accent);
  font-family: var(--ac-font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.ac-choice-btn:hover  { background: var(--ac-sand); }
.ac-choice-btn:active { transform: scale(0.97); }
.ac-choice-btn-primary {
  background: var(--ac-accent);
  color: #ffffff;
}
.ac-choice-btn-primary:hover { background: var(--ac-accent-light); }

/* End chat bar */
#ac-end-bar {
  display: none;
  padding: 8px 14px 10px;
  background: var(--ac-bg-widget);
  border-top: 1px solid var(--ac-border-color);
  flex-shrink: 0;
}
#ac-end-bar.visible { display: block; }
#ac-end-chat-btn {
  width: 100%;
  padding: 8px;
  border: 1.5px solid #c0392b;
  border-radius: 8px;
  background: transparent;
  color: #c0392b;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--ac-font-body);
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background var(--ac-transition), color var(--ac-transition);
}
#ac-end-chat-btn:hover { background: #c0392b; color: #ffffff; }

/* Post-chat panel */
#ac-postchat {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: var(--ac-bg-messages);
  gap: 16px;
  text-align: center;
}
#ac-postchat.visible { display: flex; }
#ac-postchat-icon { font-size: 44px; }
#ac-postchat h3 {
  font-family: var(--ac-font-heading);
  font-size: 20px;
  font-weight: 600;
  font-style: italic;
  color: var(--ac-primary);
}
#ac-postchat p {
  font-size: var(--ac-font-size-sm);
  color: var(--ac-text-system);
  line-height: 1.6;
}

/* Brand footer */
#ac-brand-footer {
  padding: 5px 0 7px;
  text-align: center;
  font-size: 9px;
  color: #b0bcc6;
  font-family: var(--ac-font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--ac-bg-widget);
  border-top: 1px solid var(--ac-border-color);
  flex-shrink: 0;
}
#ac-brand-footer strong { color: var(--ac-accent); }

/* ── NO-AGENTS / AFTER-HOURS PANEL ─────────────────────── */
#ac-noagents {
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 24px 20px;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
}
#ac-noagents-icon {
  font-size: 2.4rem;
  line-height: 1;
}
#ac-noagents h3 {
  margin: 0;
  font-family: var(--ac-font-heading);
  font-size: 1.1rem;
  color: var(--ac-primary);
}
#ac-noagents p {
  margin: 0;
  font-size: var(--ac-font-size-sm);
  color: var(--ac-text-secondary);
  line-height: 1.55;
}
#ac-noagents .ac-field-group {
  width: 100%;
  text-align: left;
  margin-top: 6px;
}
#ac-ticket-success {
  text-align: center;
  padding: 8px 0;
}
#ac-ticket-success p {
  font-size: var(--ac-font-size-sm);
  color: var(--ac-text-primary);
  line-height: 1.55;
}

/* Responsive */
@media (max-width: 440px) {
  #ac-widget {
    right: 0; bottom: 0;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
  }
  #ac-launcher { right: 16px; bottom: 16px; }
}
