.wa-delete-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.wa-delete-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.wa-delete-modal-box {
    position: relative;
    background: #fff;
    border-radius: 10px;
    padding: 18px 20px;
    width: 320px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-family: 'Quicksand', sans-serif;
}

.wa-delete-modal-title {
    font-weight: 600;
    font-size: 16px;
}

.wa-delete-modal-text {
    font-size: 13px;
    color: #54656f;
}

.wa-delete-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.wa-delete-cancel {
    border: none;
    background: #f0f2f5;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.wa-delete-confirm {
    border: none;
    background: #e11d48;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.wa-delete-confirm:hover {
    background: #be123c;
}

/* DELETED MESSAGE STYLE */
.wa-message-deleted .wa-bubble {
    background: #f1f2f4 !important;
    color: #667781;
    font-style: italic;
}

/* FAILED MESSAGE STYLE */
.wa-message-failed .wa-bubble {
    background: #fff5f5 !important;
    border: 1px solid #fed7d7;
    box-shadow: none;
}

.wa-message-failed .wa-message-actions {
    display: none !important;
}

.wa-message-failed .wa-bubble:hover {
    padding-left: 12px !important;
    padding-right: 12px !important;
}

.wa-failed-label {
    display: block;
    color: #e53e3e;
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
    text-align: right;
}

.whatsapp-container {
    display: flex;
    height: 75vh;
    background: #f0f2f5;
    border: 1px solid #ddd;
}

.wa-empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #667781;
    background: #efeae2;
}

.wa-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.wa-empty-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.wa-empty-text {
    font-size: 14px;
}

/* SIDEBAR */

.wa-sidebar {
    width: 320px;
    background: white;
    border-right: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
}

.wa-search {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.wa-search input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.wa-chat-list {
    overflow-y: auto;
    flex: 1;
}

.wa-chat-item {
    display: flex;
    align-items: flex-start;
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f3f3f3;
}

.wa-chat-item:hover {
    background: #f5f6f6;
}

.wa-chat-item.active {
    background: #f0f2f5;
}

.wa-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #25D366;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 10px;
}

.wa-chat-info {
    flex: 1;
    min-width: 0;
    /* required for ellipsis to work inside flex */
}

.wa-chat-top {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.wa-last-message {
    font-size: 13px;
    color: #667781;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}

.wa-last-text {
    flex: 1;
    max-width: 20ch;
    /* roughly 20 characters */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wa-chat-item.active {
    background: #f0f2f5;
    border-left: 3px solid #25D366;
}

/* CHAT AREA */

.wa-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #efeae2;
}

.wa-chat-header {
    background: #f0f2f5;
    padding: 10px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #ddd;
}

.wa-header-info {
    margin-left: 10px;
}

.wa-header-name {
    font-weight: 600;
}

.wa-header-status {
    font-size: 12px;
    color: #667781;
}

/* add back button styles */
.wa-back-btn {
    display: none;
    margin-right: 10px;
    border: none;
    background: none;
    font-size: 18px;
    cursor: pointer;
}

@media (max-width:520px) {
    .wa-back-btn {
        display: block;
    }
}

/* MESSAGES */

.wa-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    position: relative;
}

.wa-chat-content {
    position: relative;
}

.wa-scroll-down {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 36px;
    background: #53bdeb;
    color: #fff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
    z-index: 20;
}

.wa-scroll-down.show {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
    animation: waScrollBounce 0.35s ease;
}

@keyframes waScrollBounce {
    0% {
        transform: translate(-50%, 8px);
    }

    60% {
        transform: translate(-50%, -3px);
    }

    100% {
        transform: translate(-50%, 0);
    }
}

/* NEW MESSAGES BAR (appears when user is scrolled up and new messages arrive) */
.wa-new-messages-bar {
    position: absolute;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%);
    background: #25D366;
    color: #fff;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
    z-index: 25;
}

.wa-new-messages-bar.show {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
    animation: waNewMsgBounce .35s ease;
}

@keyframes waNewMsgBounce {
    0% {
        transform: translate(-50%, 8px);
    }

    60% {
        transform: translate(-50%, -3px);
    }

    100% {
        transform: translate(-50%, 0);
    }
}

/* DATE DIVIDER (WhatsApp-like) */

.wa-date-divider {
    align-self: center;
    background: #e1f3fb;
    color: #54656f;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 7px;
    margin: 14px auto;
    width: fit-content;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}

.wa-message {
    display: flex;
    margin-bottom: 10px;
}

.wa-message.incoming {
    justify-content: flex-start;
}

.wa-message.outgoing {
    justify-content: flex-end;
}



.wa-bubble {
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 55%;
    /* WhatsApp-like bubble width */
    min-width: 70px;
    /* prevent tiny bubbles for very short messages */
    font-size: 14px;
    position: relative;
    padding-bottom: 30px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

/* REPLY PREVIEW (quoted message inside bubble) */

.wa-reply-preview {
    border-left: 4px solid #8696a0;
    background: rgba(0, 0, 0, 0.05);
    padding: 6px 0 6px 8px;
    /* Remove right padding to make room for absolute or flex thumb */
    margin-bottom: 6px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    overflow: hidden;
    min-height: 44px;
}

.wa-reply-preview:hover {
    background: rgba(0, 0, 0, 0.08);
}

.wa-reply-content-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-right: 8px;
}

.wa-reply-thumb-wrapper {
    width: 44px;
    height: 100%;
    flex-shrink: 0;
}

.wa-reply-rich-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    display: block;
}

.wa-reply-rich-icon-thumb {
    width: 44px;
    height: 44px;
    background: #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.wa-reply-rich-icon-thumb img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    opacity: 0.8;
}

.wa-reply-rich-icon-thumb i {
    position: absolute;
    font-size: 10px;
    color: rgba(0, 0, 0, 0.5);
    bottom: 4px;
    right: 4px;
}

.wa-reply-text i {
    margin-right: 4px;
    color: #8696a0;
}

/* reply preview color based on original message direction */
.wa-reply-incoming {
    background: #ffffff;
    border-left-color: #8696a0;
}

.wa-reply-outgoing {
    background: rgba(0, 0, 0, 0.04);
    border-left-color: #128C7E;
}

.wa-message.outgoing .wa-reply-preview {
    border-left-color: #128C7E;
}

.wa-reply-author {
    font-weight: 600;
    color: #25D366;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wa-message.outgoing .wa-reply-author {
    color: #128C7E;
}

.wa-reply-text {
    color: #54656f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.2;
}

/* MESSAGE ACTIONS (reply/edit buttons inside bubble) */

.wa-message-actions {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    opacity: 0;
    background: #000;
    border-radius: 0;
    transition: opacity .18s ease, transform .18s ease;
    transform: translateX(6px) scale(0.96);
}

/* outgoing messages: actions appear on right inside bubble */
.wa-message.outgoing .wa-message-actions {
    right: 0;
}

/* incoming messages: actions appear on left inside bubble */
.wa-message.incoming .wa-message-actions {
    left: 0;
}

/* keep outer corners rounded but inner side flat */
.wa-message.outgoing .wa-message-actions {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.wa-message.incoming .wa-message-actions {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

/* create space for icons only when hovering */

.wa-message.outgoing:not(.wa-message-deleted) .wa-bubble:hover {
    padding-right: 46px;
    min-width: 116px;
}


.wa-message.incoming:not(.wa-message-deleted) .wa-bubble:hover {
    padding-left: 46px;
    min-width: 116px;
}

.wa-edited {
    font-size: 11px;
    color: #8696a0;
    line-height: 1;
    margin-right: 4px;
}

.wa-message.outgoing .wa-bubble:hover .wa-edited {
    right: 42px;
}

.wa-message:not(.wa-message-deleted) .wa-bubble:hover .wa-message-actions,
.wa-message:not(.wa-message-deleted) .wa-message-actions:hover {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.wa-reply-btn,
.wa-edit-btn,
.wa-delete-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wa-reply-btn:hover,
.wa-edit-btn:hover,
.wa-delete-btn:hover {
    color: #25D366;
}

/* hide edit button for incoming messages */
.wa-message.incoming .wa-edit-btn {
    display: none;
}

.wa-message.incoming .wa-delete-btn {
    display: none;
}

.wa-message.incoming .wa-bubble {
    background: white;
}

.wa-message.outgoing .wa-bubble {
    background: #d9fdd3;
}

/* FILE PREVIEW AREA */

.wa-input-wrapper {
    display: flex;
    flex-direction: column;
}

.wa-file-preview {
    display: none;
    padding: 10px;
    background: #ffffff;
    border-top: 1px solid #eee;
    gap: 10px;
    flex-wrap: wrap;
}

.wa-file-preview.active {
    display: flex;
}

.wa-preview-item {
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #ddd;
    background: #f5f6f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.wa-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wa-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #000;
    color: #fff;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.85;
}

.wa-preview-remove:hover {
    opacity: 1;
}


/* FILE PREVIEW ITEMS (template-based) */

.wa-file-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #f6f7f8;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    max-width: 220px;
}

.wa-file-thumb {
    width: 32px;
    height: 32px;
    background: #e9edef;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    overflow: hidden;
}

.wa-file-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wa-file-name {
    flex: 1;
    font-size: 12px;
    color: #3b4a54;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-file-remove {
    border: none;
    background: transparent;
    color: #667781;
    font-size: 14px;
    cursor: pointer;
}

.wa-file-remove:hover {
    color: #e11d48;
}

/* MESSAGE ACTION BAR (reply/edit preview) */

.wa-message-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: #f0f2f5;
    border-top: 1px solid #e5e5e5;
    border-bottom: 1px solid #e5e5e5;
    font-size: 13px;
}

.wa-message-action-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.wa-message-action-label {
    font-weight: 600;
    color: #25D366;
    font-size: 12px;
}

.wa-message-action-text {
    color: #54656f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

.wa-message-action-close {
    background: none;
    border: none;
    color: #54656f;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wa-message-action-close:hover {
    color: #25D366;
}

/* INPUT */

.wa-input {
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #ddd;
    background: white;
}

.wa-attach {
    background: #f0f2f5;
    border: 1px solid #ddd;
    color: #54656f;
    width: 42px;
    height: 42px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s ease;
}

.wa-attach:hover {
    background: #e9edef;
    color: #0ba17d;
    border-color: #0ba17d;
}

.wa-file-input {
    display: none;
}

.wa-text-input {
    flex: 1;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.wa-send-btn {
    background: #25D366;
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
}

/* GHOST MODE STYLES */
.wa-is-ghost-mode {
    background-color: #e9ecef !important;
    color: #54656f !important;
    opacity: 0.7 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

#wa-ghost-indicator {
    margin-left: 10px;
    font-size: 11px;
    background: #54656f;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* DISABLE HOVER ACTIONS IN GHOST MODE */
.wa-ghost-mode-active .wa-bubble:hover {
    padding-right: 12px !important;
    padding-left: 12px !important;
    min-width: 70px !important;
}

.wa-ghost-mode-active .wa-message-actions {
    display: none !important;
}

.wa-ghost-mode-active .wa-media-reply {
    display: none !important;
}

.wa-send-btn:hover {
    background: #1eb954;
}

/* TEMPLATE SELECTION */
.wa-input-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.wa-template-btn {
    background: #f0f2f5;
    border: 1px solid #ddd;
    color: #54656f;
    width: 42px;
    height: 42px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s ease;
}

.wa-template-btn:hover {
    background: #e9edef;
    color: #25D366;
    border-color: #25D366;
}

.wa-static-btn {
    background: #f0f2f5;
    border: 1px solid #ddd;
    color: #54656f;
    width: 42px;
    height: 42px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s ease;
}

.wa-static-btn:hover {
    background: #e9edef;
    color: #0ba17d;
    border-color: #0ba17d;
}

/* MODAL STYLES */
.wa-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wa-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
}

.wa-modal-content {
    position: relative;
    background: white;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: waModalFadeUp 0.3s ease;
}

@keyframes waModalFadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wa-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f0f2f5;
}

.wa-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #3b4a54;
    font-family: 'Montserrat', sans-serif;
}

.wa-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #667781;
    cursor: pointer;
    padding: 4px;
}

.wa-modal-close:hover {
    color: #e11d48;
}

.wa-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    background: #f8f9fa;
    font-family: 'Quicksand', sans-serif;
}

/* TEMPLATE LIST */
.wa-template-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wa-template-card {
    background: white;
    border: 1px solid #e9edef;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Quicksand', sans-serif;
}

.wa-template-card:hover {
    border-color: #25D366;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.1);
    transform: translateY(-2px);
}

.wa-template-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    align-items: center;
}

.wa-template-name {
    font-weight: 700;
    color: #111b21;
    font-size: 15px;
    font-family: 'Montserrat', sans-serif;
}

.wa-template-category {
    font-size: 11px;
    background: #e1f3fb;
    color: #035a7d;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 600;
}

.wa-template-body {
    font-size: 14px;
    color: #54656f;
    line-height: 1.5;
    white-space: pre-wrap;
}

.wa-template-lang {
    font-size: 12px;
    color: #8696a0;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.wa-loading-templates {
    text-align: center;
    padding: 40px;
    color: #667781;
}

.wa-no-templates {
    text-align: center;
    padding: 40px;
    color: #667781;
}

/* TEMPLATE BUTTONS & FOOTER */
.wa-template-footer {
    font-size: 11px;
    color: #8696a0;
    margin-top: 4px;
    padding-bottom: 2px;
}

.wa-template-buttons {
    display: flex;
    flex-direction: column;
    margin-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    margin-left: -12px;
    margin-right: -12px;
    margin-bottom: -25px;
    /* Adjust to sit at bottom of bubble */
}

.wa-template-button {
    text-align: center;
    padding: 10px;
    color: #008069;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s ease;
}

.wa-template-button:last-child {
    border-bottom: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.wa-template-button:hover {
    background: rgba(0, 0, 0, 0.02);
}

.wa-template-button i {
    font-size: 14px;
}

.wa-message.incoming .wa-template-button {
    color: #008069;
}

.wa-message.outgoing .wa-template-button {
    color: #008069;
}

.wa-send-btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

.wa-send-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: waSpin 0.7s linear infinite;
    display: inline-block;
}

@keyframes waSpin {
    to {
        transform: rotate(360deg);
    }
}

/* MESSAGE META (TIME + TICKS) */

.wa-text {
    display: block;
    margin: 0 0 10px;
}

/* MEDIA INSIDE MESSAGE BUBBLE */

.wa-media {
    margin-bottom: 6px;
}

.wa-media-image {
    max-width: 240px;
    max-height: 240px;
    border-radius: 6px;
    display: block;
    cursor: pointer;
}

.wa-media-video {
    max-width: 240px;
    border-radius: 6px;
    display: block;
}


.wa-media-doc {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid #e4e6e7;
    border-radius: 8px;
    padding: 12px 10px;
    text-decoration: none;
    width: 280px;
    /* Fixed standard width for docs */
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin-bottom: 4px;
}

.wa-media-doc:hover {
    background: #f5f6f6;
}

.wa-media-doc-icon {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.wa-media-doc-name {
    flex: 1;
    font-size: 13px;
    color: #111b21;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    /* Allow the flex child to shrink below its content's width */
}

.wa-meta {
    position: absolute;
    bottom: 4px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #667781;
}

.wa-message.outgoing:not(.wa-message-deleted) .wa-bubble:hover .wa-meta {
    right: 42px;
}

.wa-tick {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    line-height: 1;
    margin-left: 2px;
    transform-origin: center;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.wa-tick svg path {
    transition: fill 0.25s ease;
}

.wa-tick-animate {
    animation: waTickPop 0.22s ease;
}

@keyframes waTickPop {
    0% {
        transform: scale(0.75);
        opacity: 0;
    }

    70% {
        transform: scale(1.08);
        opacity: 1;
    }

    100% {
        transform: scale(1);
    }
}

.wa-message.incoming .wa-meta {
    right: 8px;
}

.wa-message.outgoing .wa-meta {
    right: 8px;
}

/* TICKS */

.wa-ticks {
    font-size: 11px;
}

.wa-ticks.double {
    letter-spacing: -2px;
}

.wa-ticks.blue {
    color: #53bdeb;
}

.wa-unread {
    background: #53bdeb;
    color: white;
    width: 20px;
    height: 20px;
    text-align: center;
    line-height: 20px;
    border-radius: 50%;
}

.wa-text-input {
    resize: none;
    overflow: hidden;
}

.wa-tick-animate {
    animation: waTickFade 0.25s ease;
}

@keyframes waTickFade {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* conversation move animation */
.wa-move-up {
    animation: waMoveUp 0.45s ease;
}

@keyframes waMoveUp {
    0% {
        transform: translateY(12px);
        background: #e9f5ff;
    }

    60% {
        transform: translateY(-2px);
    }

    100% {
        transform: translateY(0);
        background: transparent;
    }
}

/* MESSAGE FOCUS HIGHLIGHT */
.wa-message-focus .wa-bubble {
    animation: waFocusPulse 2s ease forwards;
}

@keyframes waFocusPulse {
    0% {
        background: #e7f3ff;
    }

    30% {
        background: #cfe9ff;
    }

    100% {
        /* return to original by not specifying background here or using inherit */
    }
}

/* MOBILE RESPONSIVE */

@media (max-width: 768px) {

    .whatsapp-container {
        flex-direction: column;
        height: auto;
    }

    .wa-sidebar {
        width: 100%;
        height: 300px;
        border-right: none;
        border-bottom: 1px solid #e5e5e5;
    }

    .wa-chat-area {
        height: calc(100vh - 380px);
    }

    .wa-chat-list {
        max-height: 240px;
    }

    .wa-messages {
        padding: 10px;
    }

    .wa-bubble {
        max-width: 80%;
        font-size: 13px;
    }

    .wa-input {
        gap: 6px;
        padding: 8px;
    }

    .wa-input input {
        font-size: 14px;
    }

    .wa-input button {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* SMALL PHONE MODE (WhatsApp-like behavior) */

@media (max-width: 520px) {

    .wa-sidebar {
        height: 100%;
    }

    .wa-chat-area {
        display: none;
    }

    .wa-sidebar.chat-open {
        display: none;
    }

    .wa-chat-area.chat-open {
        display: flex;
        height: calc(100vh - 140px);
    }
}


/* IMAGE GRID (WhatsApp style) */

.wa-media-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    margin-bottom: 6px;
    max-width: 320px;
    /* prevent giant images */
}

.wa-media-grid-item {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    cursor: pointer;
}

.wa-media-grid-item img {
    width: 100%;
    height: 140px;
    /* WhatsApp-like thumbnail size */
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}

/* Zoom-out cursor for image viewer */
.wa-media-image-viewer {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.wa-media-grid-more {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}


/* MEDIA VIEWER (fullscreen image viewer) */

.wa-media-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 9999;
}

.wa-media-viewer-content {
    position: relative;
    width: 720px;
    height: 500px;
    max-width: 80vw;
    max-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* close button */
/* removed close button styles since close button moved to toolbar */

/* navigation arrows */
.wa-media-prev,
.wa-media-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    padding: 10px;
}

.wa-media-prev:hover,
.wa-media-next:hover {
    color: #25D366;
}

.wa-media-prev {
    left: -70px;
}

.wa-media-next {
    right: -70px;
}

/* thumbnails strip */
.wa-media-thumbs {
    position: absolute;
    bottom: -130px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 8px;
    max-width: 90vw;
}

.wa-media-thumb {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.65;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.wa-media-thumb.active {
    opacity: 1;
    border-color: #25D366;
}

/* hide overlay click layer visually but keep it clickable */
.wa-media-overlay {
    position: absolute;
    inset: 0;
}

/* MEDIA VIEWER TOP TOOLBAR */

.wa-media-toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    background: rgba(0, 0, 0, 0.55);
    z-index: 10001;
    font-family: 'Quicksand', sans-serif;
}

.wa-media-toolbar-left {
    position: absolute;
    left: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: #fff;
    line-height: 1.2;
}

.wa-media-sender {
    font-size: 14px;
    font-weight: 600;
}

.wa-media-time {
    font-size: 12px;
    color: #d1d7db;
}

.wa-media-toolbar-center {
    color: #fff;
    font-size: 14px;
}

.wa-media-toolbar-actions {
    position: absolute;
    right: 20px;
    display: flex;
    gap: 14px;
}


.wa-media-download,
.wa-media-close,
.wa-media-reply,
.wa-media-goto {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    text-decoration: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}


.wa-media-download:hover,
.wa-media-close:hover,
.wa-media-reply:hover,
.wa-media-goto:hover {
    color: #25D366;
}

/* adjust viewer spacing so toolbar doesn't overlap image */

.wa-media-viewer-content {
    margin-top: 40px;
}

.wa-media-download:focus,
.wa-media-close:focus,
.wa-media-reply:focus,
.wa-media-goto:focus {
    outline: none;
    color: #fff;
}

.wa-global-unread {
    position: absolute;
    top: -6px;
    left: -16px;
    background: #25D366;
    color: #fff;
    font-size: 11px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    box-shadow: 0 0 0 2px #fff;
}

/* REPLY MEDIA STYLES */
.wa-reply-media-thumb {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 4px;
    vertical-align: middle;
}

.wa-reply-doc-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 2px;
}

.wa-reply-text i {
    margin-right: 4px;
    color: #8696a0;
}

/* VOICE RECORDING UI & INPUT ACTIONS */
.wa-mic-btn,
.wa-emoji-btn,
.wa-static-btn,
.wa-template-btn {
    background: #f0f2f5;
    border: 1px solid #ddd;
    color: #54656f;
    width: 42px;
    height: 42px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s ease;
}

.wa-mic-btn:hover,
.wa-emoji-btn:hover,
.wa-static-btn:hover,
.wa-template-btn:hover {
    background: #e9edef;
    color: #00a884;
    border-color: #00a884;
}

.wa-mic-btn:hover {
    color: #e11d48;
    border-color: #e11d48;
}


.wa-recording-ui {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: transparent;
    height: 62px;
    box-sizing: border-box;
    flex: 1;
}

.wa-recording-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.wa-recording-cancel {
    background: none;
    border: none;
    color: #ea4335;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.wa-recording-cancel:hover {
    color: #c5221f;
}

.wa-recording-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    color: #54656f;
}

.wa-recording-dot {
    width: 10px;
    height: 10px;
    background: #ea4335;
    border-radius: 50%;
    animation: wa-pulse-red 1.2s infinite;
}

@keyframes wa-pulse-red {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(234, 67, 53, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(234, 67, 53, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(234, 67, 53, 0);
    }
}

.wa-recording-timer {
    font-size: 16px;
    min-width: 50px;
}

.wa-recording-right {
    display: flex;
    align-items: center;
}

.wa-recording-stop {
    background: #25D366;
    border: none;
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.wa-recording-stop:hover {
    transform: scale(1.1);
    background: #1eb954;
}

/* EMOJI PICKER POPUP */

.wa-emoji-container {
    position: absolute;
    bottom: 60px;
    right: 110px;
    /* Adjusted to be above the emoji button */
    z-index: 1000;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    animation: waFadeInUp 0.15s ease-out;
}

emoji-picker {
    --num-columns: 8;
    width: 320px;
    height: 400px;
}

/* LARGE EMOJI SUPPORT */
.wa-message.incoming .wa-bubble-emoji-only,
.wa-message.outgoing .wa-bubble-emoji-only {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    min-width: unset !important;
    position: relative;
    margin-bottom: 20px !important;
    /* Add bottom margin for meta */
}

.wa-bubble-emoji-only .wa-message-body {
    padding: 0 !important;
}

.wa-bubble-emoji-only .wa-text {
    margin: 0 !important;
}

.wa-emoji-count-1 .wa-text {
    font-size: 4rem;
    line-height: 1.1;
}

.wa-emoji-count-2 .wa-text {
    font-size: 3rem;
    line-height: 1.1;
}

.wa-emoji-count-3 .wa-text {
    font-size: 2.2rem;
    line-height: 1.1;
}

/* Hide tail but KEEP meta for plain emoji messages */
.wa-bubble-emoji-only::before,
.wa-bubble-emoji-only::after {
    display: none !important;
}

.wa-bubble-emoji-only .wa-meta {
    position: absolute;
    bottom: -18px;
    right: 0;
    display: flex;
    background: rgba(255, 255, 255, 0.7);
    padding: 2px 5px;
    border-radius: 10px;
    backdrop-filter: blur(2px);
    pointer-events: none;
}

.wa-bubble-emoji-only .wa-message-content {
    transition: transform 0.2s cubic-bezier(0.1, 0.7, 0.1, 1);
}

/* Ensure hover actions work ONLY on the bubble itself for emojis */
.wa-bubble-emoji-only:hover .wa-message-actions {
    opacity: 1;
    visibility: visible;
}

.wa-message.outgoing .wa-bubble-emoji-only:hover .wa-message-content {
    transform: translateX(-35px);
}

.wa-message.incoming .wa-bubble-emoji-only:hover .wa-message-content {
    transform: translateX(35px);
}

.wa-bubble-emoji-only:hover .wa-message-actions {
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.wa-message.incoming .wa-bubble-emoji-only .wa-message-actions {
    left: -35px;
    right: auto;
}

.wa-message.incoming .wa-bubble-emoji-only:hover .wa-message-actions {
    left: 0;
}

/* VOICE MESSAGE PLAYER FIX */
.wa-audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    min-width: 240px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    margin-top: 5px;
}

.wa-audio-control {
    width: 38px;
    height: 38px;
    background: #25D366;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
}

.wa-audio-control i {
    margin-left: 2px;
}

.wa-audio-progress-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.wa-audio-slider {
    width: 100%;
    height: 4px;
    cursor: pointer;
    accent-color: #25D366;
}

.wa-audio-slider::-webkit-slider-thumb {
    width: 8px;
    /* MADE SMALLER */
    height: 8px;
    /* MADE SMALLER */
}

.wa-audio-info {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #667781;
    margin-top: 6px;
    /* ADDED MORE SPACE */
}

/* MOBILE IMPROVEMENTS */
@media (max-width: 768px) {
    .wa-input {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        padding: 12px 15px !important;
        gap: 12px !important;
        background: #ffffff !important;
        border-top: 1px solid #e0e0e0 !important;
        align-items: center !important;
    }

    .wa-attach {
        order: 1 !important;
        margin-right: auto !important;
        width: 42px !important;
        height: 42px !important;
        background: #f8f9fa !important;
        border: 1px solid #dee2e6 !important;
        border-radius: 10px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: #495057 !important;
    }

    .wa-input-actions {
        order: 2 !important;
        display: flex !important;
        flex: none !important;
        justify-content: flex-end !important;
        gap: 8px !important;
    }

    .wa-text-input {
        order: 3 !important;
        width: 100% !important;
        flex: none !important;
        min-height: 140px !important;
        padding: 12px 15px !important;
        font-size: 16px !important;
        border-radius: 12px !important;
        border: 1.5px solid #e9ecef !important;
        background-color: #f8f9fa !important;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03) !important;
        resize: none !important;
    }

    .wa-send-btn {
        order: 4 !important;
        width: 100% !important;
        margin-top: 4px !important;
        padding: 15px !important;
        font-weight: 700 !important;
        font-size: 16px !important;
        border-radius: 12px !important;
        height: 52px !important;
        background: #25D366 !important;
        color: white !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border: none !important;
        box-shadow: 0 4px 10px rgba(37, 211, 102, 0.2) !important;
    }

    /* Action buttons: same style as attach button */
    .wa-static-btn,
    .wa-template-btn,
    .wa-emoji-btn,
    .wa-mic-btn {
        width: 42px !important;
        height: 42px !important;
        border-radius: 10px !important;
        background: #f8f9fa !important;
        border: 1.5px solid #dee2e6 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: #495057 !important;
        transition: all 0.2s ease !important;
    }

    .wa-static-btn:active,
    .wa-template-btn:active,
    .wa-emoji-btn:active,
    .wa-mic-btn:active,
    .wa-attach:active {
        background: #e9ecef !important;
        transform: scale(0.95) !important;
    }

    /* Preview adjustments */
    .wa-file-preview {
        padding: 12px !important;
        width: 100% !important;
        order: 2.5 !important;
        /* Between actions and textarea */
    }
}

/* TEMPLATE CONFIRM MODAL PREMIUM STYLES */
#wa-confirm-modal .wa-modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: waConfirmPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes waConfirmPop {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

#wa-confirm-body {
    max-height: 250px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #25D366 transparent;
}

#wa-confirm-body::-webkit-scrollbar {
    width: 4px;
}

#wa-confirm-body::-webkit-scrollbar-thumb {
    background-color: #25D366;
    border-radius: 10px;
}

#wa-confirm-send {
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

#wa-confirm-send:hover {
    background: #1eb954 !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(37, 211, 102, 0.4);
}

#wa-confirm-send:active {
    transform: translateY(0);
}

#wa-confirm-cancel {
    transition: all 0.2s ease;
}

#wa-confirm-cancel:hover {
    background: #f8f9fa !important;
    border-color: #ccc !important;
    color: #333 !important;
}