/* ── Theme variables ──────────────────────────────────── */
/* Override these on .elev-chat-launcher / .elev-chat-widget to re-theme */

:root {
    --chat-primary: #2563eb;
    --chat-primary-dark: #1d4ed8;
    --chat-primary-light: #60a5fa;
    --chat-primary-bg: #dbeafe;
    --chat-primary-bg-hover: #eff6ff;
    --chat-primary-shadow: rgba(29, 78, 216, 0.35);
    --chat-primary-shadow-light: rgba(29, 78, 216, 0.2);
    --chat-primary-ring: rgba(37, 99, 235, 0.1);
    --chat-danger: #ef4444;
}

/* ── Launcher ─────────────────────────────────────────── */

.elev-chat-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1200;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 0;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: #fff;
    box-shadow: 0 8px 24px var(--chat-primary-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    transition: none;
    animation: none;
}

.elev-chat-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 32px var(--chat-primary-shadow);
}

.elev-chat-launcher:active {
    transform: scale(0.95);
}

.elev-chat-launcher i,
.elev-chat-launcher svg {
    width: 24px;
    height: 24px;
}

.elev-chat-launcher.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.85);
    animation: none;
}

@keyframes chat-launcher-entrance {
    0% {
        opacity: 0;
        transform: scale(0) translateY(20px);
    }
    60% {
        opacity: 1;
        transform: scale(1.12) translateY(-4px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* unread badge (launcher) */
.elev-chat-launcher__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: var(--chat-danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    padding: 0 5px;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
    pointer-events: none;
    transition: transform 200ms ease, opacity 200ms ease;
}

.elev-chat-launcher__badge:empty,
.elev-chat-launcher__badge.is-hidden {
    transform: scale(0);
    opacity: 0;
}

@keyframes chat-badge-pop {
    0% {
        transform: scale(0);
    }
    60% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.elev-chat-launcher__badge.is-new {
    animation: chat-badge-pop 300ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ── Widget panel ────────────────────────────────────── */

.elev-chat-widget {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: min(980px, calc(100vw - 32px));
    height: min(78vh, 760px);
    z-index: 1199;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 24px 48px -12px rgba(16, 24, 40, 0.2),
        0 0 0 1px rgba(16, 24, 40, 0.05);
    transform: translateY(16px) scale(0.98);
    opacity: 0;
    pointer-events: none;
    transition: none;
}

.elev-chat-widget.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.elev-chat-widget.elev-chat-widget--expanded {
    left: 292px;
    right: 24px;
    bottom: 24px;
    width: auto;
    height: calc(100dvh - 48px);
    border-radius: 16px;
}

/* ── Header ──────────────────────────────────────────── */

.chat-widget__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
}

.chat-widget__header h5 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.chat-widget__header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.chat-widget__header-actions .btn {
    background: rgba(255, 255, 255, 0.15);
    border: 0;
    color: #fff;
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.85rem;
    touch-action: manipulation;
    transition: background 150ms ease;
}

.chat-widget__header-actions .btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.chat-widget__status {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.76rem;
}

/* ── Body grid ───────────────────────────────────────── */

.chat-widget__body {
    display: grid;
    grid-template-columns: 300px 1fr;
    height: calc(100% - 54px);
    min-height: 0;
}

.elev-chat-widget--thread-only .chat-widget__body {
    grid-template-columns: 1fr;
}

/* ── Sidebar ─────────────────────────────────────────── */

.chat-widget__sidebar {
    border-right: 1px solid #f0f0f5;
    background: #fafbfc;
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-widget__sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    border: 0;
    border-bottom: 1px solid #f0f0f5;
    background: #fafbfc;
    cursor: pointer;
    width: 100%;
    font-size: 0.82rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chat-widget__sidebar-toggle:hover {
    background: #f3f4f6;
}

.chat-widget__sidebar-toggle-icon {
    transition: transform 200ms ease;
    display: inline-block;
}

.chat-widget__sidebar-toggle.is-collapsed .chat-widget__sidebar-toggle-icon {
    transform: rotate(-90deg);
}

.chat-create-form-wrap {
    overflow-y: auto;
    transition: max-height 250ms ease, opacity 250ms ease;
    max-height: 45%;
    opacity: 1;
    flex-shrink: 0;
}

.chat-create-form-wrap.is-collapsed {
    max-height: 0;
    opacity: 0;
}

.chat-create-form {
    background: #fff;
    border: 1px solid #eef0f3;
    border-radius: 10px;
    padding: 0.7rem;
    margin: 0.6rem;
    margin-bottom: 0;
}

.chat-create-form .form-label {
    font-size: 0.76rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* searchable participant input */
.chat-participant-picker {
    position: relative;
}

.chat-participant-picker__toolbar {
    display: flex;
    gap: 6px;
    align-items: center;
}

.chat-participant-picker__input {
    flex: 1;
    min-width: 0;
    padding: 0.35rem 0.5rem;
    font-size: 0.86rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.chat-participant-picker__select-all {
    flex-shrink: 0;
    border: 0;
    background: var(--chat-primary-bg);
    color: var(--chat-primary-dark);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.3rem 0.55rem;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 100ms ease;
}

.chat-participant-picker__select-all:hover {
    background: var(--chat-primary-bg-hover);
}

.chat-participant-picker__input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px var(--chat-primary-ring);
}

.chat-participant-picker__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 160px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-top: 0;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    z-index: 10;
    display: none;
}

.chat-participant-picker__dropdown.is-open {
    display: block;
}

.chat-participant-picker__option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.84rem;
    cursor: pointer;
    transition: background 100ms ease;
}

.chat-participant-picker__option:hover {
    background: var(--chat-primary-bg-hover);
}

.chat-participant-picker__option.is-selected {
    background: var(--chat-primary-bg);
    font-weight: 600;
}

.chat-participant-picker__avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary-light), var(--chat-primary));
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
}

.chat-participant-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.3rem;
    max-height: 80px;
    overflow-y: auto;
}

.chat-participant-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--chat-primary-bg);
    color: var(--chat-primary-dark);
    border-radius: 999px;
    padding: 0.15rem 0.45rem;
    font-size: 0.74rem;
    font-weight: 500;
}

.chat-participant-tag__remove {
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 100ms ease;
    background: none;
    border: none;
    color: inherit;
    padding: 0;
}

.chat-participant-tag__remove:hover {
    opacity: 1;
}

.chat-create-form .btn-primary {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    border: 0;
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 600;
    padding: 0.45rem 0.75rem;
    transition: opacity 150ms ease, transform 100ms ease;
}

.chat-create-form .btn-primary:hover {
    opacity: 0.9;
}

.chat-create-form .btn-primary:active {
    transform: scale(0.97);
}

/* ── Conversation list ───────────────────────────────── */

.chat-conversation-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-conversation-list__item {
    display: flex;
    flex-direction: column;
    width: 100%;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    background: transparent;
    border: 0;
    border-radius: 10px;
    padding: 0.55rem 0.65rem;
    color: inherit;
    transition: background 120ms ease;
    position: relative;
}

.chat-conversation-list__item:hover {
    background: #f3f4f6;
}

.chat-conversation-list__item.is-active {
    background: var(--chat-primary-bg);
}

.chat-conversation-list__item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.chat-conversation-list__item-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.chat-conversation-list__item-unread-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.chat-conversation-list__item-time {
    font-size: 0.72rem;
    color: #9ca3af;
    white-space: nowrap;
    flex-shrink: 0;
}

.chat-conversation-list__item-preview {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-conversation-list__item.is-active .chat-conversation-list__item-title {
    color: var(--chat-primary-dark);
}

.chat-conversation-list__empty {
    padding: 0.75rem 0.5rem;
}

/* unread badge on conversation item */
.chat-conversation-list__unread {
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--chat-primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    padding: 0 5px;
    flex-shrink: 0;
    transition: transform 200ms ease, opacity 200ms ease;
    animation: chat-badge-pop 250ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.chat-conversation-list__unread:empty,
.chat-conversation-list__unread.is-hidden {
    display: none;
}

/* ── Thread area ─────────────────────────────────────── */

.chat-widget__thread {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fafbfc;
}

.chat-widget__thread-header {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid #f0f0f5;
    background: #fff;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.chat-widget__thread-info {
    flex: 1;
    min-width: 0;
}

.chat-widget__thread-actions {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    flex-shrink: 0;
}

.chat-widget__thread-action {
    width: 28px;
    height: 28px;
    border: 0;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 0.1rem;
    transition: background 150ms ease, color 150ms ease;
}

.chat-widget__thread-action:hover {
    background: #e5e7eb;
    color: #374151;
}

.chat-widget__thread-action--danger:hover {
    background: #fee2e2;
    color: #b91c1c;
}

/* ── Search toggle button ─────────────────────────── */

.chat-widget__search-toggle {
    width: 28px;
    height: 28px;
    border: 0;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 0.1rem;
    transition: background 150ms ease, color 150ms ease;
}

.chat-widget__search-toggle:hover {
    background: #e5e7eb;
    color: #374151;
}

.chat-widget__search-toggle.is-active {
    background: var(--chat-primary-bg);
    color: var(--chat-primary);
}

/* ── Search bar ───────────────────────────────────── */

.chat-widget__search-bar {
    display: none;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 1rem;
    background: #fff;
    border-bottom: 1px solid #f0f0f5;
}

.chat-widget__search-bar.is-open {
    display: flex;
}

.chat-widget__search-bar input {
    flex: 1;
    min-width: 0;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.3rem 0.6rem;
    font-size: 0.86rem;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.chat-widget__search-bar input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px var(--chat-primary-ring);
}

#chat-search-clear {
    border: 0;
    background: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 1.15rem;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    transition: color 100ms ease;
}

#chat-search-clear:hover {
    color: #374151;
}

.chat-message.is-search-hidden {
    display: none;
}

.chat-widget__mobile-back {
    display: none;
    font-size: 0.8rem;
    border: 0;
    background: transparent;
    color: var(--chat-primary);
    padding: 0;
    cursor: pointer;
    touch-action: manipulation;
    font-weight: 500;
}

.chat-widget__thread-info strong {
    font-size: 0.94rem;
    color: #1f2937;
}

.chat-widget__participants-title {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: #9ca3af;
    font-size: 0.76rem;
    margin-top: 0.15rem;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: color 150ms ease;
}

.chat-widget__participants-title:hover {
    color: #6b7280;
}

.chat-widget__participants-toggle-icon {
    display: inline-block;
    transition: transform 200ms ease;
}

.chat-widget__participants-title.is-open .chat-widget__participants-toggle-icon {
    transform: rotate(180deg);
}

.chat-widget__participants.is-collapsed {
    display: none;
}

.chat-widget__participants {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.3rem;
}

.chat-widget__participant {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border-radius: 999px;
    background: #f3f4f6;
    color: #4b5563;
    padding: 0.12rem 0.5rem;
    font-size: 0.74rem;
    line-height: 1.35;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-widget__participant::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chat-primary-light);
    flex-shrink: 0;
}

/* ── Messages ────────────────────────────────────────── */

.chat-widget__messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.chat-widget__messages::-webkit-scrollbar {
    width: 5px;
}

.chat-widget__messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-widget__messages::-webkit-scrollbar-thumb {
    border-radius: 3px;
    background: #d1d5db;
}

.chat-widget__messages-empty {
    color: #9ca3af;
    text-align: center;
    padding: 2rem 1rem;
    font-size: 0.9rem;
}

.chat-message {
    display: flex;
    justify-content: flex-start;
    animation: chat-msg-in 200ms ease both;
    position: relative;
    z-index: 1;
    overflow: visible;
}

@keyframes chat-msg-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.is-me {
    justify-content: flex-end;
}

.chat-message__content {
    position: relative;
    width: fit-content;
    max-width: 75%;
    padding-right: 22px;
    margin-left: 6px;
}

.chat-message.is-me .chat-message__content {
    padding-right: 0;
    padding-left: 22px;
    margin-left: 0;
}

.chat-message__bubble {
    max-width: 100%;
    border-radius: 14px 14px 14px 4px;
    background: #fff;
    padding: 0.55rem 0.75rem;
    word-wrap: break-word;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    font-size: 0.9rem;
    line-height: 1.45;
    color: #1f2937;
    position: relative;
}

.chat-message.is-me .chat-message__bubble {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: #fff;
    border-radius: 14px 14px 4px 14px;
    box-shadow: 0 2px 8px var(--chat-primary-shadow-light);
}

/* 3-dot actions menu */
.chat-message__actions-wrap {
    position: absolute;
    top: 0.3rem;
    right: -6px;
    opacity: 0;
    transition: opacity 150ms ease;
    z-index: 10;
}

.chat-message.is-me .chat-message__actions-wrap {
    right: auto;
    left: -6px;
}

.chat-message__actions-wrap.is-open {
    z-index: 120;
}

.chat-message.is-editing {
    position: relative;
    z-index: 40;
}

.chat-message:hover,
.chat-message:focus-within {
    z-index: 20;
}

.chat-message:hover .chat-message__actions-wrap,
.chat-message__actions-wrap.is-open {
    opacity: 1;
}

.chat-message__actions-trigger {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 0;
    background: #f3f4f6;
    color: #9ca3af;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 100ms ease, color 100ms ease;
}

.chat-message__actions-trigger:hover {
    background: #e5e7eb;
    color: #374151;
}

.chat-message__actions-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.06);
    min-width: 140px;
    padding: 4px;
    z-index: 121;
}

.chat-message__actions-wrap.is-open .chat-message__actions-menu {
    display: block;
}

.chat-message__action-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: none;
    padding: 0.4rem 0.65rem;
    font-size: 0.82rem;
    color: #374151;
    cursor: pointer;
    border-radius: 6px;
    transition: background 100ms ease;
}

.chat-message__action-item:hover {
    background: #f3f4f6;
}

.chat-message__action-item--danger {
    color: var(--chat-danger);
}

.chat-message__action-item--danger:hover {
    background: #fef2f2;
}

/* edited label */
.chat-message__edited {
    font-style: italic;
    opacity: 0.7;
    font-size: 0.68rem;
}

/* inline edit mode */
.chat-message__edit-textarea {
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 0.35rem 0.5rem;
    font-size: 0.9rem;
    line-height: 1.4;
    resize: none;
    background: #ffffff;
    color: #1f2937;
    outline: none;
    margin-top: 0.25rem;
    min-height: 36px;
}

.chat-message__edit-textarea:focus {
    border-color: rgba(59, 130, 246, 0.6);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.chat-message__edit-actions {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.3rem;
}

.chat-message__edit-save,
.chat-message__edit-cancel {
    border: 0;
    border-radius: 6px;
    padding: 0.2rem 0.55rem;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 100ms ease;
}

.chat-message__edit-save:disabled,
.chat-message__edit-cancel:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-message__edit-save {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.chat-message__edit-save:hover {
    background: rgba(255, 255, 255, 0.35);
}

.chat-message__edit-cancel {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
}

.chat-message__edit-cancel:hover {
    color: #fff;
}

.chat-message__meta {
    display: block;
    margin-bottom: 0.2rem;
    font-size: 0.72rem;
    color: #9ca3af;
}

.chat-message.is-me .chat-message__meta {
    color: rgba(255, 255, 255, 0.7);
}

.chat-message__image {
    max-width: 220px;
    border-radius: 8px;
}

.chat-message.is-me .chat-message__bubble a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
}

.chat-message__reply {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    border-left: 3px solid rgba(59, 130, 246, 0.45);
    border-radius: 10px;
    background: rgba(243, 244, 246, 0.95);
    padding: 0.45rem 0.6rem;
    margin-bottom: 0.45rem;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease,
        transform 120ms ease;
}

.chat-message__reply:hover {
    background: rgba(229, 231, 235, 0.98);
    border-left-color: rgba(59, 130, 246, 0.75);
    transform: translateY(-1px);
}

.chat-message__reply-sender,
.chat-message__reply-body {
    display: block;
}

.chat-message__reply-sender {
    font-size: 0.74rem;
    font-weight: 700;
    color: #1d4ed8;
    margin-bottom: 0.1rem;
}

.chat-message__reply-body {
    font-size: 0.78rem;
    color: #4b5563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-message.is-me .chat-message__reply {
    background: rgba(255, 255, 255, 0.16);
    border-left-color: rgba(255, 255, 255, 0.45);
}

.chat-message.is-me .chat-message__reply:hover {
    background: rgba(255, 255, 255, 0.22);
    border-left-color: rgba(255, 255, 255, 0.72);
}

.chat-message.is-me .chat-message__reply-sender {
    color: rgba(255, 255, 255, 0.95);
}

.chat-message.is-me .chat-message__reply-body {
    color: rgba(255, 255, 255, 0.82);
}

.chat-message.is-reply-target .chat-message__bubble {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.32),
        0 10px 28px rgba(59, 130, 246, 0.14);
}

/* ── Composer ────────────────────────────────────────── */

.chat-widget__composer {
    border-top: 1px solid #f0f0f5;
    padding: 0.65rem 1rem;
    background: #fff;
    flex-shrink: 0;
}

.chat-widget__reply-preview {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    padding: 0.55rem 0.7rem;
    border-left: 3px solid var(--chat-primary);
    border-radius: 10px;
    background: #f8fafc;
}

.chat-widget__reply-preview-content {
    min-width: 0;
}

.chat-widget__reply-preview-content strong,
.chat-widget__reply-preview-content span {
    display: block;
}

.chat-widget__reply-preview-content strong {
    color: var(--chat-primary-dark);
    font-size: 0.76rem;
    margin-bottom: 0.1rem;
}

.chat-widget__reply-preview-content span {
    color: #4b5563;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-widget__reply-preview-cancel {
    border: 0;
    background: transparent;
    color: #6b7280;
    width: 24px;
    height: 24px;
    line-height: 24px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
    transition: background 120ms ease, color 120ms ease;
}

.chat-widget__reply-preview-cancel:hover {
    background: rgba(15, 23, 42, 0.06);
    color: #111827;
}

.chat-widget__composer-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.chat-widget__composer-row textarea {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    resize: none;
    outline: none;
    min-height: 38px;
    max-height: 120px;
    transition: border-color 150ms ease, box-shadow 150ms ease;
    line-height: 1.4;
}

.chat-widget__composer-row textarea:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.08);
}

.chat-widget__composer-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    padding-bottom: 2px;
}

.chat-widget__attach-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 0;
    background: #f3f4f6;
    color: #6b7280;
    cursor: pointer;
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 150ms ease, color 150ms ease;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.chat-widget__attach-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.chat-widget__attach-btn.has-file {
    background: var(--chat-primary-bg);
    color: var(--chat-primary);
}

.chat-widget__attach-btn svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.chat-widget__attach-btn input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    font-size: 0;
}

.chat-widget__send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 0;
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: #fff;
    cursor: pointer;
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity 150ms ease, transform 100ms ease;
    flex-shrink: 0;
}

.chat-widget__send-btn:hover {
    opacity: 0.9;
}

.chat-widget__send-btn:active {
    transform: scale(0.92);
}

.chat-widget__send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-widget__send-btn svg {
    width: 18px;
    height: 18px;
}

.chat-widget__file-preview {
    padding: 0.3rem 0;
    display: none;
}

.chat-widget__file-preview.is-visible {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.chat-widget__file-preview-name {
    font-size: 0.76rem;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.chat-widget__file-preview-remove {
    border: none;
    background: none;
    color: var(--chat-danger);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0;
    flex-shrink: 0;
}

/* ── Empty state ─────────────────────────────────────── */

.chat-empty-state {
    display: grid;
    place-items: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
}

.chat-empty-state p {
    color: #9ca3af;
    font-size: 0.92rem;
}

#chat-root {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

/* ── Mobile responsive ───────────────────────────────── */

@media (max-width: 991px) {
    .elev-chat-launcher {
        right: 16px;
        bottom: 16px;
    }

    .elev-chat-widget {
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100dvh;
        border-radius: 0;
        transform: translateY(100%);
    }

    .elev-chat-widget.elev-chat-widget--expanded {
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100dvh;
        border-radius: 0;
    }

    .elev-chat-widget.is-open {
        transform: translateY(0);
    }

    .chat-widget__body {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        height: calc(100% - 54px);
    }

    .elev-chat-widget--has-thread .chat-widget__sidebar {
        display: none;
    }

    .elev-chat-widget--has-thread .chat-widget__thread {
        display: flex;
    }

    .elev-chat-widget--has-thread .chat-widget__mobile-back {
        display: inline-flex;
    }

    .elev-chat-widget:not(.elev-chat-widget--has-thread) .chat-widget__thread {
        display: none;
    }

    .elev-chat-widget--thread-only.elev-chat-widget:not(.elev-chat-widget--has-thread) .chat-widget__thread {
        display: flex;
    }

    .chat-widget__thread-header,
    .chat-widget__composer {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .chat-widget__composer {
        padding-bottom: max(0.65rem, env(safe-area-inset-bottom));
    }

    .chat-widget__sidebar {
        border-right: 0;
    }
}
