.communications-nav .nav-link {
    color: #5e6278;
    background: #f9f9f9;
    border-radius: 0.475rem;
    padding: 0.55rem 1rem;
    font-weight: 500;
}
.communications-nav .nav-link.active {
    color: #fff;
    background: #009ef7;
}
.communications-nav .nav-link:hover:not(.active) {
    background: #eef6ff;
    color: #009ef7;
}

.comm-hub-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: 1px solid #eff2f5;
    height: 100%;
}
.comm-hub-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.08);
}
.comm-hub-card .hub-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}
.comm-hub-card .hub-icon.email { background: #e8f4fd; color: #009ef7; }
.comm-hub-card .hub-icon.sms { background: #fff4de; color: #ffc700; }
.comm-hub-card .hub-icon.whatsapp { background: #e8fff3; color: #50cd89; }

#communications_inbox_page {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 6.5rem);
    max-height: calc(100dvh - 6.5rem);
    min-height: 0;
}
#communications_inbox_page .communications-nav {
    flex: 0 0 auto;
    margin-bottom: 1rem;
}
#communications_inbox_page .comm-inbox-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#communications_inbox_page .comm-inbox-card > .card-header {
    flex: 0 0 auto;
}
#communications_inbox_page .comm-inbox-card > .card-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.comm-inbox-layout {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}
.comm-inbox-sidebar {
    width: 340px;
    max-width: 38%;
    border-inline-end: 1px solid #eff2f5;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}
.comm-inbox-thread {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
#comm_conversations {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}
#comm_thread_header,
#comm_compose {
    flex: 0 0 auto;
}
#comm_thread_empty,
#comm_thread_wrap,
.comm-thread-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

@media (max-width: 991.98px) {
    #communications_inbox_page {
        height: auto;
        max-height: none;
    }
    .comm-inbox-layout {
        flex-direction: column;
        height: auto;
    }
    .comm-inbox-sidebar {
        width: 100%;
        max-width: none;
        height: auto;
        max-height: 36vh;
        border-inline-end: 0;
        border-bottom: 1px solid #eff2f5;
    }
    .comm-inbox-thread {
        height: min(58vh, 36rem);
    }
}
.comm-conv-item {
    cursor: pointer;
    padding: 14px 18px;
    border-bottom: 1px solid #eff2f5;
}
.comm-conv-item:hover,
.comm-conv-item.active {
    background: #f1faff;
}
.comm-channel-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.comm-channel-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2px 6px;
    border-radius: 4px;
}
.comm-channel-badge.email { background: #e8f4fd; color: #009ef7; }
.comm-channel-badge.sms { background: #fff4de; color: #b89500; }
.comm-channel-badge.whatsapp { background: #e8fff3; color: #1e7e34; }

.comm-sent-date-range .form-control-sm {
    min-height: 32px;
}

.comm-sent-error {
    max-width: 280px;
    line-height: 1.35;
    word-break: break-word;
}

.comm-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 14px;
    margin-bottom: 12px;
    word-break: break-word;
}
.comm-bubble.out { margin-left: auto; }
.comm-bubble.in { margin-right: auto; }
.comm-bubble.channel-email.out { background: #e8f4fd; border: 1px solid #b6d4fe; }
.comm-bubble.channel-sms.out { background: #fff8dd; border: 1px solid #ffe08a; }
.comm-bubble.channel-whatsapp.out { background: #dcf8c6; border: 1px solid #b8e6a8; }
.comm-bubble.channel-whatsapp.in { background: #fff; border: 1px solid #e4e6ef; }
.comm-bubble.channel-email.in,
.comm-bubble.channel-sms.in { background: #f9f9f9; border: 1px solid #e4e6ef; }
.comm-bubble .comm-bubble-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: #7e8299;
    margin-bottom: 4px;
}
.comm-bubble time { display: block; font-size: 0.68rem; color: #a1a5b7; }
.comm-bubble-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 6px;
}
.comm-receipt {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    line-height: 1;
}
.comm-receipt.sent { color: #a1a5b7; }
.comm-receipt.delivered { color: #7e8299; }
.comm-receipt.read { color: #009ef7; }
.comm-receipt.failed { color: #f1416c; }
.comm-receipt.pending { color: #a1a5b7; }
.comm-handoff-flag {
    margin-top: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #f1416c;
}
.comm-waiting-badge {
    font-size: 0.65rem;
    vertical-align: middle;
}
.comm-conv-item .badge { display: inline-block; }
.comm-bubble .comm-subject { font-weight: 600; margin-bottom: 4px; font-size: 0.9rem; }
.comm-bubble-html { font-size: 0.9rem; line-height: 1.45; }
.comm-bubble-html img { max-width: 100%; height: auto; }
.comm-bubble-html table { width: 100%; max-width: 100%; }
.comm-bubble-html p { margin: 0 0 0.5em; }
.comm-media { margin: 0.35rem 0; }
.comm-media img,
.comm-media video { max-width: 100%; max-height: 280px; border-radius: 8px; display: block; }
.comm-media a { word-break: break-all; }
.wa-media-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f5f8fa;
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}
.wa-media-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-media-library-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.wa-media-library-item { max-width: 100%; }

.wa-hub-card {
    border: 1px solid #e8fff3;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    height: 100%;
}
.wa-hub-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1.25rem rgba(80, 205, 137, 0.15);
}
.wa-hub-card .wa-hub-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: #e8fff3;
    color: #50cd89;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.comm-filter-pills .btn { font-size: 0.85rem; }

.comm-actions-toolbar .btn {
    font-weight: 500;
}
.comm-actions-toolbar .dropdown-menu {
    min-width: 220px;
}
.comm-actions-toolbar .dropdown-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #a1a5b7;
}
.comm-actions-toolbar .dropdown-item {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}
.comm-actions-toolbar .dropdown-item i {
    width: 1.25rem;
    text-align: center;
}

.comm-ai-drawer.offcanvas-end,
.comm-ai-drawer.offcanvas-start {
    width: min(32rem, 100vw);
}
