/* Premium Web Application CSS */
:root {
    /* Light Theme Variables */
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --accent-color: #008069;
    --accent-hover: #006c5b;
    --border-color: #e9edef;
    --message-sent: #d9fdd3;
    --message-received: #ffffff;
    --sidebar-width: 400px;
    --header-height: 60px;
    --icon-color: #54656f;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.fa-phone-alt::before {
    display: inline-block;
    transform: rotate(90deg);
}

[data-theme="dark"] {
    /* Dark Theme Variables */
    --bg-primary: #111b21;
    --bg-secondary: #202c33;
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --accent-color: #00a884;
    --accent-hover: #00c298;
    --border-color: #313d45;
    --message-sent: #005c4b;
    --message-received: #202c33;
    --icon-color: #aebac1;
    --glass-bg: rgba(32, 44, 51, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.hidden {
    display: none !important;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    background-color: var(--bg-primary);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

/* Side Navigation (Left-most bar) */
.side-nav {
    width: 60px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    box-shadow: 0px 0px 3px 1px lightgray;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    z-index: 20;
}

[data-theme="dark"] .side-nav {
    background-color: #111b21;
    /* Slightly darker in dark mode */
}

.nav-top,
.nav-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--icon-color);
    font-size: 1.2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
    gap: 4px;
}

.nav-label {
    display: none;
    /* Hidden on desktop */
}

.nav-btn:hover,
.nav-btn.active {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.nav-btn.active {
    color: var(--accent-color);
}

.nav-avatar {
    width: 32px;
    height: 32px;
    margin-top: 10px;
}

/* Sidebar (Chat List area) */
.sidebar {
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    transition: all 0.3s ease;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-container h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.app-logo {
    height: 32px;
    object-fit: contain;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--icon-color);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 40px;
    height: 40px;
}

.icon-btn:hover {
    color: var(--text-primary);
    background-color: var(--bg-primary);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.avatar:hover {
    border-color: var(--accent-color);
}

/* Search Area */
.search-container {
    padding: 12px 16px 8px 16px;
    background-color: var(--bg-secondary);
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-primary);
    border-radius: 8px;
    padding: 8px 12px;
    gap: 10px;
}

.search-bar i {
    color: var(--icon-color);
    font-size: 0.9rem;
}

.search-bar input {
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* Chat Filters */
.chat-filters {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 4px 16px 12px 16px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: none;
}

.chat-filters::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: none;
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background-color: var(--border-color);
}

.filter-btn.active {
    background-color: #d9fdd3;
    color: #008069;
}

[data-theme="dark"] .filter-btn.active {
    background-color: rgba(0, 168, 132, 0.2);
    color: var(--accent-color);
}

/* Custom Scrollbar (Hidden but scrollable) */
* {
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

*::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari and Opera */
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.chat-item:hover,
.chat-item.active {
    background-color: var(--bg-primary);
}

.group-avatar {
    background-color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.chat-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info h4 {
    font-weight: 500;
    font-size: 1.05rem;
}

.chat-header-info .time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chat-last-message {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-last-message p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

.unread-badge {
    background-color: var(--accent-color);
    color: #fff;
    font-size: 0.7rem;
    font-weight: bold;
    border-radius: 50%;
    padding: 2px 6px;
    display: inline-block;
}

/* Main Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-image: linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05)), url('data:image/svg+xml;utf8,<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="10" r="1" fill="%23000" fill-opacity="0.05"/></svg>');
    background-color: var(--bg-primary);
    position: relative;
}

[data-theme="dark"] .chat-area {
    background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)), url('data:image/svg+xml;utf8,<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="10" r="1" fill="%23fff" fill-opacity="0.05"/></svg>');
}

.chat-header {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 5px;
    border-radius: 8px;
    transition: background 0.2s;
}

.chat-header-left:hover {
    background-color: var(--bg-primary);
}

.chat-title h3 {
    font-weight: 500;
    font-size: 1.1rem;
}

.status {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status.online {
    color: var(--accent-color);
}

.avatar-container {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.avatar-container .avatar {
    width: 100%;
    height: 100%;
    border-radius: 14px;
    object-fit: cover;
}

.calling-indicator-mini {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #10b981;
    border: 2px solid var(--bg-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 9px;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.4);
}

.calling-indicator-mini .pulse-dot {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #10b981;
    border-radius: 50%;
    opacity: 0.6;
    animation: calling-indicator-pulse 1.5s ease-out infinite;
    z-index: -1;
}

@keyframes calling-indicator-pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(2.2); opacity: 0; }
}

.chat-header-actions {
    display: flex;
    gap: 5px;
    align-items: center;
}

.chat-header .icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--icon-color);
    font-size: 1.1rem;
    transition: background 0.2s;
}

.chat-header .icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .chat-header .icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Messages */
.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Old date separator removed in favor of sticky chat-date-separator */

.message {
    max-width: 65%;
    display: flex;
    flex-direction: column;
}

.message.received {
    align-self: flex-start;
}

.message.sent {
    align-self: flex-end;
}

.msg-content {
    display: flex;
    flex-direction: column;
    padding: 10px 14px 8px 14px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
    min-width: 90px;
    max-width: 100%;
    gap: 8px;
    /* Consistent gap between quote and text */
}

.msg-content p.main-msg-text {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
    word-break: break-word;
}

.quoted-message {
    margin: 0 !important;
    /* Managed by flex gap */
}



.message.received .msg-content {
    background-color: var(--message-received);
    border-top-left-radius: 0;
}

.message.sent .msg-content {
    background-color: var(--message-sent);
    border-top-right-radius: 0;
}

.message.sent .quoted-message {
    background-color: rgba(0, 0, 0, 0.08);
}

.msg-content p {
    font-size: 0.95rem;
    line-height: 1.4;
    margin: 0;
    word-break: break-word;
}

.msg-time {
    font-size: 0.65rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    align-self: flex-end;
    margin-top: -4px;
    margin-bottom: -2px;
}

/* Custom SVG Ticks */
.tick-svg {
    width: 16px;
    height: 16px;
    fill: var(--text-secondary);
    vertical-align: middle;
}

.double-tick {
    display: inline-block;
    vertical-align: middle;
    position: relative;
    width: 22px;
    height: 16px;
    margin-right: 4px;
}

.second-tick {
    position: absolute;
    left: 6px;
}

.tick-read .tick-svg {
    fill: #008eff;
    /* Blue color for read ticks */
}

.scroll-bottom-btn {
    position: absolute;
    bottom: 95px;
    right: 20px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    color: var(--icon-color);
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: transform 0.2s, background 0.2s;
}

.scroll-bottom-btn:hover {
    background: var(--bg-primary);
    transform: translateY(-2px);
}

.scroll-bottom-btn i {
    font-size: 1rem;
}

#scroll-unread-count {
    position: absolute;
    top: -5px;
    left: -5px;
    background: var(--accent-color);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
}

/* Unread Badge */
.unread-badge {
    background-color: var(--accent-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* Unread Separator */
/* Old unread separator removed */

/* Context Menu / Message Options */
.message-options-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    background: transparent;
    border: none;
    color: var(--icon-color);
    cursor: pointer;
    font-size: 0.8rem;
}

.message:hover .message-options-btn {
    opacity: 1;
}

.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    /* Softer shadow */
    z-index: 1000;
    width: 170px;
    /* More compact width */
    padding: 6px 0;
    display: flex;
    flex-direction: column;
    animation: menuFadeIn 0.1s ease-out;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

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

.context-menu-item {
    padding: 9px 16px;
    /* Optimized vertical spacing */
    display: flex;
    align-items: center;
    gap: 12px;
    /* Fixed the excessive 36px gap reported */
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--text-primary);
    transition: background-color 0.15s;
}

.context-menu-item:hover {
    background-color: var(--bg-primary);
}

.context-menu-item i {
    width: 20px;
    text-align: center;
    color: #54656f;
    /* Neutral WhatsApp gray for icons */
    font-size: 0.95rem;
}

.context-menu-item.danger {
    color: #ea0038;
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
    padding-top: 10px;
}

.context-menu-item.danger i {
    color: #ea0038;
}


.context-menu-item:hover {
    background: var(--bg-primary);
}

.context-menu-item i {
    width: 20px;
    color: #4b5cc4;
    /* Image 3 icon color */
    font-size: 1.1rem;
}

.context-menu-item.danger {
    color: var(--danger);
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
}

.context-menu-item.danger i {
    color: var(--danger);
}

/* Footer Input Area */
.chat-footer {
    min-height: 62px;
    background-color: var(--bg-secondary);
    padding: 10px 16px;
    display: flex;
    align-items: flex-end; /* Align icons with the bottom message box */
    gap: 16px;
    z-index: 10;
    flex-shrink: 0;
}

.chat-footer .icon-btn {
    margin-bottom: 5px; /* Aligns with the vertical center of the bottom input part */
}

.input-container {
    flex: 1;
    background-color: var(--bg-primary);
    border-radius: 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.input-container:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.1);
}

#message-input {
    width: 100%;
    min-height: 40px;
    max-height: 150px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    padding: 10px 16px;
    overflow-y: auto;
    word-break: break-word;
}

#message-input:empty:before {
    content: attr(data-placeholder);
    color: var(--text-secondary);
    opacity: 0.7;
    cursor: text;
}

.chat-toolbar {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.toolbar-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: var(--bg-primary);
    color: var(--accent-color);
}

.toolbar-btn.active {
    background: var(--accent-color);
    color: white;
}

.toolbar-separator {
    width: 1px;
    height: 18px;
    background: var(--border-color);
    margin: 0 5px;
}

.toolbar-select {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8rem;
    padding: 2px 5px;
    outline: none;
    cursor: pointer;
}

.toolbar-picker-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.hidden-picker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.send-btn {
    background-color: var(--accent-color);
    color: white;
    border-radius: 50%;
}

.send-btn:hover {
    background-color: var(--accent-hover);
    color: white;
    transform: scale(1.05);
}

/* Modals & Glassmorphism Elements */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999; /* Ultra high to be above call overlay */


    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* File Manager Modal Custom Styling */


.fm-search {
    background: var(--bg-secondary) !important;
    border-radius: 20px !important;
    padding: 5px 15px !important;
    width: 300px;
}

.fm-search input {
    border: none;
    background: transparent;
    outline: none;
    margin-left: 10px;
    color: var(--text-primary);
    width: 80%;
    padding: 10px 15px 10px 35px;
    border-radius: 20px;
}

.fm-close-btn {
    font-size: 1.2rem;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    padding: 24px;
    min-width: 400px;
    max-width: 90%;
    color: var(--text-primary);
}

/* Welcome Screen */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-color: var(--bg-primary);
    border-bottom: 6px solid #156bb6;
}

.welcome-content {
    max-width: 500px;
    padding: 20px;
}



.welcome-img svg {
    width: 300px;
    height: auto;
}

.welcome-content h1 {
    font-size: 2rem;
    font-weight: 300;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.welcome-content p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 40px;
}

.welcome-footer {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.hidden {
    display: none !important;
}

.mobile-only {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        max-width: 100%;
        position: relative;
    }

    .mobile-only {
        display: flex !important;
    }

    #back-to-list {
        background: transparent;
        color: var(--text-primary);
        font-size: 1.1rem;
        width: 35px;
        height: 35px;
        margin-right: 8px;
        border-radius: 50%;
        transition: background 0.2s;
    }

    #back-to-list:hover {
        background: var(--bg-primary);
    }



    .fm-header {
        padding-bottom: 0px;
        margin-bottom: 15px;
        border-bottom: none !important;
    }

    .fm-search {
        width: 100% !important;
    }

    .fm-header-actions {
        width: 100%;
    }

    #fm-files-list {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }

    .file-card {
        padding: 10px 8px !important;
    }

    /* Main file icon */
    .file-card div[onclick*="previewFile"] i {
        font-size: 2rem !important;
    }

    /* 3-dot menu icon */
    .file-card .icon-btn i {
        font-size: 0.9rem !important;
    }

    /* Share badge icon */
    .file-card span i {
        font-size: 0.6rem !important;
    }

    .file-card span {
        font-size: 0.6rem !important;
        top: 10px !important;
        left: 10px !important;
    }

    .file-card div[title] {
        font-size: 0.7rem !important;
    }

    .file-card div:last-child span {
        font-size: 0.65rem !important;
    }

    #fm-upload-section {
        padding: 20px !important;
    }

    #fm-upload-section i {
        font-size: 2rem !important;
    }

    .side-nav {
        width: 100%;
        height: 70px;
        flex-direction: row;
        padding: 0;
        border-right: none;
        border-top: 1px solid var(--border-color);
        order: 3;
        position: fixed;
        bottom: 0;
        left: 0;
        background: var(--bg-secondary);
        justify-content: center;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }

    .nav-top,
    .nav-bottom {
        flex-direction: row;
        gap: 0;
        width: 100%;
        height: 100%;
        justify-content: space-around;
        align-items: center;
    }

    .nav-bottom {
        display: none !important;
    }

    .nav-top {
        width: 100% !important;
        display: flex !important;
    }

    .nav-top #nav-new-chat-btn {
        display: none !important;
    }

    .nav-btn {
        flex: 1;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 4px;
        position: relative;
        padding: 4px 0;
        background: transparent !important;
        min-width: 0;
        outline: none;
        border: none;
        -webkit-tap-highlight-color: transparent;
    }

    .nav-btn i {
        font-size: 1.2rem;
        width: 64px;
        /* Fixed capsule width */
        height: 32px;
        /* Fixed capsule height */
        border-radius: 20px;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 2px;
    }

    .nav-btn.active i {
        background-color: rgba(0, 168, 132, 0.12);
        color: var(--accent-color);
    }

    .nav-label {
        display: block;
        font-size: 11px;
        /* Standard mobile nav size */
        font-weight: 500;
        color: var(--text-secondary);
        width: 100%;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .nav-btn.active .nav-label {
        color: var(--text-primary);
    }

    .nav-btn.active::after {
        display: none;
        /* Remove the old top bar in mobile */
    }

    /* Mobile Only / Desktop Only helpers */
    .mobile-only {
        display: flex !important;
    }

    .sidebar-header .mobile-only {
        display: flex !important;
    }

    .desktop-only {
        display: none !important;
    }

    /* Floating Action Button */
    .floating-btn {
        position: fixed;
        right: 20px;
        bottom: 100px;
        /* Higher to avoid overlap with labels */
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background-color: var(--accent-color);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        z-index: 1001;
        border: none;
        cursor: pointer;
        transition: transform 0.2s, background-color 0.2s;
    }

    .floating-btn:active {
        transform: scale(0.9);
        background-color: var(--accent-hover);
    }

    /* Mobile Submenu */
    .mobile-submenu {
        position: absolute;
        top: 60px;
        right: 15px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
        width: 220px;
        z-index: 2000;
        overflow: hidden;
        animation: menuFadeIn 0.2s ease-out;
    }

    .submenu-item {
        padding: 14px 18px;
        display: flex;
        align-items: center;
        gap: 12px;
        color: var(--text-primary);
        text-decoration: none;
        cursor: pointer;
        transition: background 0.2s;
        border-bottom: 1px solid var(--border-color);
    }

    .submenu-item:last-child {
        border-bottom: none;
    }

    .submenu-item:hover {
        background: var(--bg-primary);
    }

    .submenu-item i {
        font-size: 1.1rem;
        color: var(--icon-color);
        width: 20px;
        text-align: center;
    }

    .submenu-item.danger {
        color: var(--danger);
    }

    .submenu-item.danger i {
        color: var(--danger);
    }
}

@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: calc(100vh - 65px);
        z-index: 20;
        transition: transform 0.3s ease-in-out;
    }

    .chat-area {
        width: 100%;
        height: 100% !important;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 30;
        background: var(--bg-primary);
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex !important;
        flex-direction: column;
        padding-bottom: 70px;
        /* Space for the fixed bottom nav */
        visibility: hidden;
    }

    .chat-area.active {
        transform: translateX(0);
        visibility: visible;
    }

    /* Mobile Headers */
    .chat-header {
        height: 65px;
        padding: 0 15px;
    }

    /* Attachment Menu on Mobile (Bottom Sheet style) */
    .attachment-menu {
        left: 5%;
        right: 5%;
        width: 90% !important;
        bottom: 70px;
        transform: none !important;
        grid-template-columns: repeat(3, 1fr);
    }

    /* Staging Overlay on Mobile */
    .staging-content {
        max-height: 90vh;
    }

    .staging-body {
        padding: 10px;
        gap: 8px;
    }

    .staging-preview-item {
        width: 100px;
        height: 100px;
    }

    .scroll-bottom-btn {
        bottom: 140px !important;
        /* Move higher on mobile to avoid footer overlap */
        right: 15px !important;
    }
}

/* Extra Small Screens */
@media (max-width: 480px) {
    .sidebar-header h2 {
        font-size: 1rem;
    }

    .chat-header-left h3 {
        font-size: 0.95rem;
    }

    .message {
        max-width: 85%;
    }
}

.add-participant-btn-info {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.2);
}

.add-participant-btn-info:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(13, 110, 253, 0.3);
}

.add-participant-btn-info i {
    font-size: 0.9rem;
}

/* Contact Info Sidebar */
.info-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100%;
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    z-index: 1000;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
}

.info-sidebar.active {
    transform: translateX(0);
}

.info-sidebar.hidden {
    transform: translateX(100%);
}

.info-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 20px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.info-header span {
    font-weight: 600;
    font-size: 1.1rem;
}

.info-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
    background-color: var(--bg-primary);
}

.info-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px 16px;
    background-color: var(--bg-secondary);
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.info-avatar {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 20px;
}

.info-profile h2 {
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 5px;
}

.info-profile p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.info-section {
    background-color: var(--bg-secondary);
    margin-bottom: 10px;
    padding: 15px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.info-section h3 {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

/* ── Media / Docs Tabbed Panel ─────────────────────────── */
.media-preview {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Tab bar */
.media-tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
    gap: 0;
}

.media-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 0 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.media-tab.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.media-tab-count {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 1px 6px;
    color: var(--text-secondary);
    min-width: 20px;
    text-align: center;
}

.media-tab.active .media-tab-count {
    background: rgba(0, 168, 132, 0.12);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Panels */
.media-panel {
    display: none;
}

.media-panel.active {
    display: block;
}

/* Photo / Video grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
}

.media-grid-cell {
    aspect-ratio: 1;
    background-color: var(--bg-primary);
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s;
}

.media-grid-cell:hover {
    transform: scale(1.03);
    z-index: 1;
}

.media-grid-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-video-thumb {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-color);
    font-size: 1.8rem;
}

/* Docs list */
.media-doc-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.media-doc-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    border-radius: 8px;
    transition: background 0.15s;
    cursor: pointer;
}

.media-doc-row:last-child {
    border-bottom: none;
}

.media-doc-row:hover {
    background: var(--bg-primary);
    padding-left: 8px;
}

.doc-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.doc-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.doc-name {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.doc-dl {
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.media-doc-row:hover .doc-dl {
    opacity: 1;
    color: var(--accent-color);
}

/* Empty state */
.media-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 30px 0;
    color: var(--text-secondary);
}

.media-empty i {
    font-size: 2.2rem;
    opacity: 0.35;
}

.media-empty span {
    font-size: 0.88rem;
    opacity: 0.7;
}

/* Dark mode */
[data-theme="dark"] .media-grid-cell,
[data-theme="dark"] .doc-icon {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .media-doc-row:hover {
    background: rgba(255, 255, 255, 0.04);
}


.info-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    gap: 20px;
    cursor: pointer;
    color: var(--text-primary);
}

.info-item i {
    width: 20px;
    color: var(--icon-color);
    font-size: 1.1rem;
    text-align: center;
}

.info-item span {
    font-size: 1rem;
}

.info-item.danger {
    color: var(--danger);
}

.info-item.danger i {
    color: var(--danger);
}

.participant-list {
    display: flex;
    flex-direction: column;
}

.participant-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    gap: 15px;
}

.participant-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.participant-info {
    flex: 1;
}

.participant-name {
    font-weight: 500;
}

.participant-role {
    font-size: 0.75rem;
    color: var(--accent-color);
    background-color: var(--message-sent);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

[data-theme="dark"] .info-sidebar,
[data-theme="dark"] .info-header,
[data-theme="dark"] .info-profile,
[data-theme="dark"] .info-section {
    background-color: var(--bg-secondary);
}

[data-theme="dark"] .info-content {
    background-color: #0b141a;
}

/* Typing Indicator Animation */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 5px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    background-color: var(--accent-color);
    border-radius: 50%;
    display: inline-block;
    animation: typing 1s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

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

/* Message Info Specifics */
.msg-info-card {
    background-color: var(--bg-secondary);
    margin: 15px 16px;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.msg-info-card .info-item {
    gap: 15px;
    padding: 0;
}

.status-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    background-color: var(--bg-primary);
}

.status-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.status-time {
    font-size: 1rem;
    color: var(--text-primary);
}

.status-icon.sent {
    color: #53bdeb;
}

/* Meeting Card Message */
.msg-meet-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 15px;
    margin-top: 5px;
    width: 280px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
}

.msg-meet-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
}

.meet-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.meet-icon-circle {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #4285f4, #34a853);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(66, 133, 244, 0.2);
}

.meet-header-info {
    display: flex;
    flex-direction: column;
}

.meet-badge {
    font-size: 0.65rem;
    font-weight: 800;
    color: #4285f4;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.meet-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.meet-card-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.meet-info-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.meet-info-row i {
    width: 14px;
    text-align: center;
    color: var(--accent-color);
}

.meet-link-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.8;
}

.meet-join-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    background: #4285f4;
    color: white !important;
    text-decoration: none !important;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s;
}

.meet-join-btn:hover {
    background: #3367d6;
}

.sent .msg-meet-card {
    background: var(--bg-secondary);
}

.status-icon.delivered {
    color: #8696a0;
}

.status-icon.read {
    color: #00a884;
}

/* Reply Feature */
.chat-footer {
    position: relative;
}

.reply-preview {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-secondary);
    padding: 10px 15px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideUp 0.2s ease;
    z-index: 5;
}

.reply-preview.hidden {
    display: none;
}

.reply-content {
    flex: 1;
    border-left: 4px solid var(--accent-color);
    padding-left: 10px;
    background-color: var(--bg-primary);
    border-radius: 4px;
    padding: 5px 10px;
}

.reply-user {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-color);
    display: block;
}

.reply-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
}

.close-reply {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
}

/* Quoted message in bubble */
.quoted-message {
    background-color: rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--accent-color);
    padding: 5px 10px;
    border-radius: 4px;
    margin: 0;
    /* Managed by parent flex gap */
    font-size: 0.85rem;
    cursor: pointer;
}

[data-theme="dark"] .quoted-message {
    background-color: rgba(255, 255, 255, 0.05);
}

.quoted-user {
    font-weight: 600;
    color: var(--accent-color);
    display: block;
    margin-bottom: 2px;
}

.quoted-text {
    color: var(--text-secondary);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@keyframes slideUp {
    from {
        transform: translateY(10px);
        opacity: 0;
    }

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

/* Removed redundant toast styles */

/* Message Highlight */
.message.highlight {
    position: relative;
}

.message.highlight::after {
    content: '';
    position: absolute;
    top: -10px;
    bottom: -10px;
    left: -2000px;
    right: -2000px;
    background-color: rgba(0, 168, 132, 0.12);
    /* Subtle WhatsApp green tint for light mode */
    z-index: 100;
    pointer-events: none;
    animation: rowFlash 2s ease forwards;
    opacity: 0;
}

@keyframes rowFlash {
    0% {
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

[data-theme="dark"] .message.highlight::after {
    background-color: rgba(123, 230, 208, 0.344);
    /* Subtle WhatsApp green tint for light mode */
}

@keyframes rowFlash {
    0% {
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.edited-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-right: 4px;
}

/* Extra Message Features */
.starred-icon {
    color: #ffb100;
    font-size: 0.7rem;
    margin-right: 4px;
}

.pinned-icon {
    position: absolute;
    top: 5px;
    left: 8px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    transform: rotate(45deg);
}

.msg-reactions {
    position: absolute;
    bottom: -12px;
    right: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 5;
    cursor: default;
}

.react-count {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.reaction-picker {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 12px;
    display: flex;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: pickerPop 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes pickerPop {
    from {
        transform: scale(0.5);
        opacity: 0;
    }

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

.reaction-picker span {
    font-size: 1.4rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.reaction-picker span:hover {
    transform: scale(1.3);
}


/* Pinned Messages Bar */
.pinned-messages-bar {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    z-index: 10;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

.pinned-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.pinned-bar-left i {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.pinned-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pinned-info span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-color);
}

.pinned-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Duration Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 12px;
    width: 320px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.modal-content h3 {
    margin-top: 0;
    color: var(--text-primary);
}

.duration-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 20px 0;
}

.duration-btn {
    padding: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.duration-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.cancel-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 600;
}


.reaction-emoji {
    width: 18px;
    height: 18px;
    vertical-align: middle;
}


.reaction-picker span.active {
    background: rgba(var(--accent-color-rgb), 0.2);
    border-radius: 50%;
    padding: 2px;
}

.plus-react {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}

.plus-react:hover {
    background: var(--accent-color);
    color: white;
    transform: scale(1.1);
}


/* Reaction Toast Notification */
.reaction-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 320px;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reaction-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.reaction-toast span {
    overflow: hidden;
    text-overflow: ellipsis;
}


/* Message Highlight Animation */
@keyframes msgHighlightPulse {
    0% {
        background-color: transparent;
    }

    20% {
        background-color: rgba(0, 168, 132, 0.25);
    }

    80% {
        background-color: rgba(0, 168, 132, 0.25);
    }

    100% {
        background-color: transparent;
    }
}

.message.msg-highlight .msg-content {
    animation: msgHighlightPulse 2s ease forwards;
    border-radius: 8px;
}


/* Forward Modal Styling */
#forward-modal {
    width: 400px;
    max-width: 90%;
    background: var(--bg-secondary);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.search-container {
    padding: 12px 16px;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 2;
}

.search-container input {
    width: 100%;
    padding: 10px 15px 10px 35px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.search-container i {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.forward-list {
    display: flex;
    flex-direction: column;
}

.forward-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.forward-item:hover {
    background: var(--bg-primary);
}

.forward-item.selected {
    background: rgba(var(--accent-color-rgb), 0.1);
}

.forward-item .checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.forward-item.selected .checkbox {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.forward-item.selected .checkbox i {
    color: white;
    font-size: 12px;
}

.forward-item .avatar {
    width: 40px;
    height: 40px;
}

.modal-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#send-forward-btn {
    padding: 10px 24px;
    border-radius: 25px;
    background: var(--accent-color);
    color: white;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#send-forward-btn:disabled {
    background: var(--text-secondary);
    opacity: 0.5;
    cursor: not-allowed;
}

/* Forwarded Label */
.forwarded-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 4px;
    opacity: 0.8;
}

.forwarded-label i {
    font-size: 0.7rem;
    transform: scaleX(-1);
    /* Flip the share icon to look like a back arrow */
}

/* Deleted Messages */
.deleted-msg {
    opacity: 0.6;
    font-style: italic;
}

.deleted-msg .main-msg-text {
    color: var(--text-secondary) !important;
    display: flex;
    align-items: center;
    gap: 6px;
}

.deleted-msg i {
    font-size: 0.8rem;
}



/* Notification / Toast System */
#toast-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 11000;
    /* Higher than all modals */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    pointer-events: none;
}

.toast {
    background: rgba(32, 32, 32, 0.95);
    backdrop-filter: blur(10px);
    color: #fff;
    padding: 14px 32px;
    border-radius: 12px;
    /* Slightly more modern than 50px for center toasts */
    font-size: 1rem;
    font-weight: 500;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastEnter 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    pointer-events: auto;
    max-width: 90vw;
    width: auto;
    min-width: 280px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    justify-content: center;
}

.toast span {
    word-break: break-word;
    white-space: normal;
    line-height: 1.4;
}

.toast.error {
    background: rgba(229, 57, 53, 0.95);
}

.toast.success {
    background: rgba(67, 160, 71, 0.95);
}

.toast.info {
    background: rgba(30, 136, 229, 0.95);
}

@keyframes toastEnter {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

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

.toast.hide {
    animation: toastExit 0.3s ease-in forwards;
}

@keyframes toastExit {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* Calling Pulse Animation */
@keyframes pulseCalling {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; box-shadow: 0 0 25px rgba(255, 255, 255, 0.4); }
    100% { transform: scale(1); opacity: 0.8; }
}

@keyframes ripplePulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.3), 0 0 0 0 rgba(255, 255, 255, 0.2); }
    70% { box-shadow: 0 0 0 40px rgba(255, 255, 255, 0), 0 0 0 70px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0), 0 0 0 0 rgba(255, 255, 255, 0); }
}

.calling-pulse {
    animation: pulseCalling 1.5s infinite ease-in-out;
    border-radius: 50%;
}

.ripple-pulse {
    animation: ripplePulse 2s infinite ease-out;
}

.pending-calling {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 2px dashed rgba(255, 255, 255, 0.1) !important;
}

.pending-calling .audio-avatar {
    border: 3px solid rgba(255, 255, 255, 0.5) !important;
    filter: grayscale(0.5);
    opacity: 0.6;
}

.calling-text {
    display: inline-block;
}

.calling-text::after {
    content: '...';
    display: inline-block;
    width: 0;
    overflow: hidden;
    animation: dots 1.5s infinite steps(4);
    vertical-align: bottom;
}

@keyframes dots {
    to { width: 1.25em; }
}


/* Custom Alert Modal */
.custom-alert {
    width: 380px;
    max-width: 90%;
    border-radius: 24px;
    padding: 32px !important;
    background: var(--bg-primary);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.custom-alert h3 {
    margin-top: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 12px;
}

#alert-message-box {
    margin: 16px 0 24px;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 1rem;
}

.modal-actions button {
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
}

#alert-ok-btn {
    background: linear-gradient(135deg, var(--accent-color), #4fb99f);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 168, 132, 0.2);
}

#alert-ok-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 168, 132, 0.3);
}

/* Selection Header - overlays normal chat header */

.selection-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--accent-color);
    display: flex;
    align-items: center;
    padding: 0 8px 0 4px;
    gap: 6px;
    z-index: 200;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: selHeaderIn 0.2s ease;
}

@keyframes selHeaderIn {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }

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

.sel-icon-btn {
    color: white !important;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}

.sel-icon-btn:hover {
    background: rgba(255, 255, 255, 0.18) !important;
}

.sel-icon-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

#selection-count-label {
    flex: 1;
    font-size: 1.05rem;
    font-weight: 500;
    color: white;
    user-select: none;
    padding-left: 4px;
}

.selection-actions {
    display: flex;
    gap: 4px;
}

/* Messages container in selection mode */
.messages-container.selection-mode .message {
    cursor: pointer;
    padding-left: 52px;
    position: relative;
    transition: padding 0.15s;
}

/* Hide the options (chevron) button in selection mode */
.messages-container.selection-mode .message-options-btn {
    display: none !important;
}

/* Circular checkbox on each message */
.msg-select-checkbox {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s, border-color 0.18s, transform 0.18s;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.message.msg-selected .msg-select-checkbox {
    background: var(--accent-color);
    border-color: var(--accent-color);
    transform: translateY(-50%) scale(1.1);
}

.msg-select-checkbox i {
    color: white;
    font-size: 0.7rem;
    display: none;
}

.message.msg-selected .msg-select-checkbox i {
    display: block;
}

/* Selected message bubble highlight */
.message.msg-selected {
    background: rgba(0, 128, 105, 0.08);
    border-radius: 4px;
}

.message.msg-selected .msg-content {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

[data-theme="dark"] .message.msg-selected {
    background: rgba(0, 168, 132, 0.12);
}

/* ======================================================
   FORWARD CONTACT PICKER MODAL
   ====================================================== */

#forward-modal {
    width: 440px;
    max-width: 95vw;
    max-height: 85vh;
    background: var(--bg-secondary);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: fwdModalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fwdModalIn {
    from {
        opacity: 0;
        transform: scale(0.88) translateY(30px);
    }

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

.forward-modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.forward-modal-header h3 {
    flex: 1;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.forward-search-wrap {
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.forward-search-wrap input {
    width: 100%;
    padding: 9px 14px 9px 38px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.2s;
}

.forward-search-wrap input:focus {
    border-color: var(--accent-color);
}

.forward-search-wrap .search-icon {
    position: absolute;
    left: 26px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.82rem;
    pointer-events: none;
}

.forward-contact-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.forward-contact-list {
    display: flex;
    flex-direction: column;
    padding: 6px 0;
}

.forward-contact-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    gap: 14px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.forward-contact-item:hover {
    background: var(--bg-primary);
}

.forward-contact-item.selected {
    background: rgba(0, 128, 105, 0.09);
}

[data-theme="dark"] .forward-contact-item.selected {
    background: rgba(0, 168, 132, 0.13);
}

.forward-contact-checkbox {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.18s, border-color 0.18s;
}

.forward-contact-item.selected .forward-contact-checkbox {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.forward-contact-item.selected .forward-contact-checkbox::after {
    content: '';
    width: 5px;
    height: 9px;
    border: 2px solid white;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(-1px, -1px);
    display: block;
}

.forward-contact-name {
    font-size: 0.93rem;
    font-weight: 500;
    color: var(--text-primary);
}

.forward-contact-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 1px;
}

.forward-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-size: 0.9rem;
}

.forward-modal-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary);
    flex-shrink: 0;
    min-height: 60px;
}

.forward-selected-chips {
    flex: 1;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    min-height: 28px;
}

.forward-chip {
    background: var(--accent-color);
    color: white;
    border-radius: 14px;
    padding: 3px 10px;
    font-size: 0.76rem;
    font-weight: 500;
    white-space: nowrap;
    animation: chipPop 0.15s ease;
}

@keyframes chipPop {
    from {
        transform: scale(0.6);
        opacity: 0;
    }

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

#send-forward-btn {
    padding: 10px 22px;
    border-radius: 24px;
    background: var(--accent-color);
    color: white;
    border: none;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    flex-shrink: 0;
}

#send-forward-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.04);
}

#send-forward-btn:disabled {
    background: var(--text-secondary);
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.fwd-group-label {
    padding: 8px 16px 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}



/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 20px;
    width: 350px;
    height: 450px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 2000;
    overflow: hidden;
    animation: pickerSlideUp 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

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

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

.emoji-picker-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

#emoji-search {
    width: 100%;
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}

.emoji-categories {
    display: flex;
    padding: 10px;
    gap: 5px;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.cat-btn {
    flex: 0 0 35px;
    height: 35px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cat-btn:hover,
.cat-btn.active {
    background: var(--bg-hover);
    color: var(--primary-color);
}

.emoji-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 10px;
    align-content: flex-start;
}

.emoji-item {
    font-size: 1.8rem;
    cursor: pointer;
    transition: transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    border-radius: 8px;
}

.emoji-item:hover {
    background: var(--bg-hover);
    transform: scale(1.2);
}

.emoji-item img {
    width: 28px;
    height: 28px;
}

.emoji-picker.hidden {
    display: none;
}

.inline-emoji {
    width: 26px;
    /* Increased from 22px */
    height: 26px;
    vertical-align: -6px;
    margin: 0 2px;
    display: inline-block;
    transition: transform 0.2s;
}

/* Jumbo Emojis (when message has only 1-3 emojis and no text) */
.inline-emoji.jumbo {
    width: 48px;
    height: 48px;
    margin: 5px;
    vertical-align: middle;
}


/* For contact list preview */
.chat-last-message .inline-emoji {
    width: 16px !important;
    height: 16px !important;
    vertical-align: -2px !important;
    margin: 0 !important;
}



/* ---- Attachment Menu (WhatsApp Style) ---- */
.attachment-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.attachment-menu {
    position: absolute;
    bottom: 70px;
    left: 40px;
    /* Shifted left to stay clear of right-side buttons */
    background: var(--bg-secondary);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    z-index: 1100;
    pointer-events: auto !important;
    width: 250px;
    animation: attachMenuPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes attachMenuPop {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }

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

.attachment-menu.hidden {
    display: none;
}

.attach-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.attach-item:hover {
    transform: translateY(-3px);
}

.attach-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.attach-item span {
    font-size: 0.75rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* WhatsApp Icon Colors */
.attach-icon.doc {
    background: linear-gradient(135deg, #7f66ff, #512da8);
}

/* Violet */
.attach-icon.camera {
    background: linear-gradient(135deg, #ff5e91, #d81b60);
}

/* Pink/Red */
.attach-icon.gallery {
    background: linear-gradient(135deg, #c561ff, #8e24aa);
}

/* Purple */
.attach-icon.audio {
    background: linear-gradient(135deg, #ff9800, #f57c00);
}

/* Orange */
.attach-icon.location {
    background: linear-gradient(135deg, #00c853, #00a040);
}

/* Green */
.attach-icon.contact {
    background: linear-gradient(135deg, #0091ea, #0277bd);
}

/* Blue */

/* ---- Media Message Containers ---- */
.msg-image-container {
    margin-bottom: 5px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
}

.chat-img {
    max-width: 100%;
    max-height: 300px;
    display: block;
    object-fit: cover;
    transition: transform 0.3s;
}

.chat-img:hover {
    transform: scale(1.02);
}

.media-caption {
    margin-top: 8px;
    padding: 0 5px;
    font-size: 0.95rem;
}

.msg-file-container {
    background: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    min-width: 200px;
    margin-bottom: 5px;
    transition: background 0.2s;
}

.msg-file-container:hover {
    background: rgba(0, 0, 0, 0.08);
}

.file-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7f66ff;
    font-size: 1.2rem;
}

.file-info {
    flex: 1;
    overflow: hidden;
}

.file-name {
    font-size: 0.9rem;
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.file-download {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.msg-audio-container {
    padding: 5px 0;
}

.msg-audio-container audio {
    height: 35px;
    max-width: 100%;
}

.msg-video-container {
    position: relative;
    max-width: 300px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: #000;
}

.video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    transition: all 0.3s;
}

.msg-video-container:hover .video-play-overlay {
    background: var(--accent-color);
    border-color: var(--accent-color);
    transform: translate(-50%, -50%) scale(1.1);
}


/* ---- Media Preview Modal (Lightbox) ---- */
.media-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.media-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
}

.media-modal-content {
    position: relative;
    max-width: 700px;
    /* Constrained to medium size by default */
    width: 90%;
    max-height: 85vh;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: max-width 0.3s ease;
}

.media-modal-content.doc-preview-mode {
    max-width: 1000px;
}

.media-modal-content.doc-preview-mode #media-preview-body img,
.media-modal-content.doc-preview-mode #media-preview-body video {
    max-height: none;
}

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

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

.media-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.2);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.media-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

#media-preview-body {
    width: 100%;
    display: flex;
    justify-content: center;
    overflow: hidden;
    border-radius: 12px;
}

#media-preview-body img {
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
}

#media-preview-body video {
    max-width: 100%;
    max-height: 65vh;
}


.media-modal-footer {
    margin-top: 20px;
}

.media-download-btn {
    background: var(--accent-color);
    color: white;
    padding: 10px 25px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s;
}

.media-download-btn:hover {
    transform: scale(1.05);
}

/* ---- Download Before Preview Styles ---- */
.msg-media-placeholder {
    position: relative;
    width: 280px;
    height: 200px;
    background: var(--bg-hover);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    margin-bottom: 5px;
}

.placeholder-blur {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: blur(25px) brightness(0.6);
    opacity: 0.7;
}

.download-overlay {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: white;
    text-align: center;
}

.download-circle {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    border: 2px solid rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    transition: all 0.3s;
}

.msg-media-placeholder:hover .download-circle {
    background: var(--accent-color);
    border-color: var(--accent-color);
    transform: scale(1.1);
}

.placeholder-text {
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 16px;
    border-radius: 20px;
    letter-spacing: 0.5px;
}

.media-modal.hidden {
    display: none;
    pointer-events: none;
}

/* ---- Attachment Staging Overlay (WhatsApp Style) ---- */
.staging-modal {
    position: absolute;
    bottom: 62px;
    /* Positioned above the chat footer */
    left: 0;
    width: 100%;
    height: auto;
    max-height: calc(100% - 62px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.staging-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(var(--bg-primary-rgb, 240, 242, 245), 0.7);
    backdrop-filter: blur(12px);
    pointer-events: none;
}

.staging-content {
    position: relative;
    width: 100%;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    max-height: 500px;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
    animation: slideUpStaging 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-top: 1px solid var(--border-color);
}

@keyframes slideUpStaging {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.staging-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-primary);
}

.staging-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.close-staging {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.close-staging:hover {
    background: var(--bg-hover);
    color: var(--danger, #dc3545);
}

.staging-body {
    flex: 1;
    padding: 15px;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    gap: 12px;
    background: var(--bg-primary);
    min-height: 120px;
}

.staging-item {
    position: relative;
    flex: 0 0 100px;
    height: 100px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

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

.staging-item .file-preview {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: var(--accent-color);
    padding: 5px;
}

.staging-item .file-preview span {
    font-size: 0.6rem;
    color: var(--text-secondary);
    text-align: center;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.remove-staged {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

.remove-staged:hover {
    background: rgba(255, 59, 48, 0.8);
}

.staging-footer {
    padding: 15px 20px;
    background: var(--bg-secondary);
}

.staging-actions {
    margin-bottom: 12px;
    display: flex;
    gap: 10px;
}

.add-more-btn {
    background: transparent;
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    padding: 6px 14px;
    border-radius: 18px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.add-more-btn:hover {
    background: rgba(var(--accent-rgb), 0.1);
}

.staging-send-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

.staging-send-wrapper input {
    flex: 1;
    padding: 12px 18px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.staging-send-wrapper input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.staging-send-wrapper input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.staging-send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-color);
    color: white;
    border: none;
    font-size: 1.15rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 168, 132, 0.35);
    transition: all 0.2s;
    flex-shrink: 0;
}

.staging-send-btn:hover, .staging-send-btn:active {
    transform: scale(1.08);
    background: #008f72;
    box-shadow: 0 6px 16px rgba(0, 168, 132, 0.45);
}

.staging-modal.hidden {
    display: none;
}

/* Footer dim state when staging is active */
.chat-active-footer.staging-active {
    pointer-events: none;
    opacity: 0.5;
    filter: blur(1px);
    transition: all 0.3s;
}

/* Mobile staging improvements */
@media (max-width: 768px) {
    .staging-content {
        max-height: 70vh;
    }

    .staging-body {
        min-height: 100px;
        padding: 12px;
    }

    .staging-item {
        flex: 0 0 90px;
        height: 90px;
    }

    .staging-footer {
        padding: 12px 15px;
    }

    .staging-actions {
        margin-bottom: 10px;
        gap: 8px;
    }

    .add-more-btn {
        padding: 8px 14px;
        font-size: 0.82rem;
    }

    .staging-send-wrapper input {
        padding: 11px 15px;
        font-size: 0.9rem;
    }

    .staging-send-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .remove-staged {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }
}

/* ---- Voice Recording UI ---- */
.voice-recording-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 5;
    border-radius: 20px;
}

.recording-status {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--danger);
    font-weight: 500;
}

.recording-dot {
    animation: pulseMic 1.5s infinite;
}

@keyframes pulseMic {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
        opacity: 0.5;
    }

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

#recording-timer {
    color: var(--text-primary);
    font-family: monospace;
    font-size: 1.1rem;
}

.recording-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.slide-instruction {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#voice-record-btn {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#voice-record-btn.recording {
    color: var(--danger);
    transform: scale(1.2);
}

#stt-btn {
    transition: all 0.3s ease;
}

#stt-btn.recording {
    color: var(--accent-color);
    animation: sttPulse 1.5s infinite;
}

/* STT Language Change Indicator (Premium) */
.stt-lang-toast-premium {
    position: absolute;
    bottom: calc(100% + 20px);
    left: 50%;
    transform: translateX(-50%);
    background: #3b82f6; /* Premium Blue for visibility as in screenshot */
    color: white;
    padding: 8px 18px;
    border-radius: 25px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4);
    z-index: 1000;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stt-lang-toast-premium.show {
    opacity: 1;
    bottom: calc(100% + 12px);
    pointer-events: auto;
}

.stt-lang-toast-premium i {
    font-size: 0.95rem;
}

@keyframes sttPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

.stt-status-indicator {
    position: absolute;
    bottom: 100%;
    left: 10px;
    background: var(--accent-color);
    color: white;
    padding: 4px 12px;
    border-radius: 12px 12px 0 0;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 5;
    animation: slideUp 0.3s ease;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.1);
}

.stt-status-indicator i {
    font-size: 0.7rem;
    animation: sttPulse 1.5s infinite;
}

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

.stt-wrapper {
    position: absolute;
    right: 12px;
    bottom: 8px; /* Align with input text */
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 5;
}

.stt-icon-btn {
    background: transparent;
    border: none;
    color: var(--icon-color);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border-radius: 50%;
}

.stt-icon-btn:hover {
    color: var(--accent-color);
    background: rgba(var(--accent-rgb), 0.1);
}


#stt-btn.recording {
    color: var(--accent-color);
    animation: sttPulse 1.5s infinite;
}

/* Adjust message input padding to make room for the STT icon */
#message-input {
    padding-right: 104px !important;
}



.icon-btn.danger {
    color: var(--danger);
}

.icon-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Call Overlay & UI */
.call-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #1a2a6c, #b21f1f, #fdbb2d); /* Rich fallback gradient */
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: calc(60px + env(safe-area-inset-top)) 20px calc(40px + env(safe-area-inset-bottom));
    color: white;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(15px);
}

[data-theme="dark"] .call-overlay {
    background: linear-gradient(160deg, #020617 0%, #0f172a 100%);
}

.call-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    z-index: 100;
    animation: fadeIn 0.8s ease;
}

.call-avatar {
    width: 170px;
    height: 170px;
    border-radius: 50%;
    margin-bottom: 28px;
    border: 4px solid rgba(255, 255, 255, 0.35);
    object-fit: cover;
    background: transparent;
    box-shadow:
        0 0 0 10px rgba(255, 255, 255, 0.07),
        0 0 0 20px rgba(255, 255, 255, 0.04),
        0 20px 50px rgba(0, 0, 0, 0.4);
    animation: avatarPulse 2.4s ease-in-out infinite;
    transition: box-shadow 0.4s ease;
}

@keyframes avatarPulse {
    0%, 100% {
        box-shadow:
            0 0 0 10px rgba(255, 255, 255, 0.07),
            0 0 0 20px rgba(255, 255, 255, 0.04),
            0 20px 50px rgba(0, 0, 0, 0.4);
    }
    50% {
        box-shadow:
            0 0 0 14px rgba(255, 255, 255, 0.11),
            0 0 0 28px rgba(255, 255, 255, 0.06),
            0 20px 50px rgba(0, 0, 0, 0.4);
    }
}

/* Stop pulse animation when call is connected */
.call-overlay.video-active .call-avatar,
.call-overlay.connected .call-avatar {
    animation: none;
}

/* Hide static call avatar on audio load to avoid duplicate overlapping */
.call-overlay.connected:not(.video-active) .call-avatar {
    display: none !important;
}

/* Beautifully position name and timer below the dynamic avatar */
.call-overlay.connected:not(.video-active) .call-info {
    position: absolute;
    top: calc(50% + 130px);
    width: 100%;
    z-index: 15;
}
.call-overlay.connected:not(.video-active) .call-name {
    font-size: 2rem;
    margin-bottom: 5px;
    text-shadow: 0 4px 15px rgba(0,0,0,0.5);
}
.call-overlay.connected:not(.video-active) .call-status {
    font-size: 1.15rem;
    letter-spacing: 2px;
    opacity: 0.9;
}

.call-name {
    font-size: 2.4rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
}

.call-status {
    font-size: 1.1rem;
    opacity: 0.85;
    margin: 0;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 500;
}

/* Professional Video Active State */
.call-overlay.video-active .call-info {
    position: absolute;
    top: 40px;
    z-index: 200;
    flex-direction: row;
    gap: 15px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 10px 24px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slideInDown 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

.call-overlay.video-active .call-avatar {
    width: 42px;
    height: 42px;
    margin-bottom: 0;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: none;
    animation: none;
}

.call-overlay.video-active .call-name {
    font-size: 1.2rem;
    font-weight: 600;
    text-shadow: none;
}

.call-overlay.video-active .call-status {
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    text-transform: none;
    font-weight: 400;
    opacity: 0.9;
}


.video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: none;
}

/* Ensure audio calls have transparent background to show call-overlay gradient */
.call-overlay:not(.video-active) .video-container {
    background: transparent !important;
}

.remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
    transition: opacity 0.5s ease;
}

.local-video {
    position: absolute;
    bottom: 120px;
    right: 20px;
    width: 120px;
    height: 180px;
    background: #222;
    border-radius: 12px;
    border: 2px solid white;
    object-fit: cover;
    z-index: 10;
}

.call-actions {
    display: flex;
    gap: 30px;
    z-index: 20;
}

.call-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
}

.call-btn.end {
    background-color: #f44336;
    color: white;
}

.call-btn.accept {
    background-color: #4caf50;
    color: white;
}

.call-btn.mute,
.call-btn.video-off {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.call-btn.mute.active,
.call-btn.video-off.active,
.call-btn.speaker.active {
    background-color: white;
    color: #333;
}

.call-btn:hover {
    transform: scale(1.1);
}

.incoming-call-alert {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10000;
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.incoming-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.incoming-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
}

.incoming-text h4 {
    margin: 0;
    font-size: 0.95rem;
}

.incoming-text p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.incoming-actions {
    display: flex;
    gap: 10px;
}

.inc-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
}

.inc-btn.accept {
    background: #4caf50;
}

.inc-btn.reject {
    background: #f44336;
}

/* Minimized Call */
.call-overlay.minimized {
    width: 250px;
    height: 150px;
    top: 20px;
    right: 20px;
    left: auto;
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    flex-direction: row;
    justify-content: center;
}

.call-overlay.minimized .call-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    margin-right: 10px;
}

.call-overlay.minimized .call-avatar {
    width: 40px;
    height: 40px;
    margin-bottom: 5px;
    box-shadow: none;
    animation: none;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.call-overlay.minimized .call-name {
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.call-overlay.minimized .call-status {
    font-size: 0.75rem;
}

.call-overlay.minimized .call-actions {
    gap: 10px;
}

.call-overlay.minimized .call-btn {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
}

.call-overlay.minimized .video-container {
    border-radius: 16px;
}

.call-overlay.minimized .local-video {
    width: 50px;
    height: 70px;
    bottom: 10px;
    right: 10px;
}

/* Call History Items */
.call-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.call-item:hover {
    background-color: var(--bg-hover);
}

.call-count {
    color: var(--accent-color);
    font-weight: 500;
    font-size: 0.9rem;
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 12px;
}

.call-icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(var(--primary-rgb), 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.call-icon-wrap.missed {
    color: #f44336;
    background: rgba(244, 67, 54, 0.1);
}

.call-details {
    flex: 1;
}

.call-details h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.call-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.call-meta i {
    font-size: 0.7rem;
}

.call-meta i.outgoing {
    color: #4caf50;
}

.call-meta i.incoming {
    color: #2196f3;
}

.call-meta i.missed {
    color: #f44336;
}

.call-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* In-Chat Call Message Log */
.message.call-log {
    margin: 10px 0;
}

.message.call-log.sent {
    align-self: flex-end;
}

.message.call-log.received {
    align-self: flex-start;
}

.message.call-log .msg-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    min-width: 140px;
}

.message.call-log.sent .msg-content {
    background: var(--message-sent);
    border-top-right-radius: 0;
}

.message.call-log.received .msg-content {
    background: var(--message-received);
    border-top-left-radius: 0;
}

.call-log-body {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    font-weight: 500;
}

.message.call-log i {
    font-size: 1.1rem;
    color: var(--text-primary);
    padding: 8px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
}

.message.call-log.missed .call-log-body,
.message.call-log.declined .call-log-body,
.message.call-log.missed i,
.message.call-log.declined i {
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.1) !important;
}


/* Premium Call Overlay */
.call-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.call-overlay.minimized {
    width: 260px;
    height: 160px;
    top: 20px;
    right: 20px;
    left: auto;
    border-radius: 20px;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    padding: 0;
    justify-content: flex-start;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.call-overlay.minimized .call-info {
    position: absolute;
    top: 12px;
    left: 12px;
    align-items: flex-start;
    text-align: left;
    gap: 4px;
    z-index: 150;
    flex-direction: row;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(-5px);
}

.call-overlay.minimized:hover .call-info,
.call-overlay.minimized.click-active .call-info {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.call-overlay.minimized .call-avatar {
    width: 32px;
    height: 32px;
    margin-bottom: 0;
    border-width: 1px;
}

.call-overlay.minimized .call-name {
    font-size: 0.95rem;
    font-weight: 600;
}

.call-overlay.minimized .call-status {
    font-size: 0.75rem;
    letter-spacing: 0;
    text-transform: none;
    opacity: 0.9;
}

.call-overlay.minimized .call-actions {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    gap: 10px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border-radius: 40px;
    justify-content: space-evenly;
    width: auto;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(5px);
}

.call-overlay.minimized:hover .call-actions,
.call-overlay.minimized.click-active .call-actions {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}


.call-overlay.minimized .call-btn {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
}

.call-overlay.minimized .local-video {
    width: 60px;
    height: 80px;
    bottom: 12px;
    right: 12px;
    border-radius: 8px;
}



/* ---- Call Ended Summary Screen ---- */
.call-ended-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(11, 15, 25, 0.98);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeInEnded 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.call-ended-inner {
    text-align: center;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 20px;
    width: 100%;
    max-width: 500px;
}

.ended-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255,255,255,0.15);
    box-shadow: 0 0 0 12px rgba(255,255,255,0.05);
}

.ended-icon {
    width: 52px;
    height: 52px;
    background: rgba(239, 68, 68, 0.2);
    border: 2px solid rgba(239, 68, 68, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    font-size: 1.2rem;
}

.ended-label {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.55);
    margin: 0;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.call-ended-inner h3 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 5px 0;
    color: white;
    letter-spacing: -0.5px;
}

.ended-duration {
    font-size: 1.6rem;
    font-weight: 700;
    color: #10b981;
    margin: 0;
    letter-spacing: 0.05em;
}

.ended-participants {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 15px;
    max-width: 350px;
}

.ended-participant-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 0.8rem;
}

.ended-participant-chip img {
    width: 18px;
    height: 18px;
    border-radius: 50%;
}


/* No Answer Actions */
.na-actions-grid {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    justify-content: center;
    margin-top: 20px;
}

.na-action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 80px;
    text-align: center;
}

.na-action-item:hover {
    color: white;
}

.na-circle-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.na-circle-btn.na-cancel { background: white; color: #333; }
.na-circle-btn.na-record { background: rgba(255, 255, 255, 0.15); }
.na-circle-btn.na-retry { background: #10b981; }

.na-action-item:hover .na-circle-btn {
    transform: scale(1.1);
}

.rotate-icon {
    transform: rotate(135deg);
}


.video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}

.remote-video {
    width: 100%;
    height: 100%;
    object-fit: contain !important; /* Full view */
    background-color: #000 !important;
    transition: transform 0.3s ease;
}

.remote-video.zoomed-in {
    object-fit: cover !important; /* Zoom view */
    transform: scale(1.5); /* extra 1.5x zoom */
}



.call-actions {
    position: absolute;
    bottom: 45px;
    display: flex;
    gap: 25px;
    z-index: 300;
    padding: 15px 30px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.call-overlay.video-active .call-actions {
    bottom: 50px;
}


/* Premium Group Call Grid */
.video-container.group-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    grid-auto-rows: 1fr;
    gap: 20px;
    padding: 30px;
    padding-bottom: 140px;
    background: #0b0f19;
    align-content: center;
    justify-content: center;
}

.remote-video-item {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #161b22;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    border: 2px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 1-on-1 Full Screen Mode */
.video-container:not(.group-grid) {
    display: block !important;
}
.video-container:not(.group-grid) .remote-video-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    aspect-ratio: auto;
    z-index: 1;
    transform: none !important;
}


.remote-video-item.audio-only {
    background: transparent !important;
}

.remote-video-item.audio-only::before {
    content: '';
    position: absolute;
    width: 260px;
    height: 260px;
    border: 2px solid rgba(0, 132, 255, 0.45);
    background: transparent;
    border-radius: 50%;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s;
}

/* Pulsing effect for speaker */
.remote-video-item.audio-only.speaking::before {
    opacity: 1;
    animation: pulse-audio-speaking 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-audio-speaking {
    0% {
        transform: scale(0.65);
        opacity: 0.8;
        box-shadow: 0 0 0 0px rgba(0, 132, 255, 0.3);
    }
    100% {
        transform: scale(1.15);
        opacity: 0;
        box-shadow: 0 0 0 40px rgba(0, 132, 255, 0);
    }
}

.remote-video-item .audio-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    z-index: 2;
    border: 3px solid rgba(255, 255, 255, 0.2);
    display: none;
    transition: all 0.3s ease;
}

.remote-video-item.audio-only .audio-avatar {
    display: block;
    width: 170px;
    height: 170px;
    border: 4px solid var(--accent-light, rgba(0, 132, 255, 0.25));
    box-shadow: 0 0 35px rgba(0, 132, 255, 0.4);
}

.remote-video-item.audio-only video {
    display: none;
}


.remote-video-item.speaking {
    border-color: var(--accent-color);
    box-shadow: 0 0 25px rgba(var(--accent-rgb), 0.4);
    transform: scale(1.02);
}

.participant-label {
    position: absolute;
    bottom: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    padding: 6px 14px;
    border-radius: 10px;
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 15;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Hide small name tag in 1-on-1 full screen since main call-name is visible */
.video-container:not(.group-grid) .participant-label {
    display: none !important;
}

.mute-indicator {
    color: #ef4444;
    font-size: 0.8rem;
    display: none; /* Shown via JS */
}

.remote-video-item.muted .mute-indicator {
    display: block;
}

.eject-mini-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(239, 68, 68, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.6; /* Semi-visible for host always */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.remote-video-item:hover .eject-mini-btn {
    opacity: 1;
}

.eject-mini-btn:hover {
    background: #ef4444;
    transform: scale(1.1);
}



@media (max-width: 480px) {
    .video-container.group-grid {
        grid-template-columns: 1fr;
        /* Stack on small mobile */
    }
}

.local-video {
    display: none;
    position: absolute;

    bottom: 160px;
    /* Adjusted to stay above actions */
    right: 30px;
    width: 150px;
    height: 220px;
    background: transparent !important;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.4);
    z-index: 10;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    /* Click to swap */
}

/* Tap-to-swap hint ring on local (small) video */
.local-video::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 14px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    animation: swapHint 2.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes swapHint {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.9; transform: scale(1.03); }
}

.local-video.shuffled {
    width: 100% !important;
    height: 100% !important;
    bottom: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
    z-index: 5 !important;
    border: none !important;
}

.remote-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: #000 !important;
}

.remote-video.shuffled {
    position: absolute !important;
    bottom: 160px !important;
    right: 30px !important;
    width: 150px !important;
    height: 220px !important;
    z-index: 10 !important;
    border-radius: 12px !important;
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    object-fit: cover !important;
    background-color: #222 !important;
}

.call-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    color: white;
}

.call-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.3);
}

.call-btn.end {
    background: #ff3b30;
}

.call-btn.end:hover {
    background: #ff2d55;
    box-shadow: 0 0 20px rgba(255, 59, 48, 0.5);
}

.call-btn.active {
    background: white;
    color: #333;
}

/* Incoming Call Alert */
.incoming-call-alert {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 15px 25px;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 6000;
    display: flex;
    align-items: center;
    gap: 20px;
    border: 1px solid var(--border-color);
    animation: slideDown 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -100px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.incoming-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.incoming-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
}

.incoming-text h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.incoming-text p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.incoming-actions {
    display: flex;
    gap: 10px;
}

.inc-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
    color: white;
}

.inc-btn.accept {
    background: #4cd964;
}

.inc-btn.reject {
    background: #ff3b30;
}

.inc-btn:hover {
    transform: scale(1.1);
}

/* Chat Separators (Date & Unread) */
.chat-date-separator {
    display: flex;
    justify-content: center;
    margin: 10px 0;
    position: sticky;
    top: 5px;
    z-index: 100;
    pointer-events: none;
    transition: all 0.3s ease;
}

.chat-date-separator span,
.unread-separator span {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 1;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(8px);
    opacity: 0.98;
}



.system-msg {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 10px 0;
    pointer-events: none;
    clear: both;
}

.system-msg span {
    background: #e9edef;
    color: #667781;
    padding: 5px 14px;
    border-radius: 7px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    text-align: center;
    width: fit-content;
    max-width: 85%;
    display: inline-block;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    margin: 0 auto;
}

[data-theme="dark"] .system-msg span {
    background: #182229;
    color: #8696a0;
}

.unread-separator {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    position: relative;
    pointer-events: none;
}

.unread-separator span {
    background: #e3f2fd;
    color: #1976d2;
    border-color: #bbdefb;
    border-radius: 8px;
    /* Unread badge is usually less rounded */
}

[data-theme='dark'] .unread-separator span {
    background: #1a237e;
    color: #90caf9;
    border-color: #283593;
}

/* Day Grouping for Sticky Headers */
.day-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

/* Group Participant List */
.participant-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.participant-item:hover {
    background: var(--bg-secondary);
}

.participant-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.participant-info {
    display: flex;
    flex-direction: column;
}

.participant-name {
    font-weight: 600;
    color: var(--text-primary);
}

.participant-role {
    font-size: 0.75rem;
    color: var(--accent-color);
    background: rgba(var(--accent-rgb), 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    width: fit-content;
    margin-top: 2px;
}

.new-group-trigger {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
}

.new-group-trigger:hover {
    background: rgba(var(--accent-rgb), 0.05) !important;
}

.group-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

/* Mobile Submenu Dropdown Fix for Desktop */
.mobile-submenu {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: auto;
    background: var(--bg-secondary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 10px 0;
    z-index: 9999;
    border: 1px solid var(--border-color);
    margin: 10px;
}

/* On desktop, position it near the trigger if inside header */
@media (min-width: 769px) {
    .mobile-submenu {
        position: absolute;
        top: 60px;
        right: 15px;
        bottom: auto;
        left: auto;
        width: 250px;
    }
}

.submenu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.95rem;
}

.submenu-item:hover {
    background: rgba(var(--accent-rgb), 0.1);
}

.submenu-item.danger {
    color: var(--danger);
}

.submenu-item i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

/* ---- Permission Request Modal ---- */
.permission-icon-stack {
    display: flex;
    justify-content: center;
    margin-bottom: 25px;
}

.perm-icon {
    width: 65px;
    height: 65px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: white;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    border: 4px solid var(--bg-primary);
    position: relative;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.perm-icon:hover {
    transform: translateY(-5px) scale(1.1);
}

.perm-icon.camera { background: linear-gradient(135deg, #ff6b6b, #ee5253); z-index: 3; }
.perm-icon.mic { background: linear-gradient(135deg, #4834d4, #686de0); z-index: 2; margin-left: -20px; }
.perm-icon.files { background: linear-gradient(135deg, #f0932b, #ffbe76); z-index: 1; margin-left: -20px; }

.permission-list {
    text-align: left;
    margin-bottom: 30px;
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.perm-item {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 15px 0;
}

.perm-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.perm-item i {
    font-size: 1.4rem;
    color: var(--accent-color);
    width: 35px;
    text-align: center;
    background: rgba(var(--accent-rgb), 0.1);
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.perm-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.perm-text strong {
    font-size: 1rem;
    color: var(--text-primary);
}

.perm-text span {
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

.permission-modal {
    animation: modalSlideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Custom Prompt Modal */
#custom-prompt-overlay .modal-content {
    width: 400px;
    max-width: 90%;
    border-radius: 24px;
    padding: 32px !important;
    background: var(--bg-primary);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

#prompt-input {
    width: 100%;
    padding: 14px 18px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    margin-top: 15px;
    transition: border-color 0.2s;
}

#prompt-input:focus {
    border-color: var(--accent-color);
    outline: none;
}

#prompt-ok-btn {
    background: linear-gradient(135deg, var(--accent-color), #4fb99f);
    color: white;
    border: none;
}

/* ===== STT (Speech-to-Text) Press & Hold ===== */
.stt-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.stt-lang-btn {
    font-size: 0.62rem;
    font-weight: 800;
    padding: 0 8px;
    border-radius: 12px;
    border: 1px solid rgba(var(--accent-rgb), 0.3);
    background: rgba(var(--accent-rgb), 0.08);
    color: var(--accent-color);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 22px;
    height: 24px;
    letter-spacing: 0.3px;
    user-select: none;
    -webkit-user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    backdrop-filter: blur(4px);
}

.stt-lang-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.2);
}

.stt-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.stt-icon-btn:hover {
    color: var(--accent-color);
    background: rgba(var(--accent-rgb), 0.1);
}

.stt-icon-btn.stt-recording {
    background: rgba(231, 76, 60, 0.12);
    color: #e74c3c;
    animation: stt-pulse-ring 1s ease-in-out infinite;
}

@keyframes stt-pulse-ring {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.5); }
    50%       { box-shadow: 0 0 0 8px rgba(231, 76, 60, 0); }
}

.stt-status-indicator {
    position: absolute;
    top: -44px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(231, 76, 60, 0.4);
    animation: stt-badge-in 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
    pointer-events: none;
}

.stt-status-indicator.hidden {
    display: none;
}

.stt-status-indicator i {
    animation: stt-mic-blink 0.7s ease-in-out infinite;
}

@keyframes stt-mic-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

@keyframes stt-badge-in {
    from { opacity: 0; transform: translateX(-50%) translateY(6px) scale(0.9); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}


/* STT tooltip anchor */
.input-container {
    position: relative;
}


/* ===== STT Live Panel (Professional) ===== */
.stt-live-panel {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0; right: 0;
    background: linear-gradient(135deg, rgba(18,18,24,0.97), rgba(30,16,16,0.97));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(231,76,60,0.3);
    border-radius: 16px;
    padding: 12px 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 -4px 30px rgba(231,76,60,0.18), 0 8px 32px rgba(0,0,0,0.4);
    animation: stt-panel-in 0.25s cubic-bezier(0.34,1.56,0.64,1);
    z-index: 20;
}
.stt-live-panel.hidden { display: none; }

@keyframes stt-panel-in {
    from { opacity:0; transform:translateY(10px) scale(0.97); }
    to   { opacity:1; transform:translateY(0) scale(1); }
}

.stt-wave-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 24px;
}

.stt-wave-bar {
    display: inline-block;
    width: 3px;
    border-radius: 3px;
    background: #e74c3c;
    animation: stt-wave-anim 0.8s ease-in-out infinite;
    transform-origin: bottom center;
}
.stt-wave-bar:nth-child(1){ height:8px;  animation-delay:0s; }
.stt-wave-bar:nth-child(2){ height:14px; animation-delay:0.1s; }
.stt-wave-bar:nth-child(3){ height:20px; animation-delay:0.2s; }
.stt-wave-bar:nth-child(4){ height:14px; animation-delay:0.3s; }
.stt-wave-bar:nth-child(5){ height:8px;  animation-delay:0.4s; }

@keyframes stt-wave-anim {
    0%,100%{ transform:scaleY(0.5); opacity:0.6; }
    50%    { transform:scaleY(1.4); opacity:1;   }
}

.stt-panel-body {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stt-panel-lang-tag {
    font-size: 0.65rem;
    font-weight: 800;
    background: rgba(231,76,60,0.2);
    color: #e74c3c;
    border: 1px solid rgba(231,76,60,0.4);
    padding: 2px 7px;
    border-radius: 6px;
    letter-spacing: 0.8px;
    flex-shrink: 0;
}

.stt-panel-hint {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    font-weight: 400;
}

.stt-interim-preview {
    margin: 0;
    font-size: 0.88rem;
    color: rgba(255,255,255,0.85);
    min-height: 1.2em;
    font-style: italic;
    line-height: 1.4;
    max-height: 3em;
    overflow: hidden;
    word-break: break-word;
}

/* Smoother transition for STT button */
.stt-icon-btn {
    transition: background 0.3s ease, color 0.3s ease, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.stt-icon-btn:active {
    transform: scale(0.92);
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}



/* Location Picker Modal */
#location-picker-modal {
    background: var(--bg-primary);
}

.location-picker-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.location-picker-header {
    height: 60px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 20px;
    border-bottom: 1px solid var(--border-color);
}

.location-picker-header h3 {
    flex: 1;
    font-size: 1.2rem;
    font-weight: 500;
}

.location-picker-body {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-secondary);
}

.location-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    gap: 20px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.location-item:hover {
    background: var(--bg-primary);
}

.loc-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    position: relative;
}

.loc-icon.live { color: #25d366; background: rgba(37, 211, 102, 0.1); }
.loc-icon.current { color: #008069; border: 2px solid #008069; }
.loc-icon.place { color: var(--text-secondary); background: var(--bg-primary); }

.live-ping {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #25d366;
    opacity: 0.4;
    animation: ping 2s infinite;
}

@keyframes ping {
    0% { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(1.8); opacity: 0; }
}

.loc-details {
    display: flex;
    flex-direction: column;
}

.loc-name { font-weight: 500; font-size: 1rem; color: var(--text-primary); }
.loc-addr { font-size: 0.85rem; color: var(--text-secondary); }

.nearby-places-section {
    padding-top: 10px;
}

.section-title {
    padding: 10px 20px;
    font-size: 0.85rem;
    color: var(--accent-color);
    text-transform: uppercase;
    font-weight: 600;
}

/* Live Duration Modal */
.duration-content-card {
    background: var(--bg-secondary);
    width: 100%;
    max-width: 450px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.duration-header {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 20px;
    border-bottom: 1px solid var(--border-color);
}

.duration-map-preview {
    flex: 1;
    background: #e9edef;
}

.duration-selection-area {
    padding: 20px;
    background: var(--bg-secondary);
    box-shadow: 0 -4px 10px rgba(0,0,0,0.1);
}

.duration-chips {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.chip {
    flex: 1;
    padding: 8px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.chip.active {
    background: #25d366;
    color: white;
    border-color: #25d366;
}

.comment-input-wrap {
    display: flex;
    align-items: center;
    gap: 15px;
}

.comment-input-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--accent-color);
    padding: 10px 0;
    outline: none;
    color: var(--text-primary);
}

.send-live-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #25d366;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.4);
}

/* Enhanced Map Card in Message */
.msg-location-card {
    width: 250px;
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid rgba(0,0,0,0.05);
}

.msg-location-card .map-img {
    height: 150px;
    width: 100%;
    background-size: cover;
    background-position: center;
    position: relative;
}

.msg-location-card .place-info {
    padding: 10px;
}

.msg-location-card .place-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #4ea8d6;
    display: block;
    margin-bottom: 2px;
}

.msg-location-card .place-addr {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: block;
    line-height: 1.3;
}

/* Live Location Card */
.live-loc-card {
    width: 250px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary);
}

.live-loc-card .map-img {
    height: 200px;
}

.live-loc-card .live-info {
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

.live-loc-card .live-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

.live-loc-card .live-until {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-left: 28px;
}

.stop-sharing-btn {
    width: 100%;
    padding: 10px;
    background: none;
    border: none;
    border-top: 1px solid var(--border-color);
    color: #e53935;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}

.stop-sharing-btn:hover { background: rgba(229, 57, 53, 0.05); }

/* Location sharing is hidden on the web app */
[data-type="location"] {
    display: none !important;
}

.contact-list-alt {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 15px;
}

.contact-item-alt {
    display: flex;
    align-items: center;
    padding: 12px;
    gap: 12px;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.contact-item-alt:hover {
    background: rgba(255, 255, 255, 0.05);
}

.avatar-mini {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.name-mini {
    flex: 1;
    font-weight: 500;
}

.add-mini-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}


/* Pro-Level Add to Call Modal */
.modal-content.glass {
    background: rgba(15, 23, 42, 0.8) !important;
    backdrop-filter: blur(25px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    width: 400px;
    padding: 0;
    overflow: hidden;
    color: white;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-body {
    padding: 16px 24px 24px;
}

.search-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    color: white;
    margin-bottom: 20px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: #3b82f6;
}

.contact-list-alt {
    max-height: 350px;
    overflow-y: auto;
    padding-right: 4px;
}

.contact-item-alt {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 14px;
    transition: all 0.2s ease;
    cursor: pointer;
    margin-bottom: 4px;
}

.contact-item-alt:hover {
    background: rgba(255, 255, 255, 0.05);
}

.avatar-mini {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.1);
}

.name-mini {
    flex: 1;
    font-weight: 500;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
}

.add-mini-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: none;
    background: #10b981;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.add-mini-btn:hover {
    transform: scale(1.1);
    filter: brightness(1.1);
}

.contact-list-alt::-webkit-scrollbar {
    width: 5px;
}

.contact-list-alt::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}


/* Improved Modal Header and Close Button */
.modal-header h3 {
    color: #ffffff !important;
    font-size: 1.4rem;
    letter-spacing: -0.5px;
}

.modal-header .close-btn {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.7) !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    outline: none !important;
}

.modal-header .close-btn:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #ef4444 !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
    transform: rotate(90deg) !important;
}


.local-video.full-screen-local {
    bottom: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: none !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    z-index: 1 !important; /* Behind the gradient/info but above background */
    object-fit: cover !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.call-overlay.video-calling-phase {
    background: transparent !important;
}

.video-calling-phase .call-info {
    z-index: 5;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}


@media (max-width: 768px) {
    .call-actions {
        gap: 10px !important;
        padding: 10px 20px !important;
        bottom: 30px !important;
        width: 90%;
        max-width: 400px;
        justify-content: space-between;
    }
    .call-btn {
        width: 45px !important;
        height: 45px !important;
        font-size: 1.1rem !important;
    }
    .local-video {
        bottom: 110px !important;
        right: 15px !important;
        width: 90px !important;
        height: 140px !important;
    }
    .call-overlay.video-active .call-actions {
        bottom: 30px !important;
    }
}


/* Call View Swapping */
.call-overlay.swapped .video-container:not(.group-grid) .remote-video-item {
    top: auto !important;
    left: auto !important;
    bottom: 160px !important;
    right: 30px !important;
    width: 150px !important;
    height: 220px !important;
    border-radius: 12px !important;
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3) !important;
    z-index: 10 !important;
    cursor: pointer;
}

.call-overlay.swapped .local-video {
    bottom: 0px !important;
    right: 0px !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    z-index: 1 !important;
}

.local-video {
    cursor: pointer;
}

@media (max-width: 768px) {
    .call-overlay.swapped .video-container:not(.group-grid) .remote-video-item {
        bottom: 110px !important;
        right: 15px !important;
        width: 90px !important;
        height: 140px !important;
    }
}


/* ---- Premium Toast Notifications ---- */
#toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1000000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 12px 20px;
    border-radius: 14px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    min-width: 250px;
    max-width: 400px;
    pointer-events: auto;
    animation: toastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

[data-theme='dark'] .toast {
    background: rgba(30, 30, 30, 0.9);
    border-color: rgba(255, 255, 255, 0.05);
}

.toast.success { border-left: 4px solid #10b981; }
.toast.error { border-left: 4px solid #ef4444; }
.toast.info { border-left: 4px solid #3b82f6; }

.toast.success i { color: #10b981; }
.toast.error i { color: #ef4444; }
.toast.info i { color: #3b82f6; }

.toast.hide {
    animation: toastOut 0.4s ease forwards;
}

@keyframes toastIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(120%); opacity: 0; }
}

/* ---- Call Log Messaging Styles ---- */
.message.call-log {
    max-width: fit-content;
    border-radius: 12px;
}

.message.call-log .msg-content {
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
}

.call-log-body {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    margin-top: 4px;
}

.call-log-body i {
    font-size: 1rem;
    padding: 8px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
}

[data-theme='dark'] .call-log-body i {
    background: rgba(255, 255, 255, 0.1);
}

.message.call-log.missed .call-log-body {
    color: #ef4444;
}

.message.call-log.missed .call-log-body i,
.message.call-log.declined .call-log-body i {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #ef4444 !important;
}

.message.call-log.sent .call-log-body i {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.message.call-log .msg-time {
    margin-top: 4px;
    opacity: 0.7;
    font-size: 0.75rem;
}

/* Drive Workspace Folder & Editor Styles */
.breadcrumb-item:hover {
    text-decoration: underline;
}

.file-card.is-folder {
    cursor: pointer;
}

.file-card.is-folder:hover {
    background: rgba(0, 168, 132, 0.05) !important;
}

#fe-grid-editor th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-secondary);
}

#fe-grid-editor td:focus {
    background: rgba(0, 168, 132, 0.1);
    outline: 2px solid var(--accent-color);
    z-index: 5;
}


/* Luckysheet Typing Fixes */
.luckysheet-input-box-index {
    z-index: 5000 !important;
}
.luckysheet-wa-editor {
    z-index: 5001 !important;
}


/* Luckysheet Cell Editor Fixes */
#luckysheet-input-box, 
.luckysheet-input-box, 
#luckysheet-rich-text-editor,
.luckysheet-cell-input {
    z-index: 9999 !important;
    background-color: #fff !important;
    color: #000 !important;
}


.luckysheet-cols-menu, 
.luckysheet-rightgclick-menu,
.luckysheet-filter-menu,
.luckysheet-datavisual-selection-set,
.luckysheet-input-box-index,
#luckysheet-cell-selected {
    z-index: 9999 !important;
}


/* ================= PWA / notifications / settings additions ================= */
.settings-section {
    text-align: left;
    margin-top: 10px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}
.settings-section-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 600;
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
}
.settings-row[hidden] { display: none; }
.settings-row-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.settings-row-label { font-weight: 500; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.settings-row-label i { color: var(--accent-color); width: 16px; text-align: center; }
.settings-row-hint { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.35; }
.settings-row-actions { display: flex; gap: 8px; flex-shrink: 0; }

.pill-btn {
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s, opacity 0.2s;
}
.pill-btn[hidden] { display: none; }
.pill-btn:hover { border-color: var(--accent-color); }
.pill-btn:disabled { opacity: 0.6; cursor: wait; }
.pill-btn.primary { background: var(--accent-color); border-color: var(--accent-color); color: #fff; }
.pill-btn.primary:hover { background: var(--accent-hover); }
.pill-btn.danger { color: var(--danger); border-color: rgba(239, 68, 68, 0.35); }
.pill-btn.danger:hover { background: rgba(239, 68, 68, 0.08); border-color: var(--danger); }
.pill-btn:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }

.pwa-banner {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 100001;
    width: min(560px, calc(100% - 24px));
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.35);
    animation: pwaBannerIn 0.35s ease-out;
}
.pwa-banner[hidden] { display: none; }
.pwa-banner-icon {
    width: 42px; height: 42px; flex-shrink: 0;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 128, 105, 0.12);
    color: var(--accent-color);
    font-size: 1.1rem;
}
.pwa-banner-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; font-size: 0.88rem; }
.pwa-banner-text span { color: var(--text-secondary); line-height: 1.35; }
.pwa-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
@keyframes pwaBannerIn { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 560px) {
    .pwa-banner { flex-wrap: wrap; bottom: calc(76px + env(safe-area-inset-bottom)); }
    .pwa-banner-actions { width: 100%; justify-content: flex-end; }
    .settings-row { flex-wrap: wrap; }
}

.offline-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100003;
    background: #b45309;
    color: #fff;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
}
.offline-bar[hidden] { display: none; }
.offline-bar i { margin-right: 6px; }

/* Chat switch: loading skeleton shown until the new conversation arrives */
.chat-loading { display: flex; flex-direction: column; gap: 14px; padding: 24px 6%; }
.chat-loading-bubble {
    height: 38px; width: 46%; border-radius: 12px;
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--border-color) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: chatSkeleton 1.1s ease-in-out infinite;
    opacity: 0.8;
}
.chat-loading-bubble.out { align-self: flex-end; width: 38%; }
.chat-loading-bubble.short { width: 28%; }
@keyframes chatSkeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .chat-loading-bubble { animation: none; } }

/* Call waiting: second incoming call while already on a call */
.call-waiting-banner {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top));
    left: 50%;
    transform: translate(-50%, -140%);
    z-index: 200000;
    width: min(460px, calc(100% - 24px));
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 18px;
    background: rgba(17, 27, 33, 0.92);
    color: #fff;
    box-shadow: 0 18px 45px -12px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(12px);
    transition: transform 0.35s cubic-bezier(.2,.9,.3,1.2);
}
.call-waiting-banner.show { transform: translate(-50%, 0); }
.call-waiting-banner .cw-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: #2a3942; }
.call-waiting-banner .cw-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.call-waiting-banner .cw-text strong { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-waiting-banner .cw-text span { font-size: 0.78rem; opacity: 0.75; }
.call-waiting-banner .cw-actions { display: flex; gap: 8px; flex-shrink: 0; }
.call-waiting-banner .cw-btn {
    border: none; border-radius: 999px; padding: 8px 12px; cursor: pointer;
    display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.8rem; color: #fff;
}
.call-waiting-banner .cw-btn.decline { background: #ef4444; }
.call-waiting-banner .cw-btn.accept { background: #10b981; }
.call-waiting-banner .cw-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (max-width: 480px) {
    .call-waiting-banner .cw-btn span { display: none; }
    .call-waiting-banner .cw-btn { width: 40px; height: 40px; justify-content: center; padding: 0; }
}

/* Mic button when no microphone is connected */
.call-btn.unavailable { opacity: 0.55; }

/* Settings → permission overview */
.perm-panel { margin: 6px 0 10px; border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; }
.perm-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; background: var(--bg-primary); font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.perm-refresh { border: none; background: none; color: var(--text-secondary); cursor: pointer; width: 28px; height: 28px; border-radius: 8px; }
.perm-refresh:hover { color: var(--accent-color); background: rgba(0, 128, 105, 0.08); }
.perm-status-list { list-style: none; margin: 0; padding: 0; }
.perm-loading { padding: 12px; font-size: 0.85rem; color: var(--text-secondary); }
.perm-item-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--border-color); }
.perm-item-row:first-child { border-top: none; }
.perm-ic { width: 18px; text-align: center; color: var(--accent-color); flex-shrink: 0; }
.perm-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.perm-txt strong { font-size: 0.88rem; font-weight: 500; color: var(--text-primary); }
.perm-txt small { font-size: 0.74rem; color: var(--text-secondary); line-height: 1.3; }
.perm-pill { font-size: 0.72rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; flex-shrink: 0; }
.perm-pill.ok { background: rgba(16, 185, 129, 0.14); color: #059669; }
.perm-pill.bad { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.perm-pill.warn { background: rgba(245, 158, 11, 0.15); color: #b45309; }
.perm-pill.muted { background: var(--bg-primary); color: var(--text-secondary); }
[data-theme="dark"] .perm-pill.ok { color: #34d399; }
[data-theme="dark"] .perm-pill.bad { color: #f87171; }
[data-theme="dark"] .perm-pill.warn { color: #fbbf24; }
.perm-act { padding: 5px 11px; font-size: 0.76rem; flex-shrink: 0; }
@media (max-width: 480px) { .perm-item-row { flex-wrap: wrap; } .perm-act { margin-left: 28px; } }

/* ===== Voice typing v2 ===== */
.stt-interim-text { opacity: 0.5; font-style: italic; }
.stt-icon-btn.stt-unsupported { opacity: 0.45; }
.stt-icon-btn:focus-visible, .stt-lang-btn:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }

/* Wave only moves while speech is detected */
.stt-live-panel .stt-wave-bar { animation-play-state: paused; opacity: 0.45; }
.stt-live-panel.speaking .stt-wave-bar { animation-play-state: running; opacity: 1; }
.stt-live-panel.listening:not(.speaking) .stt-wave-bar { animation-play-state: running; animation-duration: 2.4s; opacity: 0.7; }

.stt-lang-menu {
    position: fixed;
    z-index: 100005;
    width: 250px;
    max-height: 340px;
    overflow-y: auto;
    padding: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.35);
    animation: stt-panel-in 0.2s ease-out;
}
.stt-lang-menu.hidden { display: none; }
.stt-lang-menu-title { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); padding: 6px 8px 8px; }
.stt-lang-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: none;
    background: none;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    color: var(--text-primary);
}
.stt-lang-item:hover, .stt-lang-item:focus-visible { background: var(--bg-primary); outline: none; }
.stt-lang-code {
    width: 48px;
    flex-shrink: 0;
    white-space: nowrap;
    letter-spacing: -0.02em;
    font-size: 0.68rem;
    font-weight: 800;
    text-align: center;
    padding: 3px 4px;
    border-radius: 6px;
    background: rgba(0, 128, 105, 0.1);
    color: var(--accent-color);
}
.stt-lang-names { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.stt-lang-names strong { font-size: 0.86rem; font-weight: 500; }
.stt-lang-names small { font-size: 0.74rem; color: var(--text-secondary); }
.stt-lang-item .fa-check { color: var(--accent-color); visibility: hidden; }
.stt-lang-item.active .fa-check { visibility: visible; }
.stt-lang-item.active { background: rgba(0, 128, 105, 0.08); }
@media (max-width: 480px) { .stt-lang-menu { width: min(260px, calc(100vw - 32px)); } }

/* Voice typing — AI states */
.stt-ai-badge { margin-left: 6px; font-size: 0.66rem; padding: 2px 7px; border-radius: 999px; background: linear-gradient(135deg, #7c3aed, #0ea5e9); color: #fff; letter-spacing: 0.02em; text-transform: none; }
.stt-icon-btn.stt-ai::after { content: '✨'; position: absolute; font-size: 0.55rem; transform: translate(9px, -9px); pointer-events: none; }
.stt-icon-btn.stt-ai { position: relative; }
.stt-live-panel.working { border-color: rgba(124, 58, 237, 0.45); box-shadow: 0 -4px 30px rgba(124, 58, 237, 0.2), 0 8px 32px rgba(0, 0, 0, 0.4); }
.stt-live-panel.working .stt-wave-bar { background: linear-gradient(180deg, #a78bfa, #38bdf8); animation: stt-wave-anim 0.9s ease-in-out infinite !important; opacity: 1; transform: none !important; }
.stt-live-panel.working .stt-panel-hint { color: #c4b5fd; font-weight: 600; }
.stt-live-panel.listening .stt-wave-bar[style*="scaleY"] { animation: none; transition: transform 0.08s linear; }

/* =====================================================================
   In-chat UI v2 — grouped bubbles, inline time, call cards, quick actions
   ===================================================================== */
.day-group { gap: 0; }
.day-group > .chat-date-separator { margin: 14px 0 8px; }
.day-group > .system-msg, .day-group > .unread-separator { margin: 10px 0; }

.message { position: relative; max-width: min(65%, 620px); }
.message.grp-first, .message.grp-single, .message.call-log { margin-top: 10px; }
.message.grp-mid, .message.grp-last { margin-top: 2px; }
.day-group > .message:first-of-type { margin-top: 4px; }

/* Bubbles: soft radius, tail only on the first bubble of a group */
.message .msg-content {
    border-radius: 12px;
    padding: 7px 10px 7px 11px;
    gap: 4px;
    min-width: 0;
    box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}
.message.sent.grp-first .msg-content, .message.sent.grp-single .msg-content { border-top-right-radius: 0; }
.message.received.grp-first .msg-content, .message.received.grp-single .msg-content { border-top-left-radius: 0; }
.message.sent.grp-mid .msg-content, .message.sent.grp-last .msg-content,
.message.received.grp-mid .msg-content, .message.received.grp-last .msg-content { border-radius: 12px; }
.message.grp-first .msg-content::before, .message.grp-single .msg-content::before {
    content: '';
    position: absolute;
    top: 0;
    width: 8px;
    height: 13px;
}
.message.sent.grp-first .msg-content::before, .message.sent.grp-single .msg-content::before {
    right: -8px;
    background: var(--message-sent);
    clip-path: polygon(0 0, 100% 0, 0 100%);
}
.message.received.grp-first .msg-content::before, .message.received.grp-single .msg-content::before {
    left: -8px;
    background: var(--message-received);
    clip-path: polygon(0 0, 100% 0, 100% 100%);
}

/* Text: time + ticks on the last line, like a phone chat */
.message.is-text .msg-content p.main-msg-text { line-height: 1.45; font-size: 0.94rem; }
.msg-meta-spacer {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    visibility: hidden;
    font-size: 0.68rem;
    margin-left: 10px;
    height: 0.7em;
    overflow: hidden;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
}
.msg-meta-spacer .tick-svg { width: 15px; height: 15px; }
.msg-meta-spacer .double-tick { margin-right: 0; }
.message.is-text .msg-content > .msg-time {
    position: absolute;
    right: 9px;
    bottom: 5px;
    margin: 0;
}
.message .msg-time { font-size: 0.68rem; gap: 3px; opacity: 0.9; }
.message .msg-time .double-tick { margin-right: 0; }
.message .msg-time .tick-svg { width: 15px; height: 15px; }

/* Group sender name (first bubble only) */
.message .group-sender-name { font-size: 0.8rem !important; margin-bottom: 1px !important; }

/* Emoji-only messages: big, no bubble */
.message.emoji-only .msg-content { background: transparent !important; box-shadow: none; padding: 0 2px; }
.message.emoji-only .msg-content::before { display: none; }
.message.emoji-only .inline-emoji.jumbo { width: 56px; height: 56px; margin: 2px; }
.message.emoji-only .msg-time {
    align-self: flex-end;
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    margin-top: 2px;
}

/* Options chevron: fades in with a soft backdrop so it never covers text */
.message .message-options-btn {
    top: 3px;
    right: 3px;
    width: 26px;
    height: 22px;
    border-radius: 0 10px 0 12px;
    background: linear-gradient(to left, var(--message-received) 60%, transparent);
    z-index: 2;
}
.message.sent .message-options-btn { background: linear-gradient(to left, var(--message-sent) 60%, transparent); }

/* Quick actions beside the bubble on hover (react / reply) */
.msg-quick-actions {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
/* No gap between bubble and buttons (padding instead of offset), so the pointer never "leaves" on the way */
.message.sent .msg-quick-actions { right: 100%; padding-right: 8px; flex-direction: row-reverse; }
.message.received .msg-quick-actions { left: 100%; padding-left: 8px; }
.message:hover .msg-quick-actions, .message:has(:focus-visible) .msg-quick-actions { opacity: 1; pointer-events: auto; }
@media (hover: hover) {
    /* Hovering the empty space beside a bubble counts too (like WhatsApp Web) */
    .message::before {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        width: 124px;
    }
    .message.sent::before { right: 100%; }
    .message.received::before { left: 100%; }
    /* Short grace period so a quick mouse move toward the buttons doesn't hide them */
    .msg-quick-actions { visibility: hidden; transition: opacity 0.15s ease 0.25s, visibility 0s linear 0.4s; }
    .message:hover .msg-quick-actions, .message:has(:focus-visible) .msg-quick-actions { visibility: visible; transition-delay: 0s, 0s; }
}
.selection-mode .message::before { display: none; }
.msg-quick-actions button {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--icon-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}
.msg-quick-actions button:hover { color: var(--accent-color); }
.msg-quick-actions button:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 1px; }
@media (hover: none) { .msg-quick-actions { display: none; } }

/* New messages slide in (only ones that just arrived) */
.message.msg-new { animation: msgIn 0.22s ease-out; }
.message.sent.msg-new { transform-origin: bottom right; }
.message.received.msg-new { transform-origin: bottom left; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .message.msg-new { animation: none; } }

/* Call history cards */
.message.call-card { max-width: min(80%, 330px); }
.message.call-card .msg-content {
    background: var(--message-received);
    border: none;
    border-radius: 12px;
    padding: 8px 10px 6px;
    min-width: 230px;
    gap: 2px;
}
.message.call-card.sent .msg-content { background: var(--message-sent); border-top-right-radius: 0; }
.message.call-card.received .msg-content { border-top-left-radius: 0; }
.call-card-row { display: flex; align-items: center; gap: 12px; }
.call-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(0, 128, 105, 0.12);
    color: var(--accent-color);
    font-size: 0.95rem;
}
.message.call-card.tone-bad .call-card-icon { background: rgba(239, 68, 68, 0.12); color: #e53935; }
.message.call-card.tone-muted .call-card-icon { background: rgba(102, 119, 129, 0.14); color: var(--text-secondary); }
.message.call-card i { padding: 0; background: none; font-size: inherit; color: inherit; border-radius: 0; }
.call-card-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.call-card-text strong { font-size: 0.92rem; font-weight: 600; color: var(--text-primary); }
.message.call-card.tone-bad .call-card-text strong { color: #e53935; }
.call-card-text small { display: flex; align-items: center; gap: 5px; font-size: 0.78rem; color: var(--text-secondary); }
.call-dir { font-size: 0.7rem !important; }
.call-dir.out { transform: rotate(45deg); color: var(--accent-color) !important; }
.call-dir.in { transform: rotate(-135deg); color: var(--accent-color) !important; }
.message.call-card.tone-bad .call-dir { color: #e53935 !important; }
.call-back-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--accent-color);
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
}
.call-back-btn:hover { background: var(--accent-color); color: #fff; }
.call-back-btn:active { transform: scale(0.94); }
.call-back-btn:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.message.call-card .msg-time { align-self: flex-end; margin: 0; }
[data-theme="dark"] .message.call-card.tone-bad .call-card-text strong,
[data-theme="dark"] .message.call-card.tone-bad .call-card-icon { color: #f87171; }

/* System notices & date chips */
.system-msg span { border-radius: 8px; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06); }
[data-theme="dark"] .system-msg span { background: #1f2c33; color: #8696a0; }

/* Formatting bar only when "Aa" is on */
.input-container:not(.show-format) .chat-toolbar { display: none; }
.input-container:not(.show-format) #message-input { border-top-left-radius: 12px; border-top-right-radius: 12px; }
.format-toggle-btn { font-weight: 700; font-size: 0.9rem; font-family: Georgia, 'Times New Roman', serif; letter-spacing: -0.5px; }
.format-toggle-btn.active { color: var(--accent-color); background: rgba(0, 128, 105, 0.1); }

/* Small screens: wider bubbles */
@media (max-width: 768px) {
    .message { max-width: 85%; }
    .message.call-card .msg-content { min-width: 0; }
}

/* Reactions hang just below the bubble, never over the time */
.message.has-reactions { margin-bottom: 16px; }
.message.has-reactions .msg-reactions { bottom: -18px; padding: 1px 7px; cursor: pointer; }
.message.sent.has-reactions .msg-reactions { right: 10px; left: auto; }
.message.received.has-reactions .msg-reactions { left: 10px; right: auto; }
.message.has-reactions .msg-reactions .reaction-emoji { width: 16px; height: 16px; }

/* Mouse devices: options live beside the bubble; the in-bubble arrow stays for touch screens */
@media (hover: hover) and (pointer: fine) {
    .message .msg-content > .message-options-btn { display: none; }
}

/* ===== Main (⋮) menu ===== */
#mobile-submenu.app-menu {
    position: fixed;
    margin: 0 !important;
    z-index: 100004;
    width: min(290px, calc(100vw - 16px));
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 18px 45px -12px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.08);
    animation: appMenuIn 0.16s ease-out;
    transform-origin: top right;
}
#mobile-submenu.app-menu.hidden { display: none !important; }
@keyframes appMenuIn { from { opacity: 0; transform: scale(0.96) translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #mobile-submenu.app-menu { animation: none; } }

#mobile-submenu .app-menu-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 12px;
    background: none;
    cursor: pointer;
    text-align: left;
    color: var(--text-primary);
}
#mobile-submenu .app-menu-profile img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
#mobile-submenu .app-menu-profile-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
#mobile-submenu .app-menu-profile-text strong { font-size: 0.98rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mobile-submenu .app-menu-profile-text small { font-size: 0.78rem; color: var(--text-secondary); }
#mobile-submenu .app-menu-profile > .fa-chevron-right { color: var(--text-secondary); font-size: 0.75rem; }

#mobile-submenu .app-menu-divider { height: 1px; background: var(--border-color); margin: 4px 6px; flex-shrink: 0; }

#mobile-submenu .submenu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 46px;
    padding: 0 12px;
    border: none;
    border-radius: 10px;
    background: none;
    color: var(--text-primary);
    font-size: 0.93rem;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
#mobile-submenu .submenu-item[hidden] { display: none; }
#mobile-submenu .submenu-item i { width: 20px; text-align: center; color: var(--icon-color); font-size: 1rem; }
#mobile-submenu .submenu-item span { flex: 1; }
#mobile-submenu .submenu-item.danger, #mobile-submenu .submenu-item.danger i { color: var(--danger); }
#mobile-submenu .submenu-item:hover, #mobile-submenu .app-menu-profile:hover,
#mobile-submenu .submenu-item:focus-visible, #mobile-submenu .app-menu-profile:focus-visible {
    background: var(--bg-primary);
    outline: none;
}
#mobile-submenu .submenu-item:active, #mobile-submenu .app-menu-profile:active { background: var(--border-color); }

#mobile-submenu .app-menu-badge {
    font-style: normal;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg-primary);
    color: var(--text-secondary);
}
#mobile-submenu .app-menu-badge:empty { display: none; }
#mobile-submenu .app-menu-badge.on { background: rgba(16, 185, 129, 0.14); color: #059669; }
#mobile-submenu .app-menu-badge.blocked { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
[data-theme="dark"] #mobile-submenu .app-menu-badge.on { color: #34d399; }
[data-theme="dark"] #mobile-submenu .app-menu-badge.blocked { color: #f87171; }

/* Phone header: comfortable 44px tap target for ⋮ */
@media (max-width: 768px) {
    #mobile-menu-trigger { width: 44px; height: 44px; font-size: 1.15rem; border-radius: 50%; }
    #mobile-menu-trigger[aria-expanded="true"] { background: var(--bg-primary); color: var(--accent-color); }
}

/* ===== Composer: desktop keeps its layout (wrapper is invisible) ===== */
.composer-pill { display: contents; }

/* ===== Phones: one rounded typing bar + round send / voice button ===== */
@media (max-width: 768px) {
    /* Inside an open chat the bottom tab bar steps aside to give the chat & keyboard room */
    .app-container:has(.chat-area.active #chat-active-header:not(.hidden)) .side-nav { display: none !important; }
    .chat-area.active:has(#chat-active-header:not(.hidden)) { padding-bottom: 0 !important; }

    .chat-footer {
        min-height: 0;
        gap: 6px;
        padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
        align-items: flex-end;
        background: transparent;
        border-top: none;
    }
    .chat-footer .composer-pill {
        display: flex;
        align-items: flex-end;
        flex: 1;
        min-width: 0;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 24px;
        padding: 0 4px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
        transition: border-color 0.15s, box-shadow 0.15s;
    }
    .chat-footer .composer-pill:focus-within { border-color: var(--accent-color); box-shadow: 0 0 0 3px rgba(0, 128, 105, 0.12); }

    .composer-pill #emoji-picker-btn { order: 0; }
    .composer-pill .input-container { order: 1; }
    .composer-pill #format-toggle-btn { order: 2; }
    .composer-pill .attachment-wrapper { order: 3; }

    .chat-footer .composer-pill .icon-btn,
    .chat-footer .composer-pill .attach-btn {
        width: 40px;
        height: 46px;
        margin: 0;
        border-radius: 50%;
        font-size: 1.2rem;
        flex-shrink: 0;
        color: var(--icon-color);
        background: transparent;
    }

    /* The text box itself: borderless inside the bar, grows up to ~5 lines */
    .composer-pill .input-container {
        flex: 1;
        min-width: 0;
        background: transparent;
        border: none;
        border-radius: 0;
        box-shadow: none !important;
    }
    .composer-pill .input-container:focus-within { border: none; box-shadow: none; }
    .composer-pill #message-input {
        font-size: 16px;                  /* 16px stops iPhone/Android zooming on focus */
        line-height: 1.4;
        min-height: 46px;
        max-height: 132px;
        padding: 12px 36px 12px 4px !important;
        border-radius: 0 !important;
    }
    .composer-pill #message-input:empty:before { font-size: 16px; }

    /* Voice typing: just the mic inside the bar (language via panel chip or ⋮ menu) */
    .composer-pill .stt-wrapper { right: 0; bottom: 5px; gap: 0; }
    .composer-pill .stt-lang-btn { display: none; }
    .composer-pill .stt-icon-btn { width: 36px; height: 36px; font-size: 1.05rem; }
    .composer-pill .stt-icon-btn.stt-ai::after { transform: translate(8px, -8px); }
    .stt-live-panel .stt-panel-lang-tag { cursor: pointer; padding: 4px 9px; font-size: 0.72rem; }
    .stt-live-panel .stt-panel-lang-tag::after { content: ' ▾'; }

    /* Empty: 😊 · text · 📎 · 🎙   —   typing: 😊 · text · Aa · 🎙 */
    .chat-footer:not(.has-text) .composer-pill #format-toggle-btn:not(.active) { display: none; }
    .chat-footer.has-text .composer-pill .attachment-wrapper { display: none; }

    /* Formatting bar floats above the typing bar */
    .composer-pill .input-container.show-format .chat-toolbar {
        position: absolute;
        left: -44px;
        right: -84px;
        bottom: calc(100% + 10px);
        border: 1px solid var(--border-color);
        border-radius: 14px;
        box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.25);
        overflow-x: auto;
        z-index: 25;
    }

    /* Round green send / voice-note button */
    .chat-footer > #voice-record-btn,
    .chat-footer > #send-msg-btn {
        width: 48px;
        height: 48px;
        margin: 0;
        flex-shrink: 0;
        border-radius: 50%;
        background: var(--accent-color);
        color: #fff;
        font-size: 1.15rem;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    }
    .chat-footer > #voice-record-btn.hidden,
    .chat-footer > #send-msg-btn.hidden { display: none; }
    .chat-footer > #voice-record-btn:active,
    .chat-footer > #send-msg-btn:active { transform: scale(0.94); }
    .chat-footer > #voice-record-btn.recording { background: var(--danger); }

    /* Menus that open from the bar sit just above it */
    .attachment-menu {   /* just above the typing bar, 12px from both edges */
        bottom: calc(68px + env(safe-area-inset-bottom)) !important;
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
    }
    .reply-preview { border-radius: 14px 14px 0 0; }
    .scroll-bottom-btn { bottom: 90px !important; }
}

/* ===== Voice note recording bar ===== */
.chat-footer.is-recording .input-container,
.chat-footer.is-previewing .input-container { min-height: 46px; }
#voice-recording-ui.voice-recording-ui {
    inset: 0;
    width: auto;
    height: auto;
    padding: 0 6px;
    gap: 6px;
    border-radius: inherit;
    background: var(--bg-secondary);
    justify-content: flex-start;
}
#voice-recording-ui .recording-status {
    flex: 1;
    min-width: 0;
    gap: 10px;
    color: var(--text-primary);
}
.rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    flex-shrink: 0;
    animation: recDot 1s ease-in-out infinite;
}
.rec-dot.paused { animation: none; background: var(--text-secondary); }
@keyframes recDot { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
#voice-recording-ui #recording-timer {
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
    font-weight: 600;
    min-width: 38px;
    color: var(--text-primary);
}
.rec-wave { flex: 1; min-width: 40px; height: 26px; display: block; }
.rec-preview { flex: 1; min-width: 0; height: 36px; outline: none; }
#voice-recording-ui .recording-actions { gap: 2px; margin-left: auto; }
#voice-recording-ui .rec-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-color);
    font-size: 1rem;
}
#voice-recording-ui .rec-btn:hover { background: var(--bg-primary); }
#voice-recording-ui #cancel-record { color: var(--danger); }
#voice-recording-ui #stop-record { color: #ef4444; }
#voice-recording-ui #send-record { color: var(--accent-color); font-size: 1.1rem; }
#voice-recording-ui .rec-btn.hidden { display: none; }
#voice-record-btn.voice-send { color: var(--accent-color); }

@media (max-width: 768px) {
    .chat-footer.is-recording .composer-pill,
    .chat-footer.is-previewing .composer-pill { border-color: rgba(239, 68, 68, 0.45); }
    #voice-recording-ui.voice-recording-ui { padding: 0 2px; gap: 2px; background: transparent; border-radius: 24px; }
    #voice-recording-ui .rec-btn { width: 40px; height: 44px; font-size: 1.05rem; }
    /* The round button sends while recording */
    .chat-footer > #voice-record-btn.voice-send { background: var(--accent-color); color: #fff; }
    /* Nothing in the bar is needed while listening back except the player */
    .chat-footer.is-previewing #voice-recording-ui #send-record { display: none; }
}

/* ===== Desktop composer: floating rounded bar + round send / voice button ===== */
@media (min-width: 769px) {
    .chat-footer {
        min-height: 0;
        gap: 10px;
        padding: 8px 20px 14px;
        align-items: flex-end;
        background: transparent;
        border-top: none;
    }
    .chat-footer .composer-pill {
        display: flex;
        align-items: flex-end;
        flex: 1;
        min-width: 0;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 26px;
        padding: 0 6px;
        box-shadow: 0 2px 10px -4px rgba(11, 20, 26, 0.18);
        transition: border-color 0.15s, box-shadow 0.15s;
    }
    .chat-footer .composer-pill:focus-within { border-color: var(--accent-color); box-shadow: 0 0 0 3px rgba(0, 128, 105, 0.12), 0 2px 10px -4px rgba(11, 20, 26, 0.18); }
    .chat-footer .composer-pill > .icon-btn,
    .chat-footer .composer-pill .attach-btn {
        width: 40px;
        height: 48px;
        margin: 0;
        border-radius: 50%;
        font-size: 1.15rem;
        color: var(--icon-color);
        background: transparent;
        flex-shrink: 0;
    }
    .chat-footer .composer-pill > .icon-btn:hover,
    .chat-footer .composer-pill .attach-btn:hover { color: var(--accent-color); }
    .composer-pill #format-toggle-btn { font-size: 1rem; }
    .composer-pill .input-container {
        flex: 1;
        min-width: 0;
        background: transparent;
        border: none;
        box-shadow: none !important;
        margin-left: 4px;
    }
    .composer-pill .input-container:focus-within { border: none; box-shadow: none; }
    .composer-pill #message-input {
        font-size: 0.97rem;
        line-height: 1.45;
        min-height: 48px;
        max-height: 180px;
        padding: 13px 104px 13px 4px !important;
        border-radius: 0 !important;
    }
    .composer-pill .stt-wrapper { bottom: 7px; right: 4px; }

    /* Formatting bar floats above the typing bar */
    .composer-pill .input-container.show-format .chat-toolbar {
        position: absolute;
        left: -130px;
        bottom: calc(100% + 12px);
        border: 1px solid var(--border-color);
        border-radius: 14px;
        box-shadow: 0 10px 28px -10px rgba(0, 0, 0, 0.25);
        z-index: 25;
    }

    .chat-footer > #voice-record-btn,
    .chat-footer > #send-msg-btn {
        width: 50px;
        height: 50px;
        margin: 0;
        flex-shrink: 0;
        border-radius: 50%;
        background: var(--accent-color);
        color: #fff;
        font-size: 1.15rem;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 3px 10px -3px rgba(0, 128, 105, 0.6);
        transition: transform 0.12s ease, background 0.15s;
    }
    .chat-footer > #voice-record-btn:hover,
    .chat-footer > #send-msg-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
    .chat-footer > #voice-record-btn:active,
    .chat-footer > #send-msg-btn:active { transform: scale(0.95); }
    .chat-footer > #voice-record-btn.hidden,
    .chat-footer > #send-msg-btn.hidden { display: none; }
    .chat-footer > #voice-record-btn.voice-send { color: #fff; }
    .chat-footer.is-recording .composer-pill,
    .chat-footer.is-previewing .composer-pill { border-color: rgba(239, 68, 68, 0.45); }
    #voice-recording-ui.voice-recording-ui { background: transparent; border-radius: 26px; }

    .attachment-menu { bottom: 78px !important; left: 30px !important; }
    .reply-preview { left: 20px; right: 80px; border-radius: 14px 14px 0 0; border: 1px solid var(--border-color); border-bottom: none; }
}

/* Group chat list: sender name before the last message */
.chat-last-message .last-sender { color: var(--text-primary); font-weight: 500; }

/* ===== WhatsApp-style notification controls ===== */
.chat-muted-icon { color: var(--text-secondary); font-size: 0.8rem; margin-left: 6px; flex-shrink: 0; opacity: .85; }
.chat-last-message .chat-muted-icon + .unread-badge { margin-left: 6px; }
.unread-badge.muted { background-color: #8696a0; }

#mute-chat-item .info-item-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#mute-chat-item .info-item-text small { font-size: 0.78rem; color: var(--text-secondary); }
#mute-chat-item.is-muted > i:first-child,
#mute-chat-item.is-muted .info-item-text small { color: var(--accent-color); }

.notif-prefs { display: flex; flex-direction: column; border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); margin: 6px 0; }
.notif-pref { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; cursor: pointer; position: relative; }
.notif-pref + .notif-pref { border-top: 1px dashed var(--border-color); }
.notif-pref-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.notif-pref-label { font-weight: 500; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.notif-pref-label i { color: var(--accent-color); width: 16px; text-align: center; }
.notif-pref-hint { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.35; }
.notif-pref input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.notif-switch { flex-shrink: 0; width: 40px; height: 22px; border-radius: 22px; background: #c4ccd1; position: relative; transition: background .2s; }
.notif-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.notif-pref input:checked + .notif-switch { background: var(--accent-color); }
.notif-pref input:checked + .notif-switch::after { transform: translateX(18px); }
.notif-pref input:focus-visible + .notif-switch { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.notif-pref input:disabled + .notif-switch { opacity: .6; }

.mute-dialog-backdrop { position: fixed; inset: 0; z-index: 4000; background: rgba(11, 20, 26, .55); display: flex; align-items: center; justify-content: center; padding: 16px; animation: muteFade .15s ease-out; }
.mute-dialog { background: var(--bg-secondary); color: var(--text-primary); width: 100%; max-width: 380px; border-radius: 16px; padding: 22px 22px 14px; box-shadow: 0 18px 50px rgba(0,0,0,.3); animation: muteRise .18s ease-out; }
.mute-dialog h3 { margin: 0 0 8px; font-size: 1.1rem; font-weight: 600; }
.mute-dialog-text { margin: 0 0 14px; font-size: 0.87rem; color: var(--text-secondary); line-height: 1.45; }
.mute-options { display: flex; flex-direction: column; }
.mute-options label { display: flex; align-items: center; gap: 14px; padding: 11px 4px; cursor: pointer; border-radius: 8px; font-size: 0.95rem; }
.mute-options label:hover { background: var(--bg-primary); }
.mute-options input { accent-color: var(--accent-color); width: 18px; height: 18px; margin: 0; }
.mute-dialog-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; }
.mute-btn { border: none; background: transparent; color: var(--accent-color); font-weight: 600; font-size: 0.9rem; padding: 9px 14px; border-radius: 20px; cursor: pointer; }
.mute-btn:hover { background: var(--bg-primary); }
.mute-btn.primary { background: var(--accent-color); color: #fff; }
.mute-btn.primary:hover { filter: brightness(1.06); background: var(--accent-color); }
.mute-btn.danger { color: #ea4335; margin-right: auto; }
@keyframes muteFade { from { opacity: 0; } }
@keyframes muteRise { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@media (max-width: 768px) {
    .mute-dialog-backdrop { align-items: flex-end; padding: 0; }
    .mute-dialog { max-width: none; border-radius: 18px 18px 0 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}
