/* ==========================================================================
     HostArmada-Inspired Unified Live Chat Widget (RTL/LTR + Light/Dark Ready)
     ========================================================================== */
  #haChatLauncher {
    position: fixed;
    bottom: calc(22px + var(--ha-launcher-lift, 0px));
    inset-inline-end: 22px;
    z-index: 1090;
    border-radius: 50rem;
    padding: 10px 22px;
    font-weight: 800;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #f37970 0%, #e96359 100%);
    color: #1f242d;
    border: none;
    box-shadow: 0 10px 28px rgba(233, 99, 89, 0.42), 0 2px 8px rgba(15, 23, 42, 0.14);
    cursor: pointer;
    transition: bottom 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    font-family: 'Cairo', 'Public Sans', sans-serif;
  }
  #haChatLauncher:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 14px 34px rgba(233, 99, 89, 0.52);
    filter: brightness(1.03);
  }
  /* Clears page actions under the launcher: shrinks to its icon and rises above them */
  #haChatLauncher.is-avoiding {
    padding: 10px;
  }
  #haChatLauncher.is-avoiding .ha-launcher-label {
    display: none;
  }
  @media (prefers-reduced-motion: reduce) {
    #haChatLauncher {
      transition: none;
    }
  }
  #haChatLauncher .ha-launcher-icon {
    font-size: 1.25rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
  }
  #haChatUnreadBadge {
    background: #2b303a;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 800;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 50rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Main Floating Chat Window */
  #haChatWindow {
    position: fixed;
    bottom: 22px;
    inset-inline-end: 22px;
    z-index: 1095;
    width: 380px;
    max-width: calc(100vw - 24px);
    height: 620px;
    max-height: calc(100vh - 34px);
    background: var(--bs-paper-bg, #ffffff);
    color: var(--bs-body-color, #1e293b);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.26), 0 0 0 1px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Cairo', 'Public Sans', sans-serif;
    transition: width 0.22s ease, height 0.22s ease, transform 0.22s ease, opacity 0.2s ease;
  }
  #haChatWindow.is-expanded {
    width: 490px;
    height: 710px;
  }
  [data-bs-theme="dark"] #haChatWindow {
    background: #1e2230;
    color: #e2e8f0;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(255, 255, 255, 0.1);
  }

  /* Top Coral Header Bar (.ha-chat-header) */
  .ha-chat-header {
    background: linear-gradient(135deg, #f37970 0%, #eb665c 100%);
    color: #1f242d;
    padding: 11px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  }
  .ha-chat-header__title {
    font-weight: 800;
    font-size: 0.88rem;
    line-height: 1.3;
    text-align: center;
    flex-grow: 1;
    color: #1f242d;
  }
  .ha-chat-header__actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
  .ha-chat-header__btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #1f242d;
    font-weight: 800;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
  }
  .ha-chat-header__btn:hover {
    background: rgba(255, 255, 255, 0.28);
  }

  /* Mode Switcher Pills */
  .ha-mode-switcher {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: rgba(15, 23, 42, 0.05);
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 12px;
  }
  [data-bs-theme="dark"] .ha-mode-switcher {
    background: rgba(255, 255, 255, 0.06);
  }
  .ha-mode-pill {
    border: none;
    background: transparent;
    padding: 6px 8px;
    border-radius: 7px;
    font-size: 0.76rem;
    font-weight: 800;
    color: var(--bs-secondary-color, #64748b);
    cursor: pointer;
    transition: all 0.15s ease;
  }
  .ha-mode-pill.is-active {
    background: #2b303a;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
  }

  /* Pre-Chat Body & Footer */
  #haChatPrechatView {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }
  .ha-prechat-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
  }
  .ha-prechat-welcome {
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--bs-body-color, #334155);
    margin-bottom: 12px;
    font-weight: 600;
  }
  .ha-field-group {
    margin-bottom: 11px;
  }
  .ha-field-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 800;
    margin-bottom: 4px;
    color: var(--bs-body-color, #1e293b);
  }
  .ha-input,
  .ha-select,
  .ha-textarea {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 7px;
    padding: 7px 10px;
    font-size: 0.82rem;
    background: transparent;
    color: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
  .ha-input:focus,
  .ha-select:focus,
  .ha-textarea:focus {
    outline: none;
    border-color: #f37970;
    box-shadow: 0 0 0 3px rgba(243, 121, 112, 0.16);
  }
  [data-bs-theme="dark"] .ha-select option {
    background: #1e2230;
    color: #e2e8f0;
  }
  .ha-ref-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
  }
  .ha-btn-verify-ref {
    border: 1px solid #2b303a;
    background: #2b303a;
    color: #ffffff;
    border-radius: 7px;
    padding: 0 11px;
    font-size: 0.75rem;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
    transition: opacity 0.15s ease;
  }
  .ha-btn-verify-ref:hover {
    opacity: 0.92;
  }
  .ha-field-hint {
    font-size: 0.71rem;
    color: var(--bs-secondary-color, #64748b);
    margin-top: 3px;
    line-height: 1.45;
  }
  .ha-prechat-footer {
    padding: 10px 16px;
    border-top: 1px solid rgba(148, 163, 184, 0.25);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
  }
  .ha-btn-charcoal {
    background: #2b303a;
    color: #ffffff;
    border: 1px solid #2b303a;
    border-radius: 6px;
    padding: 7px 18px;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
  }
  .ha-btn-charcoal:hover {
    background: #1f242d;
  }
  .ha-btn-outline {
    background: transparent;
    color: inherit;
    border: 1px solid rgba(148, 163, 184, 0.55);
    border-radius: 6px;
    padding: 7px 18px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
  }
  .ha-brand-tag {
    font-size: 0.73rem;
    font-weight: 800;
    color: var(--bs-secondary-color, #64748b);
    letter-spacing: 0.2px;
  }

  /* Active Chat View (#haChatActiveView) */
  #haChatActiveView {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    position: relative;
  }
  .ha-chat-agent-bar {
    padding: 9px 14px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
  }
  .ha-agent-info {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
  }
  .ha-agent-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2b303a 0%, #475569 100%);
    color: #ffffff;
    font-weight: 800;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
  }
  .ha-agent-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  /* Shown on the fresh pre-chat form after a chat ends */
  .ha-prechat-notice {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.5;
    color: #15803d;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
  }
  .ha-prechat-notice i { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
  [data-bs-theme="dark"] .ha-prechat-notice {
    color: #86efac;
    background: rgba(34, 197, 94, 0.14);
    border-color: rgba(34, 197, 94, 0.35);
  }
  /* Team (no specialist assigned yet): the section's icon in the widget's coral brand tone */
  .ha-agent-avatar.is-team,
  .ha-msg-avatar-sm.is-team {
    background: rgba(235, 102, 92, 0.14);
    color: #e2554b;
    box-shadow: inset 0 0 0 1px rgba(235, 102, 92, 0.28);
  }
  .ha-agent-avatar.is-team { font-size: 1.15rem; }
  .ha-msg-avatar-sm.is-team { font-size: 0.9rem; }
  /* Assigned specialist without a photo: two-letter initials */
  .ha-agent-avatar.is-initials,
  .ha-msg-avatar-sm.is-initials {
    background: linear-gradient(135deg, #f37970 0%, #eb665c 100%);
    color: #ffffff;
    letter-spacing: 0.02em;
  }
  .ha-msg-avatar-sm img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
  .ha-msg-avatar-sm.is-photo { background: transparent; overflow: hidden; }
  [data-bs-theme="dark"] .ha-agent-avatar.is-team,
  [data-bs-theme="dark"] .ha-msg-avatar-sm.is-team {
    background: rgba(235, 102, 92, 0.2);
    color: #f6a39c;
    box-shadow: inset 0 0 0 1px rgba(235, 102, 92, 0.38);
  }
  .ha-agent-name {
    font-weight: 800;
    font-size: 0.82rem;
    line-height: 1.2;
  }
  .ha-agent-role {
    font-size: 0.71rem;
    color: var(--bs-secondary-color, #64748b);
    line-height: 1.2;
  }
  .ha-agent-tools {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
  .ha-thumb-btn {
    border: none;
    background: transparent;
    color: var(--bs-secondary-color, #64748b);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .ha-thumb-btn:hover,
  .ha-thumb-btn.is-selected {
    background: rgba(243, 121, 112, 0.14);
    color: #e96359;
  }

  /* Live Accreditation Status Strip (#haChatAccreditationCard) */
  #haChatAccreditationCard {
    margin: 8px 12px 0 12px;
    padding: 8px 11px;
    border-radius: 9px;
    background: rgba(105, 108, 255, 0.06);
    border: 1px solid rgba(105, 108, 255, 0.22);
    font-size: 0.73rem;
    flex-shrink: 0;
  }
  .ha-accred-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 5px;
  }
  .ha-accred-ref {
    font-weight: 900;
    font-size: 0.74rem;
    padding: 1px 7px;
    border-radius: 5px;
    background: #2b303a;
    color: #ffffff;
  }
  .ha-accred-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: center;
    justify-content: space-between;
  }
  .ha-accred-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
  }
  .ha-accred-badge {
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.69rem;
    background: rgba(15, 23, 42, 0.08);
  }
  .ha-accred-badge.is-ok {
    background: rgba(22, 163, 74, 0.15);
    color: #15803d;
  }
  .ha-accred-badge.is-warn {
    background: rgba(217, 119, 6, 0.16);
    color: #b45309;
  }

  /* Messages Timeline (#haChatTimeline) */
  #haChatTimeline {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .ha-sys-marker {
    text-align: center;
    font-size: 0.73rem;
    color: var(--bs-secondary-color, #64748b);
    margin: 2px 0;
    font-weight: 600;
  }

  /* Customer Message Row (Dark Charcoal #2b303a + Red Checkmark) */
  .ha-msg-row {
    display: flex;
    flex-direction: column;
    max-width: 85%;
  }
  .ha-msg-row.is-customer {
    align-self: flex-start;
  }
  .ha-msg-row.is-agent {
    align-self: flex-end;
  }
  .ha-customer-wrap {
    display: inline-flex;
    align-items: flex-end;
    gap: 5px;
  }
  .ha-bubble-customer {
    background: #2b303a;
    color: #ffffff;
    padding: 9px 13px;
    border-radius: 15px;
    font-size: 0.81rem;
    line-height: 1.5;
    word-break: break-word;
  }
  .ha-msg-check {
    color: #e96359;
    font-size: 0.75rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 4px;
    flex-shrink: 0;
  }

  /* Specialist Message Row (Light Gray #e9ebed + Avatar + Translation Toggle) */
  .ha-agent-sender-label {
    font-size: 0.71rem;
    color: var(--bs-secondary-color, #64748b);
    margin-bottom: 3px;
    padding-inline-end: 34px;
    text-align: end;
  }
  .ha-agent-wrap {
    display: inline-flex;
    align-items: flex-end;
    gap: 7px;
  }
  .ha-bubble-agent {
    background: #e9ebed;
    color: #1f242d;
    padding: 9px 13px;
    border-radius: 15px;
    font-size: 0.81rem;
    line-height: 1.5;
    word-break: break-word;
  }
  [data-bs-theme="dark"] .ha-bubble-agent {
    background: #2d3348;
    color: #f1f5f9;
  }
  .ha-translate-toggle {
    display: inline-block;
    margin-top: 5px;
    font-size: 0.72rem;
    color: #64748b;
    text-decoration: none;
    cursor: pointer;
    font-weight: 700;
  }
  .ha-translate-toggle:hover {
    text-decoration: underline;
    color: #1f242d;
  }
  [data-bs-theme="dark"] .ha-translate-toggle {
    color: #94a3b8;
  }
  .ha-msg-avatar-sm {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #2b303a;
    color: #ffffff;
    font-size: 0.68rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .ha-att-list {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
  .ha-att-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(15, 23, 42, 0.12);
    color: inherit;
    text-decoration: none;
  }

  /* Real-Time Specialist Typing Indicator (3 Waving Dots — HostArmada / Hostinger Style) */
  @keyframes haTypingWave {
    0%, 60%, 100% {
      transform: translateY(0);
      opacity: 0.45;
    }
    30% {
      transform: translateY(-5px);
      opacity: 1;
    }
  }
  .ha-typing-bubble {
    background: #e9ebed;
    color: #1f242d;
    padding: 10px 14px;
    border-radius: 15px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
  }
  [data-bs-theme="dark"] .ha-typing-bubble {
    background: #2d3348;
    color: #f1f5f9;
  }
  .ha-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 14px;
    direction: ltr;
  }
  .ha-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #e96359;
    display: inline-block;
    animation: haTypingWave 1.25s infinite ease-in-out;
  }
  .ha-typing-dot:nth-child(2) {
    animation-delay: 0.18s;
  }
  .ha-typing-dot:nth-child(3) {
    animation-delay: 0.36s;
  }
  .ha-agent-typing-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #e96359;
    margin-top: 2px;
  }
  .ha-agent-typing-pill .ha-typing-dot {
    width: 5px;
    height: 5px;
  }

  /* Bottom Composer (.ha-chat-composer) */
  .ha-chat-composer {
    padding: 8px 12px 10px 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.22);
    flex-shrink: 0;
  }
  #haChatAttachmentPreview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 4px 9px;
    margin-bottom: 6px;
    border-radius: 6px;
    background: rgba(105, 108, 255, 0.1);
    font-size: 0.73rem;
    font-weight: 700;
  }
  #haChatInput {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.42);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.81rem;
    resize: none;
    height: 58px;
    background: transparent;
    color: inherit;
  }
  #haChatInput:focus {
    outline: none;
    border-color: #94a3b8;
  }
  .ha-composer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
  }
  .ha-toolbar-icons {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    position: relative;
  }
  .ha-tool-btn {
    border: none;
    background: transparent;
    color: var(--bs-secondary-color, #64748b);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .ha-tool-btn:hover {
    background: rgba(15, 23, 42, 0.07);
    color: var(--bs-body-color, #1e293b);
  }
  .ha-send-btn {
    background: #2b303a;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 4px 11px;
    font-size: 0.74rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
  }
  .ha-options-menu {
    position: absolute;
    bottom: 34px;
    inset-inline-start: 0;
    background: var(--bs-paper-bg, #ffffff);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 9px;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.18);
    padding: 5px;
    min-width: 195px;
    z-index: 20;
  }
  [data-bs-theme="dark"] .ha-options-menu {
    background: #25293c;
  }
  .ha-options-menu button {
    width: 100%;
    text-align: start;
    border: none;
    background: transparent;
    padding: 6px 9px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .ha-options-menu button:hover {
    background: rgba(105, 108, 255, 0.1);
  }

  /* State 4: End Chat Confirmation Drawer (#haChatEndConfirmDrawer) */
  #haChatEndConfirmDrawer {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    background: var(--bs-paper-bg, #ffffff);
    border-top: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 -12px 30px rgba(15, 23, 42, 0.16);
    padding: 18px 16px;
    z-index: 30;
    text-align: center;
  }
  [data-bs-theme="dark"] #haChatEndConfirmDrawer {
    background: #1e2230;
  }
  .ha-end-drawer-title {
    font-weight: 800;
    font-size: 0.86rem;
    margin-bottom: 14px;
  }
  .ha-end-drawer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  /* State 5: Post-Chat Rating View (#haChatRatingView) */
  #haChatRatingView {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 16px;
    overflow-y: auto;
  }
  .ha-rating-thumbs {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0 10px 0;
  }
  .ha-rating-thumb-pill {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: transparent;
    font-size: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
  }
  .ha-rating-thumb-pill.is-active {
    background: #2b303a;
    color: #ffffff;
    border-color: #2b303a;
  }
  .ha-star-selector {
    display: inline-flex;
    gap: 4px;
    margin-bottom: 12px;
  }
  .ha-star-btn {
    border: none;
    background: transparent;
    font-size: 1.35rem;
    color: #cbd5e1;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
  }
  .ha-star-btn.is-active {
    color: #f59e0b;
  }