html,
body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background: #0b141a;
    color: #e9edef;
}

.wa-shell {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    max-width: 100%;
    overflow: hidden;
    position: relative;
}

.wa-sidebar {
    width: 34%;
    min-width: 300px;
    background: #111b21;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    flex-shrink: 0;
}

#chat-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.wa-chat {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: #0b141a;
    background-image: url('/assets/img/wa-doodle.svg');
    background-repeat: repeat;
    background-size: 380px auto;
    overflow: hidden;
    position: relative;
}

.wa-chat-header {
    flex-shrink: 0;
    z-index: 10;
}

.wa-messages {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
}

.wa-composer {
    flex-shrink: 0;
    z-index: 10;
    box-sizing: border-box;
}

.login-card {
    width: 100%;
    max-width: 420px;
}

.chat-preview-row {
    margin-top: 4px;
}

.chat-preview-unread {
    color: #e9edef;
    font-weight: 600;
}

.chat-name-unread {
    font-weight: 700;
}

.unread-badge {
    background: #25d366;
    color: #0b141a;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    flex-shrink: 0;
}

.reply-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: #202c33;
    border-top: 1px solid #2a3942;
    flex-shrink: 0;
}

.message-media-image {
    display: block;
    width: 100%;
    max-width: 320px;
    height: auto;
    max-height: min(280px, 48vh);
    object-fit: contain;
    border-radius: 6px;
    margin-bottom: 4px;
    box-sizing: border-box;
    cursor: pointer;
    transition: filter 0.18s ease, transform 0.18s ease;
}

.message-media-video {
    display: block;
    width: 100%;
    max-width: 320px;
    height: auto;
    max-height: min(280px, 48vh);
    border-radius: 6px;
    margin-bottom: 4px;
    box-sizing: border-box;
}

.message-audio-wrap {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 2px;
}

.message-media-audio {
    width: 100%;
    min-width: 220px;
    max-width: 320px;
    height: 42px;
    border-radius: 24px;
    outline: none;
    display: block;
    box-sizing: border-box;
}

.message-bubble.is-audio {
    min-width: 240px;
}

.location-link,
.media-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px;
    color: #53bdeb;
}

.contact-card {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 4px;
}

.message-bubble {
    position: relative;
    cursor: pointer;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: break-word;
}

.message-bubble.has-reaction {
    margin-bottom: 14px;
}

.message-reaction {
    position: absolute;
    bottom: -10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 6px;
    font-size: 13px;
    line-height: 1.2;
    background: #202c33;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    z-index: 2;
    user-select: none;
    pointer-events: none;
}

.message-out .message-reaction {
    right: 8px;
    background: #005c4b;
    border-color: rgba(255, 255, 255, 0.15);
}

.message-in .message-reaction {
    left: 8px;
    background: #202c33;
    border-color: rgba(255, 255, 255, 0.12);
}

.chat-row.active {
    background: #2a3942 !important;
}

.chat-time {
    opacity: 0.7;
    font-size: 11px;
}

.chat-preview {
    opacity: 0.75;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 85%;
}

.message-out,
.message-in {
    max-width: 75%;
    padding: 8px 12px;
    margin: 6px 0;
    border-radius: 10px;
    box-sizing: border-box;
}

.message-meta {
    display: block;
    font-size: 11px;
    opacity: 0.75;
    margin-top: 4px;
    text-align: right;
    user-select: none;
    line-height: 1.2;
}

.status-tick {
    display: inline-block;
    font-size: 11px;
    letter-spacing: -2px;
    margin-left: 4px;
    vertical-align: baseline;
}

.status-tick.status-read {
    color: #53bdeb !important;
    opacity: 1 !important;
    font-weight: bold;
}

.status-tick.status-delivered,
.status-tick.status-sent {
    color: inherit;
    opacity: 0.85;
}

.status-tick.status-failed {
    color: #f15c6d !important;
    font-weight: bold;
}

.date-separator {
    text-align: center;
    font-size: 12px;
    opacity: 0.8;
    margin: 10px 0;
}

.quoted-reply {
    border-left: 3px solid rgba(255, 255, 255, 0.35);
    padding-left: 8px;
    margin-bottom: 6px;
    opacity: 0.85;
    font-size: 12px;
}

.media-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px;
}

.message-out {
    margin-left: auto;
    background: #005c4b;
}

.message-in {
    margin-right: auto;
    background: #202c33;
}

@media (max-width: 992px) {
    .wa-sidebar {
        width: 100%;
        min-width: 0;
    }

    .wa-chat {
        display: none;
        width: 100%;
    }

    .wa-chat.wa-visible-mobile {
        display: flex;
    }

    .wa-sidebar.wa-hidden-mobile {
        display: none;
    }
}

@media (max-width: 768px) {
    .wa-messages {
        padding: 8px 10px !important;
    }

    .message-out,
    .message-in {
        max-width: 85% !important;
        padding: 5px 8px !important;
    }

    .message-media-image,
    .message-media-video {
        max-width: 100% !important;
        width: 100% !important;
        max-height: min(240px, 42vh) !important;
        object-fit: contain !important;
    }

    .message-bubble.is-audio {
        min-width: 210px;
        max-width: 86% !important;
    }

    .message-media-audio {
        min-width: 180px;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .wa-messages {
        padding: 6px 8px !important;
    }

    .message-out,
    .message-in {
        max-width: 88% !important;
    }

    .message-media-image,
    .message-media-video {
        max-height: min(220px, 36vh) !important;
    }
}

body.wa-light {
    background: #efeae2;
    color: #111b21;
}

body.wa-light .wa-sidebar {
    background: #fff;
}

body.wa-light .wa-chat {
    background-color: #efeae2;
    background-image: url('/assets/img/wa-doodle-light.svg');
    background-repeat: repeat;
    background-size: 380px auto;
}

body.wa-light .message-in {
    background: #fff;
    color: #111b21;
}

body.wa-light .message-out {
    background: #d9fdd3;
    color: #111b21;
}

body.wa-light .message-in .message-reaction {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

body.wa-light .message-out .message-reaction {
    background: #d9fdd3;
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.message-action-popup {
    position: fixed;
    z-index: 1060;
    background: #233138;
    border: 1px solid #2a3942;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    padding: 6px;
    min-width: 220px;
    animation: popup-enter 0.15s ease-out;
}

@keyframes popup-enter {
    from {
        opacity: 0;
        transform: scale(0.92);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.message-action-reactions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding: 4px 6px;
}

.reaction-btn {
    background: transparent;
    border: 0;
    font-size: 20px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease;
}

.reaction-btn:hover {
    transform: scale(1.25);
    background: rgba(255, 255, 255, 0.12);
}

.reaction-btn.active {
    background: rgba(37, 211, 102, 0.25);
    box-shadow: 0 0 0 1.5px #25d366;
}

.message-action-divider {
    height: 1px;
    background: #2a3942;
    margin: 6px 0;
}

.message-action-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.message-action-item {
    display: flex;
    align-items: center;
    width: 100%;
    border: 0;
    background: transparent;
    color: #e9edef;
    text-align: left;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13.5px;
    cursor: pointer;
    transition: background 0.12s ease;
}

.message-action-item:hover {
    background: #2a3942;
}

.message-action-danger {
    color: #f15c6d;
}

.message-action-danger:hover {
    background: rgba(241, 92, 109, 0.15);
    color: #ff6b7d;
}

.fade-out-message {
    transition: opacity 0.25s ease, transform 0.25s ease, max-height 0.25s ease, margin 0.25s ease, padding 0.25s ease;
    opacity: 0 !important;
    transform: scale(0.92) !important;
    max-height: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

body.wa-light .message-action-popup {
    background: #ffffff;
    border-color: #d1d7db;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

body.wa-light .reaction-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

body.wa-light .reaction-btn.active {
    background: rgba(37, 211, 102, 0.15);
    box-shadow: 0 0 0 1.5px #128c7e;
}

body.wa-light .message-action-divider {
    background: #e9edef;
}

body.wa-light .message-action-item {
    color: #111b21;
}

body.wa-light .message-action-item:hover {
    background: #f0f2f5;
}

body.wa-light .reply-bar {
    background: #f0f2f5;
    border-top-color: #d1d7db;
}

.status-tick.status-read {
    color: #53bdeb;
}

.composer-advanced summary {
    cursor: pointer;
    user-select: none;
}

.wa-composer {
    position: relative;
}

.composer-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.composer-toolbar {
    position: relative;
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.composer-tool-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.composer-tool-btn.active {
    background: #2a3942;
    border-color: #25d366;
    color: #25d366;
}

.composer-input {
    flex: 1 1 auto;
    min-width: 0;
    resize: none;
}

.composer-send-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.composer-mode-template .composer-send-btn {
    opacity: 0.45;
}

.composer-attach-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    z-index: 20;
    min-width: 190px;
    background: #233138;
    border: 1px solid #2a3942;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    padding: 6px;
}

.composer-attach-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    background: transparent;
    color: #e9edef;
    text-align: left;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
}

.composer-attach-item:hover {
    background: #2a3942;
}

.composer-attach-item i {
    width: 18px;
    text-align: center;
    color: #25d366;
}

.attachment-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: #111b21;
    border: 1px solid #2a3942;
    border-radius: 8px;
}

.attachment-preview-thumb {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    background: #2a3942;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.attachment-preview-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-preview-icon {
    font-size: 22px;
    color: #8696a0;
}

.attachment-preview-meta {
    flex: 1 1 auto;
    min-width: 0;
}

.attachment-preview-name {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-preview-size {
    font-size: 12px;
}

.attachment-preview-remove {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    line-height: 1;
}

.template-panel {
    margin-bottom: 10px;
    padding: 12px;
    background: #111b21;
    border: 1px solid #2a3942;
    border-radius: 8px;
}

.template-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.template-panel-title {
    font-size: 14px;
    font-weight: 600;
}

.template-panel-close {
    width: 30px;
    height: 30px;
    padding: 0;
    line-height: 1;
}

.template-panel-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.template-panel-fields .form-select {
    min-width: 140px;
    flex: 1 1 140px;
}

.template-preview {
    padding: 8px 10px;
    background: #0b141a;
    border-radius: 6px;
    white-space: pre-wrap;
    word-break: break-word;
}

.template-panel-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

body.wa-light .composer-tool-btn.active {
    background: #e7f7ed;
    border-color: #25d366;
    color: #128c7e;
}

body.wa-light .composer-attach-menu {
    background: #fff;
    border-color: #d1d7db;
}

body.wa-light .composer-attach-item {
    color: #111b21;
}

body.wa-light .composer-attach-item:hover {
    background: #f0f2f5;
}

body.wa-light .attachment-preview,
body.wa-light .template-panel {
    background: #f0f2f5;
    border-color: #d1d7db;
}

body.wa-light .attachment-preview-thumb {
    background: #fff;
}

body.wa-light .template-preview {
    background: #fff;
}

.sidebar-tabs .sidebar-tab.active {
    background: #25d366;
    border-color: #25d366;
    color: #0b141a;
    font-weight: 600;
}

.new-chat-panel {
    padding: 12px 16px;
    background: #111b21;
}

.new-chat-error {
    margin-top: 8px;
    color: #f15c6d;
    font-size: 12px;
}

body.wa-light .new-chat-panel {
    background: #f0f2f5;
}

body.wa-light .new-chat-error {
    color: #d93025;
}

.chat-header-info {
    min-width: 0;
}

.chat-header-title {
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-subtitle {
    font-size: 0.8rem;
    line-height: 1.2;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.wa-light .chat-header-subtitle {
    color: #667781;
}

.chat-header-menu-wrap {
    position: relative;
}

.chat-header-menu-btn.is-disabled,
.chat-header-menu-btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.chat-header-context-menu {
    position: fixed;
}

.chat-row {
    padding-right: 44px !important;
}

.chat-row-wrap {
    position: relative;
}

.chat-row-wrap:hover .chat-row-menu-btn,
.chat-row-menu-btn:focus,
.chat-row-menu-btn.menu-open {
    opacity: 1;
}

.chat-row-menu-btn {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    border: 0;
    background: rgba(17, 27, 33, 0.92);
    color: #aebac1;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 2;
}

.chat-row-menu-btn:hover {
    background: #2a3942;
    color: #e9edef;
}

.chat-context-menu {
    position: fixed;
    z-index: 1050;
    min-width: 180px;
    background: #233138;
    border: 1px solid #2a3942;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    padding: 6px;
}

.chat-context-item {
    display: flex;
    align-items: center;
    width: 100%;
    border: 0;
    background: transparent;
    color: #e9edef;
    text-align: left;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 14px;
}

.chat-context-item:hover {
    background: #2a3942;
}

.chat-context-danger {
    color: #f15c6d;
}

body.wa-light .chat-row-menu-btn {
    background: rgba(255, 255, 255, 0.95);
    color: #54656f;
}

body.wa-light .chat-row-menu-btn:hover {
    background: #f0f2f5;
    color: #111b21;
}

body.wa-light .chat-context-menu {
    background: #fff;
    border-color: #d1d7db;
}

body.wa-light .chat-context-item {
    color: #111b21;
}

body.wa-light .chat-context-item:hover {
    background: #f0f2f5;
}

body.wa-light .sidebar-tabs .sidebar-tab.active {
    background: #25d366;
    border-color: #25d366;
    color: #0b141a;
}

.coming-soon {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #8696a0;
}

.send-status.send-status-error {
    color: #ea4335;
}

.send-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(134, 150, 160, 0.35);
    border-top-color: #25d366;
    border-radius: 50%;
    animation: send-spin 0.8s linear infinite;
    flex-shrink: 0;
}

.send-status-error .send-spinner {
    display: none;
}

@keyframes send-spin {
    to {
        transform: rotate(360deg);
    }
}

body.wa-light .send-status {
    color: #667781;
}

body.wa-light .send-status.send-status-error {
    color: #d93025;
}

body.wa-light .btn-outline-light {
    color: #111b21;
    border-color: #c5cdd3;
    background-color: #fff;
}

body.wa-light .btn-outline-light:hover,
body.wa-light .btn-outline-light:focus,
body.wa-light .btn-outline-light:active {
    color: #111b21;
    border-color: #8696a0;
    background-color: #f0f2f5;
}

body.wa-light .btn-outline-light:disabled,
body.wa-light .btn-outline-light.coming-soon {
    color: #54656f;
    border-color: #d1d7db;
    background-color: #fff;
}

.template-variables {
    width: 100%;
}

.template-variables .form-control {
    min-width: 140px;
    flex: 1 1 140px;
}

.template-load-error {
    width: 100%;
    color: #f15c6d;
    font-size: 12px;
}

body.wa-light .template-load-error {
    color: #d93025;
}

.message-sticker {
    width: 130px;
    height: 130px;
    max-width: 100%;
    max-height: 140px;
    display: block;
    object-fit: contain;
    border-radius: 4px;
}

.message-bubble.is-sticker {
    background: transparent !important;
    box-shadow: none !important;
    padding: 2px !important;
    border: 0 !important;
    max-width: fit-content !important;
}

.message-bubble.is-sticker .message-meta {
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    padding: 2px 6px;
    border-radius: 10px;
    margin-top: 2px;
}

.message-footer-text {
    font-size: 11px;
    opacity: 0.65;
    margin-top: 6px;
}

.message-card-buttons {
    display: flex;
    flex-direction: column;
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    margin-left: -12px;
    margin-right: -12px;
    margin-bottom: -8px;
}

.message-card-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 9px 12px;
    color: #53bdeb !important;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    transition: background 0.15s ease;
    user-select: none;
    cursor: pointer;
}

.message-card-btn:first-child {
    border-top: 0;
}

.message-card-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #70cbf4 !important;
}

.message-button-selected {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(83, 189, 235, 0.15);
    color: #53bdeb;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12.5px;
    margin-top: 4px;
}

body.wa-light .message-card-buttons {
    border-top-color: rgba(0, 0, 0, 0.08);
}

body.wa-light .message-card-btn {
    color: #00a884 !important;
    border-top-color: rgba(0, 0, 0, 0.06);
}

body.wa-light .message-card-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

body.wa-light .message-button-selected {
    background: rgba(0, 168, 132, 0.12);
    color: #00a884;
}

.message-media-image {
    cursor: pointer;
    transition: filter 0.18s ease, transform 0.18s ease;
}

.message-media-image:hover {
    filter: brightness(0.92);
}

.message-media-image:active {
    transform: scale(0.985);
}

/* Image Lightbox Modal */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    animation: lightbox-fade-in 0.2s ease-out;
}

@keyframes lightbox-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.image-lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 20, 26, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1;
}

.image-lightbox-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
}

.image-lightbox-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: rgba(17, 27, 33, 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 3;
}

.image-lightbox-title {
    color: #e9edef;
    font-size: 15px;
    font-weight: 600;
}

.image-lightbox-actions {
    display: flex;
    gap: 10px;
}

.image-lightbox-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: hidden;
}

.image-lightbox-body img {
    max-width: 92vw;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.7);
    transition: transform 0.2s ease;
}