/* WhatsApp Web Clone Stylesheet */
:root {
    --wa-bg-color: #efeae2;
    --mobile-bottom-inset: 0px;
    --mobile-nav-height: 56px;
    --mobile-input-bar-height: 58px;
    --wa-chat-bg: #efeae2;
    --wa-header-bg: #f0f2f5;
    --wa-search-bg: #f0f2f5;
    --wa-sidebar-bg: #ffffff;
    --wa-primary-color: #00a884;
    --wa-message-sent: #d9fdd3;
    --wa-message-received: #ffffff;
    --wa-text-primary: #111b21;
    --wa-text-secondary: #667781;
    --wa-border-color: #e9edef;
    --wa-active-chat: #f0f2f5;
    --wa-hover-chat: #f5f6f6;
    --wa-system-message: #ffeecd;
}

/* Dark Theme Variables */
.dark-theme {
    --wa-bg-color: #0b141a;
    --wa-chat-bg: #0b141a;
    --wa-header-bg: #202c33;
    --wa-search-bg: #202c33;
    --wa-sidebar-bg: #111b21;
    --wa-primary-color: #00a884;
    --wa-message-sent: #005c4b;
    --wa-message-received: #202c33;
    --wa-text-primary: #e9edef;
    --wa-text-secondary: #8696a0;
    --wa-border-color: #222e35;
    --wa-active-chat: #2a3942;
    --wa-hover-chat: #202c33;
    --wa-system-message: #182229;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #121b22; /* Outer WhatsApp Web background */
    overflow: hidden;
    height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(11, 20, 26, 0.2);
}

.dark-theme ::-webkit-scrollbar-thumb {
    background: rgba(233, 237, 239, 0.2);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(11, 20, 26, 0.3);
}

/* WhatsApp Background Pattern (Doodle Wallpaper) */
.whatsapp-bg {
    background-color: var(--wa-chat-bg);
    background-image: url("assets/chat-wallpaper.svg");
    background-blend-mode: overlay;
    background-size: repeat;
    opacity: 0.98;
}

.dark-theme .whatsapp-bg {
    background-blend-mode: soft-light;
    opacity: 0.4;
    background-color: #0b141a;
}

/* Tooltip standard styled */
.tooltip {
    position: relative;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    border-radius: 5px;
    background: #313d45;
    color: #e9edef;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s ease-in-out;
    z-index: 100;
}

.tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Audio Wave Animation */
.wave-bar {
    width: 2px;
    height: 15px;
    background-color: #8696a0;
    margin: 0 1px;
    display: inline-block;
    transition: height 0.1s ease;
}

.wave-bar.active {
    background-color: #53bdeb;
}

/* Context Menu CSS styling */
.context-menu {
    position: absolute;
    z-index: 200;
    background-color: var(--wa-sidebar-bg);
    border: 1px solid var(--wa-border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 8px;
    min-width: 140px;
    padding: 6px 0;
    display: none;
    animation: fadeIn 0.12s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Shake Animation for Call Button or Alerts */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.animate-shake {
    animation: shake 0.6s ease-in-out infinite;
}

/* Pulse animation for voice record */
@keyframes pulse-red {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.animate-pulse-red {
    animation: pulse-red 1.5s infinite;
}

/* Message Transition */
.msg-enter {
    animation: msgSlideIn 0.2s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}

@keyframes msgSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Status Story View Ring */
.story-ring-active {
    border: 2px solid #00a884;
    padding: 2px;
}

.story-ring-read {
    border: 2px solid #8696a0;
    padding: 2px;
}

/* @Mention picker & highlights */
.mention-highlight {
    color: #00a884;
    font-weight: 600;
    cursor: pointer;
}

.dark .mention-highlight {
    color: #25d366;
}

#mention-picker {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
}

.mention-item.active {
    background-color: #f0f2f5;
}

.dark .mention-item.active {
    background-color: #2a3942;
}

/* Incoming message toast notification */
.msg-toast {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 320px;
    padding: 12px 16px;
    background: #202c33;
    color: #e9edef;
    border-radius: 12px;
    border: 1px solid #2a3942;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    animation: toastSlideIn 0.3s ease;
}

.msg-toast.hidden {
    display: none;
}

.msg-toast-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #00a884;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    font-size: 18px;
}

.msg-toast-title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 2px;
}

.msg-toast-text {
    font-size: 12px;
    color: #8696a0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}

@keyframes toastSlideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ==================== Mobile layout (WhatsApp-style) ==================== */
html {
    height: 100%;
    height: 100dvh;
}

.mobile-input {
    font-size: 16px; /* يمنع تكبير iOS تلقائياً عند الكتابة */
}

.mobile-input-shell {
    background: #2a3942;
    border-radius: 24px;
    min-height: 42px;
    padding: 4px 6px 4px 10px;
    gap: 4px;
}

.mobile-input-tools {
    gap: 2px;
}

.mobile-tool-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #8696a0;
    font-size: 20px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

.mobile-tool-btn:active {
    opacity: 0.55;
}

.mobile-attach-icon {
    display: inline-block;
    transform: rotate(-45deg);
}

#mobile-attach-btn.attach-active {
    color: #25d366;
}

@media (max-width: 767px) {
    .mobile-send-btn {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
        border: none;
        border-radius: 50%;
        background: #00a884;
        color: #ffffff;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.12s ease, background 0.12s ease;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    }

    .mobile-send-btn:active {
        transform: scale(0.94);
    }

    .mobile-send-btn .mic-icon-wa {
        font-size: 22px;
        line-height: 1;
        color: #ffffff;
    }

    .mobile-send-btn .send-plane-icon {
        font-size: 18px;
        line-height: 1;
        color: #ffffff;
        transform: rotate(-45deg) translateX(1px);
    }
}

@media (min-width: 768px) {
    .mobile-send-btn {
        width: auto;
        height: auto;
        min-width: 0;
        min-height: 0;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
    }
}

.chat-list-item {
    min-height: 72px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.chat-input-bar {
    padding-bottom: max(0.75rem, var(--mobile-bottom-inset));
    box-sizing: border-box;
}

#messages-area {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.chat-loading-state {
    width: 100%;
}

/* Attachment sheet — مخفي افتراضياً، يظهر عند الضغط فقط */
.attachment-backdrop {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 18;
}

.attachment-backdrop.is-open {
    display: block;
}

.attachment-sheet {
    display: none;
    position: absolute;
    z-index: 30;
    background: #1f2c33;
    border-top: 1px solid rgba(134, 150, 160, 0.2);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
}

.attachment-sheet.is-open {
    display: flex;
    animation: attachSheetIn 0.2s ease-out;
}

@keyframes attachSheetIn {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.attach-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    border: none;
    background: transparent;
    padding: 4px 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.attach-option-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: transform 0.15s;
}

.attach-option:active .attach-option-icon {
    transform: scale(0.92);
}

.attach-option-label {
    font-size: 12px;
    color: #aebac1;
    white-space: nowrap;
}

/* File inputs must stay in DOM (not display:none) so mobile browsers open the picker */
.file-input-offscreen {
    position: fixed;
    left: 0;
    top: 0;
    width: 1px;
    height: 1px;
    opacity: 0.001;
    overflow: hidden;
    z-index: -1;
}

#mobile-attach-btn.attach-active,
#attachment-btn.attach-active {
    color: #25d366 !important;
}

@media (max-width: 767px) {
    .attachment-sheet {
        left: 0;
        right: 0;
        bottom: calc(var(--mobile-input-bar-height) + var(--mobile-bottom-inset));
        flex-direction: row;
        justify-content: space-around;
        align-items: flex-start;
        padding: 16px 8px 20px;
        gap: 4px;
    }

    .attachment-backdrop {
        bottom: calc(var(--mobile-input-bar-height) + var(--mobile-bottom-inset));
    }
}

@media (min-width: 768px) {
    .attachment-backdrop {
        display: none !important;
    }

    .attachment-sheet {
        left: auto;
        right: 16px;
        bottom: 68px;
        flex-direction: column;
        gap: 10px;
        padding: 10px 8px;
        border-radius: 28px;
        width: 52px;
        border: 1px solid #2a3942;
        background: #202c33;
        animation: none;
    }

    .attachment-sheet.is-open {
        display: flex;
    }

    .attach-option-label {
        display: none;
    }

    .attachment-sheet .attach-option-icon {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 767px) {
    :root {
        --mobile-bottom-inset: max(
            52px,
            calc(env(safe-area-inset-bottom, 0px) + 14px),
            var(--system-nav-inset, 0px),
            var(--vv-bottom-gap, 0px)
        );
    }

    html {
        height: 100%;
        height: 100svh;
    }

    body.lab-dashboard-page,
    body.admin-dashboard-page {
        display: block !important;
        align-items: stretch !important;
        justify-content: stretch !important;
        height: 100svh !important;
        max-height: 100svh !important;
        overflow: hidden;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-sizing: border-box;
    }

    body.lab-dashboard-page #app-container,
    body.admin-dashboard-page #admin-app-shell {
        height: 100% !important;
        max-height: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    #sidebar,
    #main-space {
        min-height: 0 !important;
    }

    #main-space {
        height: 100% !important;
        flex: 1 1 auto !important;
    }

    #chat-window {
        height: 100% !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }

    #messages-area {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        padding-bottom: 6px !important;
    }

    body.mobile-chat-open #messages-area {
        padding-bottom: 10px !important;
    }

    body:not(.admin-dashboard-page):not(.lab-dashboard-page) {
        background-color: #0b141a !important;
    }

    body:not(.admin-dashboard-page):not(.lab-dashboard-page) #app-container {
        border-radius: 0 !important;
        max-height: 100dvh !important;
        height: 100dvh !important;
        background: #0b141a;
    }

    body:not(.admin-dashboard-page):not(.lab-dashboard-page) #sidebar {
        background: #0b141a !important;
        border: none !important;
    }

    .sidebar-topbar {
        background: #0b141a !important;
        border-bottom: none !important;
    }

    .mobile-search-wrap {
        background: #0b141a;
        padding-top: 4px;
    }

    .mobile-chats-list {
        background: #0b141a !important;
        padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-bottom-inset) + 12px) !important;
    }

    .chat-list-item {
        min-height: 76px;
        padding-top: 10px;
        padding-bottom: 10px;
        border-bottom-color: rgba(134, 150, 160, 0.15) !important;
    }

    .chat-list-item h4 {
        font-size: 17px;
        font-weight: 500;
    }

    #main-space {
        width: 100%;
        flex: 1 1 100%;
        background: #0b141a;
    }

    #chat-window {
        width: 100%;
        background: #0b141a;
    }

    #chat-window > .h-\[56px\] {
        background: #202c33 !important;
        border: none !important;
    }

    #chat-window > .chat-window-header {
        background: #202c33 !important;
        border: none !important;
    }

    .chat-header-name {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        white-space: normal;
        word-break: break-word;
    }

    .chat-header-status {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .chat-doc-title {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        white-space: normal;
        word-break: break-word;
        line-height: 1.35;
    }

    .chat-media-document {
        max-width: 100% !important;
    }

    body.lab-dashboard-page #chat-window > .chat-window-header {
        background: #fff !important;
        border-bottom: 1px solid var(--admin-border) !important;
    }

    body.lab-dashboard-page .chat-header-name {
        color: #111b21 !important;
    }

    .mobile-wa-input-bar {
        background: #202c33 !important;
        border: none !important;
        align-items: center !important;
        padding: 8px 10px max(14px, var(--mobile-bottom-inset)) !important;
        gap: 8px !important;
        min-height: calc(var(--mobile-input-bar-height) + var(--mobile-bottom-inset)) !important;
        flex-shrink: 0 !important;
        position: relative;
        z-index: 25;
        box-sizing: border-box;
    }

    body.lab-dashboard-page .mobile-wa-input-bar,
    body.admin-dashboard-page .mobile-wa-input-bar {
        background: #fff !important;
        border-top: 1px solid var(--admin-border, #e2e8f0) !important;
        padding-bottom: max(16px, var(--mobile-bottom-inset)) !important;
    }

    body.mobile-chat-open .mobile-wa-input-bar {
        padding-bottom: max(18px, calc(var(--mobile-bottom-inset) + 4px)) !important;
    }

    .msg-toast {
        left: 12px;
        right: 12px;
        bottom: calc(12px + var(--mobile-bottom-inset));
        max-width: none;
    }

    #emoji-picker-popup {
        width: min(310px, calc(100vw - 24px)) !important;
        right: 0 !important;
    }

    .wa-unread-badge {
        min-width: 22px;
        height: 22px;
        padding: 0 6px;
        font-size: 12px;
        font-weight: 600;
    }
}

/* Filter pills — واتساب */
.wa-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    background: #202c33;
    color: #aebac1;
    border: none;
    transition: background 0.15s, color 0.15s;
}

.wa-filter-pill.active {
    background: #103529;
    color: #25d366;
}

@media (min-width: 768px) {
    .wa-filter-pill {
        background: #f0f2f5;
        color: #54656f;
    }
    .wa-filter-pill.active {
        background: #d9fdd3;
        color: #008069;
    }
    .dark .wa-filter-pill {
        background: #202c33;
        color: #aebac1;
    }
    .dark .wa-filter-pill.active {
        background: #103529;
        color: #25d366;
    }
}

.filter-count {
    font-size: 11px;
    opacity: 0.9;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Bottom navigation */
.mobile-bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--mobile-nav-height) + var(--mobile-bottom-inset));
    padding-bottom: var(--mobile-bottom-inset);
    background: #0b141a;
    border-top: 1px solid rgba(134, 150, 160, 0.2);
    display: flex;
    align-items: flex-start;
    justify-content: space-around;
    z-index: 30;
    box-sizing: border-box;
}

.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #8696a0;
    font-size: 11px;
    border: none;
    background: transparent;
    padding: 8px 4px 4px;
    min-height: var(--mobile-nav-height);
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item.active {
    color: #25d366;
}

.mobile-nav-icon-wrap {
    position: relative;
    font-size: 20px;
    line-height: 1;
}

.mobile-nav-item.active .mobile-nav-icon-wrap {
    background: #103529;
    border-radius: 999px;
    padding: 4px 20px;
}

.mobile-nav-badge {
    position: absolute;
    top: -6px;
    left: -10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #25d366;
    color: #0b141a;
    font-size: 10px;
    font-weight: 700;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-nav-badge.hidden {
    display: none;
}

/* FAB */
.mobile-fab {
    position: absolute;
    bottom: calc(var(--mobile-nav-height) + var(--mobile-bottom-inset) + 12px);
    left: 16px;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: #25d366;
    color: #0b141a;
    border: none;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    z-index: 25;
    -webkit-tap-highlight-color: transparent;
}

.mobile-fab:active {
    transform: scale(0.96);
}

.mobile-fab.hidden-nav {
    display: none;
}

.mobile-bottom-nav.hidden-nav {
    display: none;
}

/* Unread badge in chat list */
.wa-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #25d366;
    color: #0b141a;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    flex-shrink: 0;
}

/* Media viewer — فتح وتحميل المرفقات */
body.media-viewer-open {
    overflow: hidden;
}

.media-viewer-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.media-viewer-modal.hidden {
    display: none !important;
}

.media-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
}

.media-viewer-panel {
    position: relative;
    z-index: 1;
    width: min(960px, 100%);
    max-height: calc(100dvh - 24px);
    background: #0b141a;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.media-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: #202c33;
    border-bottom: 1px solid rgba(134, 150, 160, 0.2);
}

.media-viewer-title {
    color: #e9edef;
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    flex: 1;
    text-align: right;
}

.media-viewer-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.media-viewer-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #aebac1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    -webkit-tap-highlight-color: transparent;
}

.media-viewer-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #25d366;
}

.media-viewer-body {
    flex: 1;
    min-height: 200px;
    max-height: calc(100dvh - 100px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0b141a;
    overflow: auto;
    padding: 8px;
}

.media-viewer-image {
    max-width: 100%;
    max-height: calc(100dvh - 120px);
    object-fit: contain;
    border-radius: 4px;
}

.media-viewer-pdf {
    width: 100%;
    height: min(80dvh, 720px);
    border: none;
    background: #fff;
    border-radius: 4px;
}

.media-pdf-mobile-view {
    width: 100%;
    min-height: 100%;
}

.media-pdf-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 240px;
    color: #aebac1;
    font-size: 14px;
}

.media-pdf-pages {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.media-pdf-page {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.media-pdf-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 240px;
    padding: 24px;
    text-align: center;
}

.media-pdf-fallback-name {
    color: #e9edef;
    font-size: 14px;
    word-break: break-word;
}

.media-pdf-open-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 180px;
    padding: 12px 20px;
    border-radius: 999px;
    background: #008069;
    color: #fff;
    font-weight: 600;
    text-decoration: none;
}

@media (max-width: 767px) {
    .media-viewer-modal {
        padding: 0;
        z-index: 250;
    }

    .media-viewer-panel {
        width: 100%;
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
    }

    .media-viewer-mobile-pdf .media-viewer-body {
        max-height: calc(100dvh - 56px);
        align-items: flex-start;
        justify-content: flex-start;
        padding: 10px 8px 16px;
    }

    .media-viewer-toolbar {
        padding-top: max(10px, env(safe-area-inset-top));
    }
}

.chat-media-document:focus-visible {
    outline: 2px solid #25d366;
    outline-offset: 2px;
}

@media (min-width: 768px) {
    .chat-header-name {
        display: block;
        -webkit-line-clamp: unset;
        -webkit-box-orient: unset;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .chat-doc-title {
        display: block;
        -webkit-line-clamp: unset;
        -webkit-box-orient: unset;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

.chat-media-image-wrap {
    -webkit-tap-highlight-color: transparent;
}

.deleted-msg-placeholder {
    min-width: 140px;
    padding: 2px 0;
}

/* Admin top navigation (pill tabs) */
.admin-top-nav {
    background: #e8eaed;
    border-bottom: 1px solid #d8dbe0;
    z-index: 30;
}

.dark .admin-top-nav {
    background: #111b21;
    border-bottom-color: #2a3942;
}

.admin-top-nav__inner {
    padding: 10px 12px 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.admin-top-nav__inner::-webkit-scrollbar {
    display: none;
}

.admin-top-nav__track {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
    min-width: min-content;
    padding-bottom: 2px;
}

.admin-nav-pill {
    position: relative;
    display: inline-flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 10px;
    padding: 10px 18px 12px;
    background: #ffffff;
    border: none;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
}

.dark .admin-nav-pill {
    background: #202c33;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.admin-nav-pill:hover:not(.admin-nav-pill--disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.admin-nav-pill.is-active::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: #7c3aed;
}

.admin-nav-pill[data-admin-view="chats"].is-active::after { background: #7c3aed; }
.admin-nav-pill[data-admin-view="users"].is-active::after { background: #0ea5e9; }
.admin-nav-pill[data-admin-view="region_managers"].is-active::after { background: #14b8a6; }
.admin-nav-pill[data-admin-view="groups"].is-active::after { background: #f97316; }
.admin-nav-pill[data-admin-view="reports"].is-active::after { background: #22c55e; }
.admin-nav-pill[data-admin-view="settings"].is-active::after { background: #ec4899; }

.admin-nav-pill.is-active {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.admin-nav-pill--disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.admin-nav-pill__icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    flex-shrink: 0;
}

.admin-nav-pill__icon--purple { background: #7c3aed; }
.admin-nav-pill__icon--blue { background: #0ea5e9; }
.admin-nav-pill__icon--teal { background: #14b8a6; }
.admin-nav-pill__icon--orange { background: #f97316; }
.admin-nav-pill__icon--green { background: #22c55e; }
.admin-nav-pill__icon--pink { background: #ec4899; }

.admin-nav-pill.is-active .admin-nav-pill__icon--purple { box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.25); }
.admin-nav-pill.is-active .admin-nav-pill__icon--blue { box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.25); }
.admin-nav-pill.is-active .admin-nav-pill__icon--teal { box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.25); }
.admin-nav-pill.is-active .admin-nav-pill__icon--orange { box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.25); }

.admin-nav-pill__label {
    font-size: 13px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.2;
}

.dark .admin-nav-pill__label {
    color: #e9edef;
}

.admin-nav-pill__badge {
    font-size: 9px;
    font-weight: 700;
    color: #9ca3af;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 999px;
    margin-right: 4px;
}

.dark .admin-nav-pill__badge {
    background: #2a3942;
    color: #8696a0;
}

.admin-view {
    display: none;
}

.admin-view.admin-view--active {
    display: flex;
}

.admin-users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-user-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.dark .admin-user-card {
    background: #202c33;
    border-color: #2a3942;
}

.admin-user-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.rm-credential-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #f8f9fa;
}

.dark .rm-credential-row {
    background: #111b21;
}

.rm-credential-row--code {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
}

.dark .rm-credential-row--code {
    background: rgba(20, 184, 166, 0.1);
    border-color: rgba(20, 184, 166, 0.25);
}

.rm-credential-label {
    font-size: 10px;
    font-weight: 700;
    color: #667781;
    flex-shrink: 0;
}

.dark .rm-credential-label {
    color: #8696a0;
}

.rm-credential-value {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.rm-credential-value code {
    font-size: 12px;
    font-weight: 700;
    color: #111b21;
    word-break: break-all;
}

.dark .rm-credential-value code {
    color: #e9edef;
}

.rm-login-code {
    font-size: 14px !important;
    letter-spacing: 0.08em;
    color: #0d9488 !important;
}

.dark .rm-login-code {
    color: #2dd4bf !important;
}

.rm-copy-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #8696a0;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

.rm-copy-btn:hover {
    color: #25d366;
    background: rgba(37, 211, 102, 0.1);
}

.groups-table-wrap {
    min-width: 0;
}

.groups-admin-table td,
.groups-admin-table th {
    vertical-align: middle;
}

.groups-admin-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.12s;
}

.dark .groups-admin-table tbody tr {
    border-bottom-color: #2a3942;
}

.groups-admin-table tbody tr:hover {
    background: #f8f9fa;
}

.dark .groups-admin-table tbody tr:hover {
    background: #111b21;
}

.group-token-cell code {
    font-size: 12px;
    font-weight: 700;
    color: #ea580c;
    letter-spacing: 0.05em;
}

.dark .group-token-cell code {
    color: #fb923c;
}

.group-direct-link-cell {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 220px;
}

.group-direct-link-cell__url {
    flex: 1;
    min-width: 0;
    font-size: 10px;
    font-family: ui-monospace, monospace;
    color: #0d9488;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-direct-link-cell__url:hover {
    text-decoration: underline;
}

.dark .group-direct-link-cell__url {
    color: #2dd4bf;
}

.group-action-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.group-action-btn--edit {
    color: #0ea5e9;
}

.group-action-btn--edit:hover {
    background: rgba(14, 165, 233, 0.12);
}

.group-action-btn--delete {
    color: #ef4444;
}

.group-action-btn--delete:hover {
    background: rgba(239, 68, 68, 0.12);
}

/* Region manager add form */
.rm-form-panel {
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    border-top: 3px solid #14b8a6;
}

.dark .rm-form-panel {
    background: #202c33;
    border-color: #2a3942;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.rm-form-panel__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid #eef0f2;
    background: linear-gradient(180deg, #f0fdfa 0%, #fff 100%);
}

.dark .rm-form-panel__header {
    background: linear-gradient(180deg, rgba(20, 184, 166, 0.08) 0%, #202c33 100%);
    border-bottom-color: #2a3942;
}

.rm-form-panel__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #14b8a6;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.rm-form-panel__title {
    font-size: 14px;
    font-weight: 700;
    color: #111b21;
    line-height: 1.3;
}

.dark .rm-form-panel__title {
    color: #e9edef;
}

.rm-form-panel__subtitle {
    font-size: 11px;
    color: #667781;
    margin-top: 2px;
}

.dark .rm-form-panel__subtitle {
    color: #8696a0;
}

.rm-form-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: #8696a0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.rm-form-close-btn:hover {
    background: #f3f4f6;
    color: #ef4444;
}

.dark .rm-form-close-btn:hover {
    background: #2a3942;
}

.rm-form-panel__body {
    padding: 18px;
}

.rm-form-section + .rm-form-section {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px dashed #e5e7eb;
}

.dark .rm-form-section + .rm-form-section {
    border-top-color: #2a3942;
}

.rm-form-section__title {
    font-size: 11px;
    font-weight: 700;
    color: #14b8a6;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.rm-form-grid {
    display: grid;
    gap: 14px;
}

.rm-form-grid--2 {
    grid-template-columns: 1fr;
}

.rm-form-grid--3 {
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .rm-form-grid--2 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 900px) {
    .rm-form-grid--3 {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.rm-field__label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #54656f;
    margin-bottom: 6px;
}

.dark .rm-field__label {
    color: #aebac1;
}

.rm-required {
    color: #ef4444;
}

.rm-optional {
    font-weight: 400;
    color: #9ca3af;
}

.rm-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.rm-input-wrap__icon {
    position: absolute;
    right: 12px;
    color: #8696a0;
    font-size: 13px;
    pointer-events: none;
    z-index: 1;
}

.rm-input {
    width: 100%;
    padding: 10px 38px 10px 12px;
    border-radius: 10px;
    border: 1px solid #dde1e6;
    background: #f8f9fa;
    font-size: 13px;
    color: #111b21;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.dark .rm-input {
    background: #111b21;
    border-color: #2a3942;
    color: #e9edef;
}

.rm-input:focus {
    outline: none;
    border-color: #14b8a6;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
    background: #fff;
}

.dark .rm-input:focus {
    background: #0b141a;
}

.rm-input--mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    letter-spacing: 0.02em;
}

.rm-input--code {
    font-weight: 700;
    letter-spacing: 0.12em;
}

.rm-input-wrap--actions .rm-input--with-btns {
    padding-left: 72px;
}

.rm-input-action-btn {
    position: absolute;
    left: 8px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: #8696a0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: background 0.15s, color 0.15s;
    z-index: 2;
}

.rm-input-action-btn:hover {
    background: rgba(20, 184, 166, 0.12);
    color: #14b8a6;
}

.rm-input-wrap--actions .rm-input-action-btn:nth-last-child(2) {
    left: 40px;
}

.rm-field__hint {
    font-size: 10px;
    color: #8696a0;
    margin-top: 5px;
    line-height: 1.4;
}

.rm-field__hint-btn {
    font-size: 10px;
    color: #14b8a6;
    font-weight: 600;
    margin-top: 5px;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.rm-field__hint-btn:hover {
    color: #0d9488;
}

.rm-form-panel__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #eef0f2;
}

.dark .rm-form-panel__footer {
    border-top-color: #2a3942;
}

.rm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    transition: opacity 0.15s, transform 0.1s;
}

.rm-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.rm-btn--ghost {
    color: #667781;
    background: #f0f2f5;
}

.dark .rm-btn--ghost {
    background: #2a3942;
    color: #aebac1;
}

.rm-btn--ghost:hover {
    background: #e5e7eb;
}

.dark .rm-btn--ghost:hover {
    background: #374955;
}

.rm-btn--primary {
    background: #25d366;
    color: #fff;
    min-width: 140px;
}

.rm-btn--primary:hover:not(:disabled) {
    opacity: 0.92;
}

.rm-btn--primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#region-manager-add-form:not(.hidden) {
    animation: rmFormSlideIn 0.22s ease-out;
}

@keyframes rmFormSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Admin users sidebar (legacy / scroll) */
#admin-users-panel {
    background: var(--admin-surface, #fff);
}

.admin-users-scroll::-webkit-scrollbar {
    width: 5px;
}

.admin-users-scroll::-webkit-scrollbar-thumb {
    background: #374955;
    border-radius: 4px;
}

.admin-user-card {
    cursor: default;
}

/* ============================================================
   Admin Dashboard — Soft light theme (مريح للعين)
   ============================================================ */
.admin-dashboard-page {
    --admin-bg-1: #f0f4fa;
    --admin-bg-2: #e8eef6;
    --admin-bg-3: #f7f4ef;
    --admin-surface: #ffffff;
    --admin-surface-2: #f8fafc;
    --admin-surface-3: #f1f5f9;
    --admin-border: #e2e8f0;
    --admin-border-soft: #edf2f7;
    --admin-text: #334155;
    --admin-text-muted: #64748b;
    --admin-shadow: 0 4px 24px rgba(15, 23, 42, 0.07);
    --admin-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --admin-radius: 14px;
    --admin-accent: #6366f1;
}

body.admin-dashboard-page {
    background: linear-gradient(145deg, var(--admin-bg-1) 0%, var(--admin-bg-2) 45%, var(--admin-bg-3) 100%) !important;
    color: var(--admin-text);
}

body.admin-dashboard-page #admin-app-shell {
    background: transparent;
}

body.admin-dashboard-page .admin-top-nav {
    background: rgba(255, 255, 255, 0.82) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--admin-border) !important;
    box-shadow: var(--admin-shadow-sm);
}

body.admin-dashboard-page .admin-nav-pill {
    background: #fff !important;
    border: 1px solid var(--admin-border-soft);
    box-shadow: var(--admin-shadow-sm) !important;
}

body.admin-dashboard-page .admin-nav-pill__label {
    color: var(--admin-text) !important;
}

body.admin-dashboard-page #app-container {
    background: transparent !important;
    padding: 0 10px 10px;
    gap: 0;
}

body.admin-dashboard-page #admin-view-chats {
    background: var(--admin-surface) !important;
    border-radius: var(--admin-radius);
    border: 1px solid var(--admin-border);
    box-shadow: var(--admin-shadow);
    margin: 0 2px 2px;
    overflow: hidden;
}

body.admin-dashboard-page #sidebar,
body.admin-dashboard-page.dark #sidebar {
    background: var(--admin-surface) !important;
    border-color: var(--admin-border) !important;
}

body.admin-dashboard-page #sidebar .bg-wa-lightHeader,
body.admin-dashboard-page #sidebar .dark\:bg-wa-darkHeader,
body.admin-dashboard-page #sidebar [class*="bg-wa-lightHeader"],
body.admin-dashboard-page #sidebar > div:first-child {
    background: linear-gradient(180deg, #fff 0%, var(--admin-surface-2) 100%) !important;
    border-bottom: 1px solid var(--admin-border) !important;
}

body.admin-dashboard-page #chats-list,
body.admin-dashboard-page .dark #chats-list {
    background: var(--admin-surface) !important;
}

body.admin-dashboard-page #main-space,
body.admin-dashboard-page.dark #main-space {
    background: var(--admin-surface-2) !important;
    border-color: var(--admin-border) !important;
}

body.admin-dashboard-page #welcome-screen {
    background: linear-gradient(165deg, #f8fafc 0%, #eef2ff 55%, #f0fdf4 100%) !important;
    border-color: var(--admin-border) !important;
}

body.admin-dashboard-page #welcome-screen h2 {
    color: #1e293b !important;
}

body.admin-dashboard-page #welcome-screen p {
    color: var(--admin-text-muted) !important;
}

body.admin-dashboard-page #chat-window {
    background: var(--admin-surface-2) !important;
}

body.admin-dashboard-page #chat-window > .h-\[60px\],
body.admin-dashboard-page #chat-window > .h-\[56px\] {
    background: #fff !important;
    border-bottom: 1px solid var(--admin-border) !important;
}

body.admin-dashboard-page #messages-container,
body.admin-dashboard-page #messages-area {
    background-color: #e5ddd5 !important;
    background-image: url("assets/chat-wallpaper.svg") !important;
    background-blend-mode: multiply;
    opacity: 1;
}

body.admin-dashboard-page .bg-wa-lightHeader:not(#sidebar *) {
    background-color: var(--admin-surface-2) !important;
}

body.admin-dashboard-page #notif-banner {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.08), rgba(37, 211, 102, 0.08)) !important;
    border-bottom: 1px solid var(--admin-border-soft);
}

body.admin-dashboard-page #admin-view-users,
body.admin-dashboard-page #admin-view-region-managers,
body.admin-dashboard-page #admin-view-groups {
    background: transparent !important;
    padding: 0 2px 6px;
}

body.admin-dashboard-page .admin-users-page {
    background: var(--admin-surface);
    border-radius: var(--admin-radius);
    border: 1px solid var(--admin-border);
    box-shadow: var(--admin-shadow);
    overflow: hidden;
}

body.admin-dashboard-page .admin-users-page__header {
    background: linear-gradient(180deg, #fff, var(--admin-surface-2)) !important;
    border-color: var(--admin-border) !important;
}

body.admin-dashboard-page .admin-user-card {
    background: #fff !important;
    border-color: var(--admin-border) !important;
    box-shadow: var(--admin-shadow-sm);
}

body.admin-dashboard-page .admin-user-card:hover {
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}

body.admin-dashboard-page .groups-table-wrap {
    background: #fff !important;
    border-color: var(--admin-border) !important;
}

body.admin-dashboard-page .groups-admin-table thead tr {
    background: var(--admin-surface-2) !important;
}

body.admin-dashboard-page .groups-admin-table tbody tr:hover {
    background: #f1f5f9 !important;
}

body.admin-dashboard-page #region-manager-add-form {
    background: transparent !important;
}

body.admin-dashboard-page .rm-form-panel {
    border-color: var(--admin-border);
    box-shadow: var(--admin-shadow);
}

body.admin-dashboard-page .filter-btn:not(.active) {
    background: var(--admin-surface-3) !important;
    color: var(--admin-text-muted) !important;
}

body.admin-dashboard-page .filter-btn.active {
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.25);
}

/* لوحة الأدمن: الوضع الداكن يبقى فاتحاً ومريحاً */
body.admin-dashboard-page.dark {
    --admin-bg-1: #f0f4fa;
    --admin-bg-2: #e8eef6;
    --admin-surface: #ffffff;
    --admin-text: #334155;
}

body.admin-dashboard-page.dark .admin-top-nav {
    background: rgba(255, 255, 255, 0.9) !important;
}

@media (max-width: 767px) {
    body.admin-dashboard-page {
        background: linear-gradient(180deg, var(--admin-bg-1), var(--admin-bg-2)) !important;
    }

    body.admin-dashboard-page #app-container {
        background: transparent !important;
        padding: 0;
    }

    body.admin-dashboard-page #admin-view-chats {
        border: none;
        border-radius: 0;
        margin: 0;
        box-shadow: none;
    }

    body.admin-dashboard-page #sidebar,
    body.admin-dashboard-page #main-space,
    body.admin-dashboard-page #chat-window {
        background: var(--admin-surface) !important;
    }

    body.admin-dashboard-page .mobile-chats-list {
        background: var(--admin-surface) !important;
    }

    body.admin-dashboard-page .mobile-wa-input-bar {
        background: #fff !important;
        border-top: 1px solid var(--admin-border) !important;
    }

    body.admin-dashboard-page #chat-window > .h-\[56px\] {
        background: #fff !important;
    }
}

/* ============================================================
   Lab Dashboard (index) — Soft light theme (مريح للعين)
   ============================================================ */
.lab-dashboard-page {
    --admin-bg-1: #f0f4fa;
    --admin-bg-2: #e8eef6;
    --admin-bg-3: #f7f4ef;
    --admin-surface: #ffffff;
    --admin-surface-2: #f8fafc;
    --admin-surface-3: #f1f5f9;
    --admin-border: #e2e8f0;
    --admin-border-soft: #edf2f7;
    --admin-text: #334155;
    --admin-text-muted: #64748b;
    --admin-shadow: 0 4px 24px rgba(15, 23, 42, 0.07);
    --admin-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --admin-radius: 14px;
}

body.lab-dashboard-page {
    background: linear-gradient(145deg, var(--admin-bg-1) 0%, var(--admin-bg-2) 45%, var(--admin-bg-3) 100%) !important;
    color: var(--admin-text);
}

body.lab-dashboard-page #app-container {
    background: var(--admin-surface) !important;
    border-radius: var(--admin-radius);
    border: 1px solid var(--admin-border);
    box-shadow: var(--admin-shadow);
    overflow: hidden;
}

body.lab-dashboard-page #sidebar,
body.lab-dashboard-page.dark #sidebar {
    background: var(--admin-surface) !important;
    border-color: var(--admin-border) !important;
}

body.lab-dashboard-page #sidebar .bg-wa-lightHeader,
body.lab-dashboard-page #sidebar .dark\:bg-wa-darkHeader,
body.lab-dashboard-page #sidebar [class*="bg-wa-lightHeader"],
body.lab-dashboard-page #sidebar > div:first-child,
body.lab-dashboard-page .sidebar-topbar {
    background: linear-gradient(180deg, #fff 0%, var(--admin-surface-2) 100%) !important;
    border-bottom: 1px solid var(--admin-border) !important;
}

body.lab-dashboard-page #chats-list,
body.lab-dashboard-page .dark #chats-list,
body.lab-dashboard-page .mobile-chats-list {
    background: var(--admin-surface) !important;
}

body.lab-dashboard-page #main-space,
body.lab-dashboard-page.dark #main-space {
    background: var(--admin-surface-2) !important;
    border-color: var(--admin-border) !important;
}

body.lab-dashboard-page #welcome-screen {
    background: linear-gradient(165deg, #f8fafc 0%, #eef2ff 55%, #f0fdf4 100%) !important;
    border-color: var(--admin-border) !important;
}

body.lab-dashboard-page #welcome-screen h2 {
    color: #1e293b !important;
}

body.lab-dashboard-page #welcome-screen p {
    color: var(--admin-text-muted) !important;
}

body.lab-dashboard-page #welcome-screen .fa-flask-vial {
    color: #059669 !important;
    opacity: 0.85;
}

body.lab-dashboard-page #welcome-screen .fa-laptop-medical {
    color: #94a3b8 !important;
}

body.lab-dashboard-page #chat-window {
    background: var(--admin-surface-2) !important;
}

body.lab-dashboard-page #chat-window > .h-\[60px\],
body.lab-dashboard-page #chat-window > .h-\[56px\],
body.lab-dashboard-page #chat-window > .chat-window-header {
    background: #fff !important;
    border-bottom: 1px solid var(--admin-border) !important;
}

body.lab-dashboard-page #messages-container,
body.lab-dashboard-page #messages-area {
    background-color: #e5ddd5 !important;
    background-image: url("assets/chat-wallpaper.svg") !important;
    background-blend-mode: multiply;
}

body.lab-dashboard-page .bg-wa-lightHeader:not(#sidebar *) {
    background-color: var(--admin-surface-2) !important;
}

body.lab-dashboard-page #notif-banner {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.06), rgba(5, 150, 105, 0.06)) !important;
    border-bottom: 1px solid var(--admin-border-soft);
}

body.lab-dashboard-page #notif-banner .bg-emerald-600 {
    background: linear-gradient(135deg, #34d399, #059669) !important;
}

body.lab-dashboard-page .border-emerald-500,
body.lab-dashboard-page [class*="border-emerald"] {
    border-color: #a7f3d0 !important;
}

body.lab-dashboard-page .text-emerald-600 {
    color: #047857 !important;
}

body.lab-dashboard-page .filter-btn:not(.active) {
    background: var(--admin-surface-3) !important;
    color: var(--admin-text-muted) !important;
}

body.lab-dashboard-page .filter-btn.active {
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.2);
}

body.lab-dashboard-page .mobile-wa-input-bar {
    background: #fff !important;
    border-top: 1px solid var(--admin-border) !important;
}

body.lab-dashboard-page .mobile-input-shell {
    background: #fff !important;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

body.lab-dashboard-page #message-input,
body.lab-dashboard-page .mobile-input {
    color: #111b21 !important;
}

body.lab-dashboard-page #message-input::placeholder {
    color: #8696a0 !important;
}

body.lab-dashboard-page.dark {
    --admin-bg-1: #f0f4fa;
    --admin-bg-2: #e8eef6;
    --admin-surface: #ffffff;
    --admin-text: #334155;
}

@media (max-width: 767px) {
    body.lab-dashboard-page {
        background: linear-gradient(180deg, var(--admin-bg-1), var(--admin-bg-2)) !important;
    }

    body.lab-dashboard-page #app-container {
        border: none;
        border-radius: 0;
        box-shadow: none;
        background: var(--admin-surface) !important;
        height: 100% !important;
        max-height: 100% !important;
    }

    body.lab-dashboard-page #sidebar,
    body.lab-dashboard-page #main-space,
    body.lab-dashboard-page #chat-window {
        background: var(--admin-surface) !important;
    }

    body.lab-dashboard-page .sidebar-topbar {
        background: #fff !important;
        border-bottom: 1px solid var(--admin-border) !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   صفحة تسجيل الدخول — ثيم فاتح مريح
   ═══════════════════════════════════════════════════════════════ */
html.login-page,
body.login-page__body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    min-height: 100vh;
    margin: 0;
}

body.login-page__body {
    background: linear-gradient(145deg, #eef4fb 0%, #e4ecf7 45%, #dce8f4 100%);
    color: #334155;
}

.login-page__wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem 2rem;
}

.login-page__brand {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 1.75rem;
}

.login-page__logo {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #059669, #10b981);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    box-shadow: 0 8px 24px rgba(5, 150, 105, 0.28);
}

.login-page__brand-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #1e293b;
    margin: 0;
    line-height: 1.3;
}

.login-page__brand-sub {
    font-size: 0.75rem;
    color: #64748b;
    margin: 0.2rem 0 0;
    font-weight: 600;
}

.login-card {
    width: 100%;
    max-width: 26rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 1.25rem;
    padding: 1.5rem 1.35rem 1.75rem;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
    position: relative;
    overflow: hidden;
}

.login-card__accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #059669, #14b8a6, #0ea5e9);
}

.login-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
    background: #f1f5f9;
    border-radius: 0.85rem;
    padding: 0.3rem;
    margin-bottom: 1.25rem;
}

.login-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.55rem 0.35rem;
    border-radius: 0.65rem;
    font-size: 0.68rem;
    font-weight: 700;
    color: #64748b;
    text-decoration: none;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.login-tab i {
    font-size: 0.95rem;
}

.login-tab:hover {
    color: #334155;
    background: rgba(255, 255, 255, 0.6);
}

.login-tab.is-active {
    background: #fff;
    color: #059669;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.login-tab--teal.is-active {
    color: #0d9488;
}

.login-tab--amber.is-active {
    color: #d97706;
}

.login-card__title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #1e293b;
    margin: 0 0 0.35rem;
}

.login-card__subtitle {
    font-size: 0.78rem;
    color: #64748b;
    margin: 0 0 1rem;
    line-height: 1.5;
}

.login-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
    border-radius: 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.85rem;
    line-height: 1.45;
}

.login-alert i {
    margin-top: 0.1rem;
    flex-shrink: 0;
}

.login-alert--ok {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #047857;
}

.login-alert--warn {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #b45309;
}

.login-alert--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-field label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: #475569;
    margin-bottom: 0.4rem;
}

.login-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.65rem 0.85rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-input-wrap:focus-within {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
    background: #fff;
}

.login-input-wrap__icon {
    color: #94a3b8;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.login-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.875rem;
    color: #1e293b;
    font-family: inherit;
}

.login-input--mono {
    font-family: ui-monospace, 'Cascadia Code', monospace;
    letter-spacing: 0.04em;
}

.login-input::placeholder {
    color: #94a3b8;
}

.login-input-wrap--password {
    padding-left: 0.5rem;
}

.login-toggle-pass {
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 0.35rem;
    line-height: 1;
}

.login-toggle-pass:hover {
    color: #64748b;
    background: #e2e8f0;
}

.login-hint {
    font-size: 0.72rem;
    color: #64748b;
    margin: -0.25rem 0 0;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
}

.login-hint i {
    color: #0ea5e9;
    margin-top: 0.15rem;
}

.login-submit {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    border: none;
    border-radius: 0.75rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    margin-top: 0.35rem;
    transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
    box-shadow: 0 8px 20px rgba(5, 150, 105, 0.25);
}

.login-submit:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.login-submit--lab {
    background: linear-gradient(135deg, #059669, #10b981);
}

.login-submit--region_manager {
    background: linear-gradient(135deg, #0d9488, #14b8a6);
    box-shadow: 0 8px 20px rgba(13, 148, 136, 0.25);
}

.login-submit--admin {
    background: linear-gradient(135deg, #d97706, #f59e0b);
    box-shadow: 0 8px 20px rgba(217, 119, 6, 0.22);
}

.login-page__footer {
    margin-top: 1.5rem;
    font-size: 0.7rem;
    color: #94a3b8;
    text-align: center;
}

@media (max-width: 400px) {
    .login-tab span {
        font-size: 0.62rem;
    }
}

/* PWA — شريط تثبيت التطبيق */
.pwa-install-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.18);
    animation: pwaBannerIn 0.35s ease;
}

body.mobile-chat-open .pwa-install-banner {
    bottom: calc(72px + var(--mobile-bottom-inset, 0px));
}

.pwa-install-banner__content {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.pwa-install-banner__icon {
    border-radius: 12px;
    flex-shrink: 0;
}

.pwa-install-banner__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    text-align: right;
}

.pwa-install-banner__text strong {
    font-size: 14px;
    color: #111b21;
}

.pwa-install-banner__text span {
    font-size: 12px;
    color: #667781;
    line-height: 1.35;
}

.pwa-install-banner__actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.pwa-install-banner__btn {
    border: none;
    border-radius: 999px;
    padding: 8px 16px;
    background: #008069;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.pwa-install-banner__close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: #f0f2f5;
    color: #54656f;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

@keyframes pwaBannerIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (display-mode: standalone) {
    .pwa-install-banner,
    .pwa-install-fab,
    .pwa-install-gate {
        display: none !important;
    }
}

.pwa-install-fab {
    position: fixed;
    left: 16px;
    bottom: calc(84px + var(--mobile-bottom-inset, 0px));
    z-index: 280;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #00a884, #008069);
    color: #fff;
    font-size: 20px;
    box-shadow: 0 6px 20px rgba(0, 128, 105, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pwaBannerIn 0.35s ease;
}

body.mobile-chat-open .pwa-install-fab {
    bottom: calc(96px + var(--mobile-bottom-inset, 0px));
}

/* شاشة التثبيت التلقائي */
body.pwa-gate-open {
    overflow: hidden;
}

.pwa-install-gate {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(165deg, #008069 0%, #005c4b 100%);
}

.pwa-install-gate__panel {
    width: min(380px, 100%);
    background: #fff;
    border-radius: 20px;
    padding: 28px 22px 22px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
    animation: pwaBannerIn 0.4s ease;
}

.pwa-install-gate__icon {
    border-radius: 18px;
    margin: 0 auto 14px;
    box-shadow: 0 4px 16px rgba(0, 128, 105, 0.25);
}

.pwa-install-gate__panel h2 {
    font-size: 20px;
    font-weight: 800;
    color: #111b21;
    margin-bottom: 10px;
}

.pwa-install-gate__panel p {
    font-size: 14px;
    color: #667781;
    line-height: 1.55;
    margin-bottom: 18px;
    min-height: 44px;
}

.pwa-install-gate__btn {
    width: 100%;
    border: none;
    border-radius: 999px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #00a884, #008069);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(0, 128, 105, 0.35);
}

.pwa-install-gate__btn:disabled {
    opacity: 0.75;
}

.pwa-install-gate__skip {
    margin-top: 12px;
    border: none;
    background: transparent;
    color: #8696a0;
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
    padding: 8px;
}

.pwa-install-gate__warn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #fff8e6;
    border: 1px solid #fde68a;
    color: #92400e;
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
}

.pwa-install-gate__browser {
    width: 100%;
    margin-top: 10px;
    border: 2px solid #008069;
    border-radius: 999px;
    padding: 13px 18px;
    background: #fff;
    color: #008069;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
}

.pwa-install-gate__help {
    margin-top: 10px;
    border: none;
    background: transparent;
    color: #54656f;
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    padding: 6px;
}

.pwa-play-protect-help {
    position: fixed;
    inset: 0;
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.pwa-play-protect-help.hidden {
    display: none !important;
}

.pwa-play-protect-help__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(11, 20, 26, 0.55);
}

.pwa-play-protect-help__panel {
    position: relative;
    z-index: 1;
    width: min(420px, 100%);
    max-height: 88vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 16px;
    padding: 18px 18px 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
    text-align: right;
}

.pwa-play-protect-help__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.pwa-play-protect-help__header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    color: #111b21;
}

.pwa-play-protect-help__close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #f0f2f5;
    color: #54656f;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.pwa-play-protect-help__steps {
    margin: 0 0 12px;
    padding-right: 18px;
    color: #3b4a54;
    font-size: 13px;
    line-height: 1.65;
}

.pwa-play-protect-help__steps li + li {
    margin-top: 8px;
}

.pwa-play-protect-help__note {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #f0f9f4;
    border: 1px solid #bbf7d0;
    color: #166534;
    font-size: 12px;
    line-height: 1.55;
}

.pwa-play-protect-help__btn {
    width: 100%;
    border: none;
    border-radius: 999px;
    padding: 13px 16px;
    background: linear-gradient(135deg, #00a884, #008069);
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
}

.login-pwa-help {
    margin-top: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
    overflow: hidden;
}

.login-pwa-help summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: #475569;
    list-style: none;
}

.login-pwa-help summary::-webkit-details-marker {
    display: none;
}

.login-pwa-help__body {
    padding: 0 14px 14px;
    font-size: 12px;
    color: #64748b;
    line-height: 1.6;
}

.login-pwa-help__body p {
    margin: 0 0 8px;
}

.login-pwa-help__body ol {
    margin: 0;
    padding-right: 18px;
}

.login-pwa-help__body li + li {
    margin-top: 6px;
}

.pwa-install-modal {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.pwa-install-modal.hidden {
    display: none !important;
}

.pwa-install-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.pwa-install-modal__panel {
    position: relative;
    z-index: 1;
    width: min(360px, 100%);
    background: #fff;
    border-radius: 16px;
    padding: 24px 20px 20px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.25);
}

.pwa-install-modal__icon {
    border-radius: 16px;
    margin: 0 auto 12px;
}

.pwa-install-modal__panel h3 {
    font-size: 18px;
    font-weight: 700;
    color: #111b21;
    margin-bottom: 8px;
}

.pwa-install-modal__panel p {
    font-size: 14px;
    color: #667781;
    line-height: 1.5;
    margin-bottom: 16px;
}

.pwa-install-modal__btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
}

.pwa-install-modal__help {
    margin-top: 12px;
    font-size: 13px;
    color: #008069;
    line-height: 1.5;
}

.pwa-install-modal__close {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: #f0f2f5;
    color: #54656f;
    font-size: 20px;
    cursor: pointer;
}

@media (min-width: 768px) {
    .pwa-install-fab {
        bottom: 24px;
    }
}

/* شريط تفعيل الإشعارات */
.notif-permission-banner {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
    right: 12px;
    z-index: 450;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.15);
    animation: pwaBannerIn 0.35s ease;
}

.notif-permission-banner__text {
    flex: 1;
    text-align: right;
    min-width: 0;
}

.notif-permission-banner__text strong {
    display: block;
    font-size: 14px;
    color: #111b21;
}

.notif-permission-banner__text span {
    display: block;
    font-size: 12px;
    color: #667781;
    margin-top: 2px;
}

.notif-permission-banner__btn {
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    background: #008069;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.notif-permission-banner__close {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: #f0f2f5;
    color: #54656f;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Chat header — square action buttons in a compact row */
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.chat-header-action-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid rgba(17, 27, 33, 0.1);
    background: #f0f2f5;
    color: #54656f;
    box-shadow: 0 1px 2px rgba(17, 27, 33, 0.06);
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
    cursor: pointer;
    flex-shrink: 0;
}

.chat-header-action-btn i {
    font-size: 18px;
    line-height: 1;
    pointer-events: none;
}

.chat-header-action-btn:hover,
.chat-header-action-btn:focus-visible {
    color: #008069;
    border-color: rgba(0, 128, 105, 0.28);
    background: rgba(0, 128, 105, 0.1);
    outline: none;
}

.chat-header-action-btn:active {
    transform: scale(0.96);
}

body.lab-dashboard-page .chat-header-action-btn {
    background: #eef1f4;
    border-color: #dde3ea;
    color: #3b4a54;
}

body.lab-dashboard-page .chat-header-action-btn:hover,
body.lab-dashboard-page .chat-header-action-btn:focus-visible {
    background: rgba(0, 128, 105, 0.12);
    border-color: rgba(0, 128, 105, 0.35);
    color: #008069;
}

.dark .chat-header-action-btn,
body:not(.lab-dashboard-page) #chat-window .chat-header-action-btn {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    color: #aebac1;
    box-shadow: none;
}

.dark .chat-header-action-btn:hover,
.dark .chat-header-action-btn:focus-visible,
body:not(.lab-dashboard-page) #chat-window .chat-header-action-btn:hover,
body:not(.lab-dashboard-page) #chat-window .chat-header-action-btn:focus-visible {
    background: rgba(0, 128, 105, 0.18);
    border-color: rgba(0, 128, 105, 0.35);
    color: #25d366;
}

@media (min-width: 768px) {
    .chat-header-actions {
        gap: 8px;
    }

    .chat-header-action-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .chat-header-action-btn i {
        font-size: 19px;
    }
}

@media (max-width: 767px) {
    .chat-window-header {
        min-height: 60px !important;
        padding-top: 6px !important;
        padding-bottom: 6px !important;
    }

    .chat-header-actions {
        gap: 5px;
    }

    .chat-header-action-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        border-radius: 11px;
    }

    .chat-header-action-btn i {
        font-size: 17px;
    }
}

/* Group members modal — WhatsApp-style participant list */
.group-members-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.group-members-modal.hidden {
    display: none !important;
}

.group-members-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(11, 20, 26, 0.45);
    backdrop-filter: blur(1px);
}

.group-members-modal-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    max-height: min(88vh, 640px);
    background: #fff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(11, 20, 26, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: groupMembersSlideUp 0.22s ease-out;
}

@keyframes groupMembersSlideUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.group-members-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px 12px;
    background: #f0f2f5;
    border-bottom: 1px solid #e9edef;
    flex-shrink: 0;
}

.group-members-modal-close {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #54656f;
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.group-members-modal-close:hover {
    background: rgba(11, 20, 26, 0.06);
}

.group-members-modal-heading {
    flex: 1;
    min-width: 0;
    text-align: right;
}

.group-members-modal-heading h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #111b21;
    line-height: 1.3;
}

.group-members-modal-subtitle {
    margin: 2px 0 0;
    font-size: 13px;
    color: #667781;
    line-height: 1.3;
}

.group-members-modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    -webkit-overflow-scrolling: touch;
}

.group-members-section + .group-members-section {
    border-top: 8px solid #f0f2f5;
}

.group-members-section-title {
    padding: 10px 20px 6px;
    font-size: 13px;
    font-weight: 600;
    color: #008069;
    text-align: right;
    background: #fff;
}

.group-members-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 20px;
    cursor: default;
    transition: background 0.12s ease;
    border-bottom: 1px solid #f0f2f5;
}

.group-members-row:last-child {
    border-bottom: none;
}

.group-members-row:hover {
    background: #f5f6f6;
}

.group-members-avatar {
    width: 49px;
    height: 49px;
    min-width: 49px;
    min-height: 49px;
    max-width: 49px;
    max-height: 49px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #dfe5e7;
}

.group-members-info {
    flex: 1;
    min-width: 0;
    text-align: right;
}

.group-members-name {
    font-size: 16px;
    font-weight: 500;
    color: #111b21;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-members-meta {
    margin-top: 2px;
    font-size: 13px;
    color: #667781;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-members-empty,
.group-members-loading,
.group-members-error {
    padding: 16px 20px 20px;
    text-align: center;
    font-size: 13px;
    color: #667781;
    line-height: 1.5;
}

.group-members-error {
    color: #ea0038;
}

body.group-members-modal-open {
    overflow: hidden;
}

body.lab-dashboard-page .group-members-modal-panel {
    background: #fff;
}

@media (min-width: 768px) {
    .group-members-modal {
        align-items: center;
        padding: 16px;
    }

    .group-members-modal-panel {
        border-radius: 14px;
        max-height: min(80vh, 620px);
        box-shadow: 0 8px 32px rgba(11, 20, 26, 0.22);
        animation: groupMembersFadeIn 0.2s ease-out;
    }

    @keyframes groupMembersFadeIn {
        from {
            opacity: 0;
            transform: scale(0.97);
        }
        to {
            opacity: 1;
            transform: scale(1);
        }
    }
}
