/* Keep only one chat state visible. The base .wa-empty-chat display:flex rule
   otherwise overrides the browser's native [hidden] rule. */
.wa-chat-panel {
    overflow: hidden;
}

.wa-empty-chat,
.wa-active-chat {
    flex: 1 1 100%;
    min-width: 0;
}

.wa-empty-chat[hidden],
.wa-active-chat[hidden] {
    display: none !important;
}

.wa-center-info-button[hidden],
.wa-center-modal[hidden],
.wa-center-content[hidden] {
    display: none !important;
}

.wa-center-info-button {
    color: #087f69;
    background: #dcf5ee;
}

.wa-center-modal {
    position: fixed;
    inset: 0;
    z-index: 10020;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    direction: rtl;
    background: rgba(13, 27, 35, .72);
    backdrop-filter: blur(4px);
}

.wa-center-dialog {
    width: min(880px, 100%);
    max-height: min(88vh, 850px);
    overflow: hidden;
    color: #183548;
    background: #f6f9fb;
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .3);
}

.wa-center-dialog > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 18px;
    color: #fff;
    background: linear-gradient(125deg, #153c55, #079477);
}

.wa-center-dialog > header > div {
    display: flex;
    align-items: center;
    gap: 11px;
}

.wa-center-dialog > header > div > span {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    font-size: 20px;
    background: rgba(255, 255, 255, .16);
    border-radius: 11px;
}

.wa-center-dialog h3 { margin: 0; font-size: 18px; font-weight: 800; }
.wa-center-dialog header small { display: block; margin-top: 2px; color: rgba(255, 255, 255, .78); font-size: 10px; }
.wa-center-dialog header .wa-icon-button { color: #fff; background: rgba(255, 255, 255, .12); }
.wa-center-dialog header .wa-icon-button:hover { background: rgba(255, 255, 255, .22); }

.wa-center-loading {
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    color: #638093;
}
.wa-center-loading i { color: #079477; font-size: 28px; }

.wa-center-content {
    max-height: calc(min(88vh, 850px) - 72px);
    overflow-y: auto;
    padding: 18px;
}

.wa-center-identity {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 14px;
    padding: 16px 18px;
    background: #fff;
    border: 1px solid #e0e9ee;
    border-radius: 13px;
}
.wa-center-identity strong { display: block; color: #123950; font-size: 20px; }
.wa-center-identity span { display: block; margin-top: 4px; color: #6b8291; font-size: 11px; }
.wa-center-identity em { padding: 6px 11px; color: #287259; background: #e4f6ee; border-radius: 20px; font-size: 11px; font-style: normal; font-weight: 700; }
.wa-center-identity em.is-inactive { color: #a44747; background: #fdeaea; }

.wa-center-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.wa-center-meta-grid > div {
    min-width: 0;
    padding: 12px;
    background: #fff;
    border: 1px solid #e2e9ed;
    border-radius: 10px;
}
.wa-center-meta-grid small,
.wa-center-meta-grid strong { display: block; }
.wa-center-meta-grid small { margin-bottom: 4px; color: #7b909d; font-size: 9px; }
.wa-center-meta-grid strong { overflow-wrap: anywhere; color: #2c4b5e; font-size: 12px; }

.wa-center-detail-block {
    margin-top: 12px;
    padding: 14px;
    background: #fff;
    border: 1px solid #e2e9ed;
    border-radius: 11px;
}
.wa-center-detail-block h4 { margin: 0 0 10px; color: #36586d; font-size: 13px; font-weight: 800; }
.wa-center-detail-block h4 i { margin-left: 5px; color: #079477; }
.wa-center-detail-block p { margin: 0; color: #5b7180; line-height: 1.8; white-space: pre-wrap; }
.wa-center-worklines { display: flex; flex-wrap: wrap; gap: 7px; }
.wa-center-worklines span { padding: 5px 9px; color: #14705e; background: #e6f7f2; border: 1px solid #c5eadf; border-radius: 18px; font-size: 10px; }

.wa-center-matching {
    margin-top: 14px;
    padding: 16px;
    color: #fff;
    background: linear-gradient(135deg, #15394f, #1f566c);
    border-radius: 14px;
}
.wa-center-matching-head { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wa-center-matching-head > div { padding: 13px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .1); border-radius: 10px; }
.wa-center-matching-head small,
.wa-center-matching-head strong,
.wa-center-matching-head span { display: block; }
.wa-center-matching-head small { color: #b9d0dc; font-size: 9px; }
.wa-center-matching-head strong { margin: 4px 0; font-size: 19px; }
.wa-center-matching-head span { color: #d9e7ed; font-size: 10px; }
.wa-center-total-receivable { color: #6ee7b7; }
.wa-center-total-payable { color: #fda4af; }
.wa-center-total-balanced { color: #fde68a; }

.wa-center-balances { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.wa-center-balance { padding: 10px; background: rgba(255, 255, 255, .07); border-radius: 9px; }
.wa-center-balance small,
.wa-center-balance strong,
.wa-center-balance span { display: block; }
.wa-center-balance small { color: #b9d0dc; font-size: 9px; }
.wa-center-balance strong { margin: 3px 0; font-size: 14px; direction: ltr; text-align: right; }
.wa-center-balance span { color: #d9e7ed; font-size: 9px; }
.wa-center-generated { display: block; margin-top: 11px; color: #9eb8c5; font-size: 9px; text-align: left; }

@media (max-width: 680px) {
    .wa-center-modal { padding: 8px; }
    .wa-center-dialog { max-height: 96vh; border-radius: 13px; }
    .wa-center-content { max-height: calc(96vh - 72px); padding: 12px; }
    .wa-center-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .wa-center-balances { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .wa-center-matching-head { grid-template-columns: 1fr; }
    .wa-center-identity { align-items: flex-start; flex-direction: column; }
}

/* WhatsApp Web-like interaction polish */
.bot-chat-page {
    padding: 10px 14px 14px !important;
    background: #eaf0f3;
}

.wa-app {
    position: relative;
    height: calc(100vh - 96px);
    min-height: 610px;
    border: 0;
    border-radius: 14px;
    box-shadow: 0 12px 38px rgba(16, 39, 52, .18);
}

.wa-app::before {
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    z-index: 20;
    content: '';
    background: linear-gradient(90deg, #0b8069, #25d366, #0b8069);
}

.wa-sidebar { width: 390px; min-width: 330px; }
.wa-sidebar-header,
.wa-chat-header { background: #f5f7f8; border-bottom: 1px solid #e1e7ea; }
.wa-sidebar-header { padding-inline: 14px 10px; }
.wa-search-wrap { padding: 8px 11px; background: #fff; }
.wa-search { height: 38px; border: 1px solid transparent; border-radius: 10px; transition: .16s; }
.wa-search:focus-within { background: #fff; border-color: #9ad9cc; box-shadow: 0 0 0 3px rgba(0, 168, 132, .08); }

.wa-conversation { min-height: 76px; height: auto; padding: 0 12px; gap: 11px; }
.wa-conversation.is-active { background: #e9edef; }
.wa-conversation-avatar,
.wa-chat-avatar { overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .04); }
.wa-conversation-avatar img,
.wa-chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.wa-conversation-copy { min-height: 76px; }
.wa-conversation-top { align-items: flex-start; padding-top: 2px; }
.wa-conversation-identity { min-width: 0; display: flex; align-items: center; gap: 6px; flex: 1; }
.wa-conversation-identity > strong { min-width: 0; flex: 0 1 auto; }
.wa-conversation-bottom { margin-top: 3px; }
.wa-conversation-time { padding-top: 2px; }

.wa-category-badge,
.wa-chat-category {
    --category-color: #8796a5;
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    color: #40515a;
    background: color-mix(in srgb, var(--category-color) 13%, white);
    border: 1px solid color-mix(in srgb, var(--category-color) 38%, white);
    border-radius: 999px;
    font-size: 8px;
    line-height: 1.5;
    white-space: nowrap;
}
.wa-category-badge i { width: 6px; height: 6px; flex: 0 0 6px; background: var(--category-color); border-radius: 50%; }
.wa-category-badge b { max-width: 86px; overflow: hidden; font-weight: 700; text-overflow: ellipsis; }
.wa-chat-title-line { display: flex; min-width: 0; align-items: center; gap: 8px; }
.wa-chat-title-line > strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.wa-chat-category { flex: 0 0 auto; padding-inline: 8px; border-right: 4px solid var(--category-color); font-weight: 700; }
.wa-chat-category[hidden] { display: none !important; }

.wa-message-stage { padding-top: 20px; background-color: #efeae2; }
.wa-message-list { gap: 4px; }
.wa-message-bubble { padding: 7px 9px 5px; border-radius: 9px; }
.wa-message-row.incoming .wa-message-bubble::before,
.wa-message-row.outgoing .wa-message-bubble::before {
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    content: '';
    border-style: solid;
}
.wa-message-row.incoming .wa-message-bubble::before {
    right: -7px;
    border-width: 0 0 9px 8px;
    border-color: transparent transparent transparent #fff;
}
.wa-message-row.outgoing .wa-message-bubble::before {
    left: -7px;
    border-width: 9px 0 0 8px;
    border-color: #d9fdd3 transparent transparent transparent;
}
.wa-message-bubble.is-sticker { min-width: 0; padding: 3px; background: transparent; box-shadow: none; }
.wa-message-bubble.is-sticker::before { display: none; }
.wa-message-sticker { display: block; width: min(190px, 42vw); max-height: 190px; object-fit: contain; cursor: pointer; filter: drop-shadow(0 2px 2px rgba(0,0,0,.12)); }
.wa-message-bubble.is-sticker .wa-message-meta { display: inline-flex; float: left; margin-top: -18px; padding: 2px 5px; background: rgba(255,255,255,.82); border-radius: 8px; }

.wa-message-audio { min-width: 310px; display: flex; align-items: center; gap: 9px; padding: 4px 2px; direction: ltr; }
.wa-message-audio > span { width: 39px; height: 39px; display: grid; flex: 0 0 39px; place-items: center; color: #fff; background: #00a884; border-radius: 50%; font-size: 18px; }
.wa-message-audio audio { width: 255px; max-width: calc(72vw - 85px); height: 38px; }
.wa-message-video { display: block; width: min(430px, 62vw); max-height: 460px; margin-bottom: 5px; background: #111; border-radius: 7px; }

.wa-message-file {
    min-width: 270px;
    display: grid;
    grid-template-columns: 43px minmax(0,1fr) 20px;
    align-items: center;
    gap: 9px;
    padding: 9px;
    color: #334852;
    background: rgba(255,255,255,.68);
    border: 1px solid rgba(84,101,111,.1);
    border-radius: 8px;
    text-decoration: none !important;
}
.wa-message-file:hover { color: #116e5e; background: rgba(255,255,255,.92); }
.wa-message-file-icon { width: 43px; height: 43px; display: grid; place-items: center; color: #fff; background: #758a95; border-radius: 8px; font-size: 20px; }
.wa-message-file.is-pdf .wa-message-file-icon { background: #e04f5f; }
.wa-message-file > span:nth-child(2) { min-width: 0; display: flex; flex-direction: column; }
.wa-message-file strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.wa-message-file small { margin-top: 2px; color: #788b95; font-size: 9px; }
.wa-message-file > i { color: #78909a; }

.wa-composer { align-items: center; padding: 9px 14px; border-top: 1px solid #dfe5e7; }
.wa-composer textarea { border-radius: 12px; }
.wa-icon-button { transition: background .15s, color .15s, transform .15s; }
.wa-icon-button:active { transform: scale(.93); }
.wa-send-button { box-shadow: 0 4px 12px rgba(0,128,105,.2); }
.wa-conversation-list,
.wa-message-stage { scrollbar-width: thin; scrollbar-color: #b7c3c9 transparent; }
.wa-conversation-list::-webkit-scrollbar,
.wa-message-stage::-webkit-scrollbar { width: 7px; }
.wa-conversation-list::-webkit-scrollbar-thumb,
.wa-message-stage::-webkit-scrollbar-thumb { background: #b7c3c9; border-radius: 8px; }

@supports not (background: color-mix(in srgb, red 10%, white)) {
    .wa-category-badge,
    .wa-chat-category { background: #f2f5f6; border-color: var(--category-color); }
}

@media (max-width: 800px) {
    .bot-chat-page { padding: 0 !important; }
    .wa-app { height: calc(100vh - 72px); min-height: 520px; border-radius: 0; }
    .wa-sidebar { width: 100%; min-width: 0; }
    .wa-message-audio { min-width: 255px; }
    .wa-message-file { min-width: 235px; }
    .wa-message-video { width: min(430px, 78vw); }
}
