/* ── Live Chat Widget ───────────────────────────────────────────── */

.live-chat-widget-root {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1050;
    font-family: inherit;
}

/* ── Floating toggle button ───────────────────────────────────── */

.live-chat-toggle-wrap {
    position: relative;
    width: 64px;
    height: 64px;
}

.live-chat-pulse-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(169, 33, 142, 0.45);
    animation: live-chat-pulse 2.8s ease-out infinite;
    pointer-events: none;
}

.live-chat-pulse-ring--delayed {
    animation-delay: 1.4s;
}

.live-chat-toggle {
    position: relative;
    z-index: 2;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, #a9218e 0%, #6b2d8f 45%, #2c7be5 100%);
    box-shadow:
        0 8px 24px rgba(169, 33, 142, 0.35),
        0 4px 8px rgba(0, 0, 0, 0.12);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    outline: none;
}

.live-chat-toggle:hover {
    transform: scale(1.06);
    box-shadow:
        0 12px 32px rgba(169, 33, 142, 0.45),
        0 6px 12px rgba(0, 0, 0, 0.15);
}

.live-chat-toggle:active {
    transform: scale(0.96);
}

.live-chat-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    line-height: 1;
}

/* Awake bouncing animation */
.live-chat-bounce-awake {
    animation: live-chat-bounce-awake 3s ease-in-out infinite;
}

.live-chat-widget-root.is-open .live-chat-bounce-awake,
.live-chat-widget-root.is-open .live-chat-pulse-ring {
    animation-play-state: paused;
}

.live-chat-widget-root.has-unread .live-chat-bounce-awake {
    animation-duration: 2s;
}

@keyframes live-chat-bounce-awake {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

@keyframes live-chat-pulse {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    70% {
        transform: scale(1.55);
        opacity: 0;
    }
    100% {
        transform: scale(1.55);
        opacity: 0;
    }
}

.live-chat-unread-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff6b6b, #e63757);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(230, 55, 87, 0.5);
    animation: live-chat-badge-pop 0.4s ease;
}

@keyframes live-chat-badge-pop {
    0% { transform: scale(0.5); }
    70% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ── Chat panel ───────────────────────────────────────────────── */

.live-chat-panel {
    position: absolute;
    right: 0;
    bottom: 80px;
    width: 380px;
    max-width: calc(100vw - 32px);
    max-height: 560px;
    background: #fff;
    border-radius: 16px;
    box-shadow:
        0 20px 60px rgba(30, 20, 50, 0.18),
        0 0 0 1px rgba(169, 33, 142, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: live-chat-panel-in 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes live-chat-panel-in {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.live-chat-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    background: linear-gradient(135deg, #a9218e 0%, #6b2d8f 55%, #4a3f8f 100%);
    color: #fff;
}

.live-chat-panel-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.live-chat-panel-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    backdrop-filter: blur(4px);
}

.live-chat-panel-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.live-chat-panel-subtitle {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 1px;
}

.live-chat-panel-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.live-chat-panel-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

.live-chat-panel-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.live-chat-section {
    padding: 14px 16px 0;
}

.live-chat-section-label {
    padding: 12px 16px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8b95a8;
}

/* ── Ticket list ────────────────────────────────────────────────── */

.live-chat-tickets {
    max-height: 340px;
    overflow-y: auto;
    padding: 4px 12px 12px;
}

.live-chat-tickets::-webkit-scrollbar,
.live-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.live-chat-tickets::-webkit-scrollbar-thumb,
.live-chat-messages::-webkit-scrollbar-thumb {
    background: #d0d7e2;
    border-radius: 4px;
}

.live-chat-ticket-item {
    padding: 12px 14px;
    margin-bottom: 8px;
    border-radius: 12px;
    border: 1px solid #eef1f6;
    background: #fafbfc;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.live-chat-ticket-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(169, 33, 142, 0.1);
    border-color: rgba(169, 33, 142, 0.25);
    background: #fff;
}

.live-chat-ticket-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.live-chat-ticket-number {
    font-weight: 700;
    font-size: 13px;
    color: #2d3748;
}

.live-chat-status-pill {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    background: #ede9fe;
    color: #6b2d8f;
    text-transform: capitalize;
}

.live-chat-status-pill.closed {
    background: #f1f3f5;
    color: #868e96;
}

.live-chat-status-pill.waiting {
    background: #fff3cd;
    color: #856404;
}

.live-chat-ticket-subject {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 2px;
}

.live-chat-ticket-preview {
    font-size: 12px;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-chat-empty-state {
    text-align: center;
    padding: 28px 16px;
    color: #95a0af;
}

.live-chat-empty-state i {
    font-size: 32px;
    margin-bottom: 10px;
    opacity: 0.5;
    display: block;
}

.live-chat-empty-state p {
    margin: 0;
    font-size: 13px;
}

/* ── Thread view ────────────────────────────────────────────────── */

.live-chat-thread-toolbar {
    padding: 10px 14px;
    border-bottom: 1px solid #eef1f6;
    background: #fafbfc;
}

.live-chat-back-btn {
    background: none;
    border: none;
    color: #a9218e;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    margin-bottom: 4px;
}

.live-chat-back-btn:hover {
    text-decoration: underline;
}

.live-chat-thread-title {
    font-size: 12px;
    color: #6c757d;
    font-weight: 600;
}

.live-chat-messages {
    min-height: 220px;
    max-height: 300px;
    overflow-y: auto;
    padding: 14px;
    background: linear-gradient(180deg, #f8f9fc 0%, #f3f5f9 100%);
}

.live-chat-message {
    margin-bottom: 10px;
    padding: 10px 13px;
    border-radius: 14px;
    max-width: 88%;
    word-break: break-word;
    font-size: 13px;
    line-height: 1.45;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.live-chat-message.mine {
    margin-left: auto;
    background: linear-gradient(135deg, #e8d4f0 0%, #dbeafe 100%);
    border-bottom-right-radius: 4px;
}

.live-chat-message.theirs {
    background: #fff;
    border: 1px solid #e8ecf2;
    border-bottom-left-radius: 4px;
}

.live-chat-message.system {
    background: transparent;
    color: #868e96;
    font-style: italic;
    font-size: 12px;
    max-width: 100%;
    text-align: center;
    box-shadow: none;
    padding: 6px;
}

.live-chat-message .meta {
    font-size: 10px;
    font-weight: 600;
    color: #a9218e;
    margin-bottom: 4px;
    opacity: 0.8;
}

.live-chat-image-input {
    display: none;
}

.live-chat-compose-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.live-chat-input-grow {
    flex: 1;
    min-width: 0;
}

.live-chat-btn-attach {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1.5px solid #e8ecf2;
    background: #f8f9fc;
    color: #6b2d8f;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}

.live-chat-btn-attach:hover {
    background: #f0e6f5;
    border-color: #d4b8e0;
}

.live-chat-image-wrap {
    margin-top: 2px;
}

.live-chat-message-image {
    display: block;
    max-width: 220px;
    max-height: 180px;
    border-radius: 8px;
    object-fit: contain;
    cursor: pointer;
}

.live-chat-image-caption {
    margin-top: 4px;
    font-size: 12px;
    color: #6c757d;
}

.live-chat-compose {
    padding: 12px 14px;
    border-top: 1px solid #eef1f6;
    background: #fff;
}

.live-chat-compose-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    gap: 8px;
}

/* ── Form elements ──────────────────────────────────────────────── */

.live-chat-new-form {
    padding: 14px 16px 16px;
    overflow-y: auto;
}

.live-chat-field-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8b95a8;
    margin-bottom: 5px;
}

.live-chat-input,
.live-chat-select {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 13px;
    color: #2d3748;
    background: #fafbfc;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    resize: vertical;
}

.live-chat-input:focus,
.live-chat-select:focus {
    outline: none;
    border-color: #a9218e;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(169, 33, 142, 0.12);
}

.live-chat-form-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Buttons ──────────────────────────────────────────────────── */

.live-chat-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.live-chat-btn:hover {
    transform: translateY(-1px);
}

.live-chat-btn:active {
    transform: translateY(0);
}

.live-chat-btn-block {
    width: 100%;
}

.live-chat-btn-primary {
    background: linear-gradient(135deg, #a9218e, #6b2d8f);
    color: #fff;
    box-shadow: 0 4px 12px rgba(169, 33, 142, 0.3);
}

.live-chat-btn-primary:hover {
    box-shadow: 0 6px 16px rgba(169, 33, 142, 0.4);
}

.live-chat-btn-success {
    background: linear-gradient(135deg, #2dce89, #2bb673);
    color: #fff;
    box-shadow: 0 4px 10px rgba(45, 206, 137, 0.3);
}

.live-chat-btn-outline-danger {
    background: transparent;
    color: #e63757;
    border: 1.5px solid #f5c2cb;
}

.live-chat-btn-outline-danger:hover {
    background: #fff5f5;
}

.live-chat-btn-ghost {
    background: #f1f3f5;
    color: #495057;
}

.live-chat-btn-ghost:hover {
    background: #e9ecef;
}

/* ── Mobile ───────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .live-chat-widget-root {
        right: 16px;
        bottom: 16px;
    }

    .live-chat-panel {
        width: calc(100vw - 32px);
        bottom: 76px;
        max-height: calc(100vh - 120px);
    }
}
