/* ============================================
   WhatsApp Inbox - Modern Responsive Design
   Mobile-First | Dark Mode | 60fps Animations
   ============================================ */

/* ===== CSS Variables ===== */
:root {
    /* Dark Theme (Default) */
    --bg-primary: #0b141a;
    --bg-secondary: #111b21;
    --bg-tertiary: #1f2c34;
    --bg-input: #2a3942;
    --bg-hover: #202c33;
    --bg-active: #2a3942;
    --bg-message-out: #005c4b;
    --bg-message-in: #202c33;

    /* Accent Colors */
    --accent: #00a884;
    --accent-hover: #00c49a;
    --accent-dark: #008069;
    --accent-light: rgba(0, 168, 132, 0.15);

    /* Text Colors */
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --text-muted: #667781;
    --text-accent: #00a884;

    /* Borders & Shadows */
    --border: #222d34;
    --border-light: #2a3942;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.25);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.35);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.4);

    /* Status Colors */
    --online: #25d366;
    --unread: #00a884;
    --danger: #ef4444;
    --warning: #f97316;
    --info: #53bdeb;

    /* Dimensions */
    --header-height: 60px;
    --input-height: 52px;
    --sidebar-width: 400px;
    --sidebar-min: 320px;
    --mobile-nav-height: 64px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);

    /* Animation */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f0f2f5;
    --bg-tertiary: #e4e6eb;
    --bg-input: #f0f2f5;
    --bg-hover: #f5f6f6;
    --bg-active: #e9edef;
    --bg-message-out: #d9fdd3;
    --bg-message-in: #ffffff;
    --text-primary: #111b21;
    --text-secondary: #54656f;
    --text-muted: #8696a0;
    --border: #e9edef;
    --border-light: #f0f2f5;
}

/* ===== Base Reset ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
}

a {
    color: var(--accent);
    text-decoration: none;
}

/* ===== App Layout ===== */
.app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: relative;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 100%;
    max-width: var(--sidebar-width);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
    transition: transform var(--transition-normal);
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        inset: 0;
        max-width: 100%;
        z-index: 100;
    }

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

/* Sidebar Header */
.sidebar-header {
    padding: 12px 16px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.sidebar-header .header-actions {
    display: flex;
    gap: 2px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 4px;
}

.sidebar-header .header-actions .icon-btn {
    width: 34px;
    height: 34px;
    font-size: 15px;
    border-radius: var(--radius-md);
}

.sidebar-header .header-actions .icon-btn:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-weight: 600;
    font-size: 15px;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    transition: all var(--transition-fast);
}

.status-indicator.online {
    background: var(--online);
    box-shadow: 0 0 8px var(--online);
}

#status-text {
    font-size: 12px;
    color: var(--text-muted);
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 4px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition-fast);
    position: relative;
}

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

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

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

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border-radius: var(--radius-lg);
    padding: 0 14px;
    height: 42px;
    gap: 12px;
    transition: all var(--transition-fast);
}

.search-box:focus-within {
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.search-icon {
    color: var(--text-muted);
    font-size: 16px;
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    min-width: 0;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* Chat Filters */
.chat-filters {
    display: flex;
    gap: 8px;
    padding: 8px 12px 12px;
    background: var(--bg-secondary);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

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

.filter-btn {
    flex-shrink: 0;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

.filter-btn:active {
    transform: scale(0.97);
}

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

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 14px;
    cursor: pointer;
    transition: background var(--transition-fast);
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.chat-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 80px;
    right: 16px;
    height: 1px;
    background: var(--border);
}

.chat-item:last-child::after {
    display: none;
}

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

.chat-item:active {
    background: var(--bg-active);
}

.chat-item.active {
    background: var(--bg-active);
}

/* Chat Avatar */
.chat-avatar {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.chat-avatar.group {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.chat-avatar.channel {
    background: linear-gradient(135deg, #53bdeb, #25d366);
}

.chat-avatar.business {
    background: linear-gradient(135deg, #7c3aed, #a855f7);
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-type-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    padding: 2px;
}

/* Chat Content */
.chat-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.chat-name {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.chat-time {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.chat-time.unread {
    color: var(--accent);
    font-weight: 600;
}

.chat-preview-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.chat-preview {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.chat-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.unread-badge {
    min-width: 20px;
    height: 20px;
    background: var(--accent);
    color: var(--bg-primary);
    font-size: 11px;
    font-weight: 700;
    padding: 0 6px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pin-badge, .mute-badge {
    font-size: 14px;
    opacity: 0.6;
}

/* Chat Menu Button */
.chat-menu-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-item:hover .chat-menu-btn {
    opacity: 1;
}

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

/* ===== Chat Area ===== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
    min-width: 0;
}

@media (max-width: 768px) {
    .chat-area {
        position: fixed;
        inset: 0;
        z-index: 200;
        transform: translateX(100%);
        transition: transform var(--transition-normal);
    }

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

/* Chat Background Pattern */
.chat-bg {
    position: absolute;
    inset: 0;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%239C92AC' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

/* Chat Area Header */
.chat-area-header {
    height: var(--header-height);
    padding: 0 12px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 5;
}

.back-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.back-btn:hover {
    background: var(--bg-hover);
}

.back-btn:active {
    transform: scale(0.95);
}

.back-btn svg {
    display: block;
}

@media (max-width: 768px) {
    .back-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

.header-contact {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
    padding: 6px 8px;
    margin: -6px -8px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.header-contact:hover {
    background: var(--bg-hover);
}

.header-contact:active {
    background: var(--bg-active);
}

.chat-area-info {
    flex: 1;
    min-width: 0;
}

.chat-area-name {
    font-weight: 600;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.chat-area-status {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.chat-area-status.typing {
    color: var(--accent);
    animation: typingPulse 1s ease-in-out infinite;
}

@keyframes typingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

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

.header-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.header-actions .icon-btn {
    width: 40px;
    height: 40px;
    color: var(--text-secondary);
}

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

.header-actions .icon-btn svg {
    display: block;
}

@media (max-width: 768px) {
    .chat-area-header {
        padding: 0 8px;
        gap: 4px;
    }

    .header-contact {
        gap: 10px;
    }

    .header-actions {
        gap: 0;
    }

    .header-actions .icon-btn {
        width: 36px;
        height: 36px;
    }
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 1;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

@media (min-width: 769px) {
    .messages-container {
        padding: 16px 60px;
    }
}

/* Load Older Messages */
.load-older-container {
    display: flex;
    justify-content: center;
    padding: 12px;
}

.load-older-btn {
    padding: 8px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

/* Date Separator */
.date-separator {
    display: flex;
    justify-content: center;
    padding: 16px 0;
}

.date-separator span {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius-lg);
    font-size: 12px;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 6px 8px 6px 9px;
    border-radius: 8px;
    position: relative;
    animation: messageIn 0.2s ease-out;
    transform-origin: bottom;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

@media (min-width: 769px) {
    .message {
        max-width: 65%;
    }
}

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

.message.incoming {
    align-self: flex-start;
    background: var(--bg-message-in);
    border-top-left-radius: 0;
    margin-left: 0;
}

.message.outgoing {
    align-self: flex-end;
    background: var(--bg-message-out);
    border-top-right-radius: 0;
    margin-right: 0;
}

/* Message tail effect */
.message.incoming::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 8px;
    height: 13px;
    background: var(--bg-message-in);
    clip-path: polygon(100% 0, 100% 100%, 0 0);
}

.message.outgoing::before {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    width: 8px;
    height: 13px;
    background: var(--bg-message-out);
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

/* Consecutive messages - hide tail */
.message + .message.incoming.same-sender::before,
.message + .message.outgoing.same-sender::before {
    display: none;
}

.message + .message.incoming.same-sender {
    border-top-left-radius: 8px;
    margin-top: 2px;
}

.message + .message.outgoing.same-sender {
    border-top-right-radius: 8px;
    margin-top: 2px;
}

/* Group sender name colors */
.message-sender {
    font-size: 12.5px;
    font-weight: 500;
    margin-bottom: 2px;
    cursor: pointer;
}

.message-sender:hover {
    text-decoration: underline;
}

/* Sender color palette for groups */
.message-sender.color-1, .message-sender-info.color-1 .sender-name { color: #06cf9c; }
.message-sender.color-2, .message-sender-info.color-2 .sender-name { color: #25d366; }
.message-sender.color-3, .message-sender-info.color-3 .sender-name { color: #53bdeb; }
.message-sender.color-4, .message-sender-info.color-4 .sender-name { color: #7c3aed; }
.message-sender.color-5, .message-sender-info.color-5 .sender-name { color: #e91e63; }
.message-sender.color-6, .message-sender-info.color-6 .sender-name { color: #ff9800; }
.message-sender.color-7, .message-sender-info.color-7 .sender-name { color: #009688; }
.message-sender.color-8, .message-sender-info.color-8 .sender-name { color: #3f51b5; }

/* Messages with sender avatar (groups and private chats) */
.message.has-avatar {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.message-sender-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    flex-shrink: 0;
    overflow: hidden;
}

.message-sender-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.message-sender-avatar:hover {
    transform: scale(1.05);
    transition: transform 0.15s;
}

.message-sender-avatar-spacer {
    width: 32px;
    min-width: 32px;
    flex-shrink: 0;
}

.message-sender-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
    cursor: pointer;
}

.message-sender-info:hover .sender-name {
    text-decoration: underline;
}

.message-sender-info .sender-name {
    font-size: 12.5px;
    font-weight: 600;
}

.message-sender-info .sender-phone {
    font-size: 11px;
    color: var(--text-muted);
    direction: ltr;
}

/* Sticker message - no background */
.message.sticker-message {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.message.sticker-message::before {
    display: none;
}

.message.sticker-message .message-footer {
    position: absolute;
    bottom: 4px;
    left: 8px;
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 6px;
    border-radius: 8px;
}

.message.sticker-message .message-time {
    color: rgba(255, 255, 255, 0.9);
}

/* Media-only message - adjust padding */
.message.media-only {
    padding: 3px;
}

.message.media-only .message-footer {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 6px;
    border-radius: 8px;
    float: none;
    margin: 0;
    top: auto;
}

.message.media-only .message-time,
.message.media-only .message-status {
    color: rgba(255, 255, 255, 0.9);
}

.message-text {
    font-size: 14.2px;
    line-height: 19px;
    white-space: pre-wrap;
}

.message-text a {
    color: var(--info);
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

/* Inline footer for short messages */
.message-footer {
    display: inline-flex;
    justify-content: flex-end;
    align-items: center;
    gap: 3px;
    float: left;
    margin: 0 0 -5px 4px;
    position: relative;
    top: 5px;
}

.message.outgoing .message-footer {
    float: left;
    margin: 0 0 -5px 4px;
}

.message-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 400;
}

.message.incoming .message-time {
    color: var(--text-muted);
}

.message-status {
    font-size: 14px;
    margin-left: 2px;
}

.message-status.sent { color: rgba(255,255,255,0.5); }
.message-status.delivered { color: rgba(255,255,255,0.6); }
.message-status.read { color: #53bdeb; }

.message-star {
    font-size: 11px;
    margin-right: 2px;
}

.message-edited {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    margin-right: 3px;
}

.message.incoming .message-edited {
    color: var(--text-muted);
}

/* Quoted Message */
.quoted-message {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 7px;
    border-right: 4px solid var(--accent);
    padding: 5px 12px 7px 8px;
    margin-bottom: 3px;
    cursor: pointer;
    transition: background 0.15s;
}

.quoted-message:hover {
    background: rgba(0, 0, 0, 0.15);
}

.quoted-sender {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
    margin-bottom: 2px;
}

.quoted-text {
    font-size: 13px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.quoted-media {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quoted-thumb {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
}

/* Quoted Message */
.quoted-message {
    background: rgba(0,0,0,0.15);
    border-right: 3px solid var(--accent);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Message Media */
.message-media {
    border-radius: 6px;
    overflow: hidden;
    margin: -6px -8px 4px -9px;
    position: relative;
}

.message-media img {
    width: 100%;
    min-width: 200px;
    max-width: 330px;
    display: block;
    cursor: pointer;
}

.message-media video {
    width: 100%;
    min-width: 200px;
    max-width: 330px;
    max-height: 400px;
    display: block;
    background: #000;
}

.message-media-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30px 8px 6px;
    background: linear-gradient(transparent, rgba(0,0,0,0.5));
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 4px;
}

.message-media-overlay .message-time,
.message-media-overlay .message-status {
    color: rgba(255,255,255,0.9);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* View Once Media */
.message-viewonce {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 200px;
    height: 200px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    flex-direction: column;
    gap: 8px;
    color: var(--text-secondary);
}

.message-viewonce-icon {
    font-size: 40px;
    opacity: 0.7;
}

/* Voice/Audio Message */
.voice-message {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px;
    padding: 4px 0;
}

.voice-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    position: relative;
}

.voice-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* Old voice-play-btn styles removed - see enhanced styles below */

.voice-content {
    flex: 1;
    min-width: 0;
}

.voice-waveform {
    height: 28px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.voice-bar {
    width: 3px;
    background: var(--text-muted);
    border-radius: 2px;
    transition: height 0.1s;
}

.voice-bar.played {
    background: var(--accent);
}

.voice-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.voice-duration {
    font-size: 11px;
    color: var(--text-muted);
}

.voice-speed {
    font-size: 11px;
    color: var(--accent);
    cursor: pointer;
    padding: 2px 6px;
    background: rgba(0,168,132,0.15);
    border-radius: 10px;
}

/* Document Message */
.message-document {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    margin: -2px -4px 4px;
    cursor: pointer;
    min-width: 220px;
}

.message-document:hover {
    background: rgba(0, 0, 0, 0.1);
}

.doc-icon {
    width: 42px;
    height: 50px;
    background: #ef4444;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.doc-icon::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.3) 50%);
}

.doc-icon span {
    font-size: 10px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
}

.doc-icon.pdf { background: #ef4444; }
.doc-icon.doc, .doc-icon.docx { background: #3b82f6; }
.doc-icon.xls, .doc-icon.xlsx { background: #22c55e; }
.doc-icon.ppt, .doc-icon.pptx { background: #f97316; }
.doc-icon.zip, .doc-icon.rar { background: #eab308; }
.doc-icon.txt { background: #6b7280; }

.doc-info {
    flex: 1;
    min-width: 0;
}

.doc-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.doc-download {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Location Message */
.message-location {
    border-radius: 6px;
    overflow: hidden;
    margin: -2px -4px 4px;
    cursor: pointer;
}

.location-map {
    width: 100%;
    height: 140px;
    background: var(--bg-tertiary);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.location-map::after {
    content: '📍';
    font-size: 36px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.location-info {
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.05);
}

.location-name {
    font-size: 14px;
    font-weight: 500;
}

.location-address {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Contact Message */
.message-contact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    margin: -2px -4px 4px;
    min-width: 200px;
}

.contact-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    flex-shrink: 0;
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-size: 15px;
    font-weight: 500;
}

.contact-phone {
    font-size: 13px;
    color: var(--text-secondary);
    direction: ltr;
    text-align: right;
}

.contact-action {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.contact-action:hover {
    background: var(--accent);
    color: white;
}

/* Poll Message */
.message-poll {
    min-width: 240px;
    padding: 4px 0;
}

.poll-question {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.poll-question::before {
    content: '📊';
    font-size: 18px;
}

.poll-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.poll-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.poll-option:hover {
    background: rgba(0, 0, 0, 0.12);
}

.poll-radio {
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.poll-option.selected .poll-radio {
    border-color: var(--accent);
    background: var(--accent);
}

.poll-option.selected .poll-radio::after {
    content: '✓';
    color: white;
    font-size: 12px;
}

.poll-text {
    flex: 1;
    font-size: 14px;
}

.poll-votes {
    font-size: 12px;
    color: var(--text-muted);
}

.poll-total {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* Sticker Message */
.message-sticker {
    margin: -6px -8px -4px -9px;
}

.message-sticker img {
    max-width: 180px;
    max-height: 180px;
}

/* GIF Message */
.message-gif {
    border-radius: 6px;
    overflow: hidden;
    margin: -2px -4px 4px;
}

.message-gif video {
    width: 100%;
    max-width: 280px;
    display: block;
}

.message-gif-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Forwarded indicator */
.forwarded-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.forwarded-indicator::before {
    content: '↪️';
    font-size: 12px;
}

/* Message Reactions */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-top: 4px;
    margin-bottom: -2px;
}

.reaction-chip {
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: var(--radius-full);
    font-size: 14px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 4px;
}

.reaction-count {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Voice Message Enhanced */
.voice-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    min-width: 240px;
}

.voice-play-btn {
    position: static !important;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: white;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, background 0.15s;
    opacity: 1 !important;
    z-index: 10;
    pointer-events: auto !important;
}

.voice-play-btn:hover {
    transform: scale(1.05);
}

.voice-play-btn:active {
    transform: scale(0.95);
}

.voice-play-btn.playing .play-icon { display: none; }
.voice-play-btn.playing .pause-icon { display: block !important; }

.voice-waveform {
    flex: 1;
    height: 32px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.voice-waveform-bars {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 2px;
}

.waveform-bar {
    width: 3px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    transition: background 0.1s;
}

.message.incoming .waveform-bar {
    background: rgba(0,0,0,0.2);
}

.voice-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    pointer-events: none;
}

.voice-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--accent);
    opacity: 0.4;
}

.voice-duration {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 36px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.voice-speed-btn {
    font-size: 11px;
    color: var(--accent);
    background: rgba(0,168,132,0.15);
    border: none;
    padding: 4px 8px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s;
}

.voice-speed-btn:hover {
    background: rgba(0,168,132,0.25);
}

/* Document Message Enhanced */
.document-icon {
    width: 44px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.document-info {
    flex: 1;
    min-width: 0;
}

.document-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.document-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.document-type {
    background: rgba(0,0,0,0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.document-download {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.message-document:hover .document-download {
    transform: scale(1.1);
}

/* Location Enhanced */
.location-pin {
    display: flex;
    align-items: center;
    justify-content: center;
}

.location-coords {
    font-size: 11px;
    color: var(--text-muted);
    direction: ltr;
    text-align: right;
    margin-top: 2px;
}

/* Contact Message Enhanced */
.contact-label {
    font-size: 12px;
    color: var(--text-muted);
}

/* Poll Message Enhanced */
.poll-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
}

.poll-header svg {
    flex-shrink: 0;
    color: var(--accent);
}

.message-poll .poll-question {
    font-size: 15px;
    font-weight: 500;
    margin: 0;
}

.message-poll .poll-question::before {
    display: none;
}

.poll-option-text {
    font-size: 14px;
}

.poll-footer {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.08);
    text-align: center;
}

.poll-footer .poll-votes {
    font-size: 12px;
    color: var(--text-muted);
}

/* Poll Voting */
.poll-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--accent);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.poll-option {
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 6px;
    background: var(--bg-hover);
    transition: all 0.2s ease;
}

.poll-option:hover {
    background: var(--bg-active);
}

.poll-option.selected {
    background: var(--accent-light);
    border: 1px solid var(--accent);
}

.poll-option.selected .poll-checkbox {
    background: var(--accent);
}

.poll-option.voted {
    pointer-events: none;
    opacity: 0.8;
}

.poll-vote-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.poll-vote-btn:hover {
    background: var(--accent-hover);
}

.poll-vote-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* GIF Badge */
.gif-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.message-gif {
    position: relative;
}

/* Contacts Message (multiple) */
.message-contacts {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(0,0,0,0.05);
    border-radius: 6px;
}

.contacts-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.contacts-title {
    font-size: 14px;
    font-weight: 500;
}

/* Special Messages (group invite, product, list, etc.) */
.message-special {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
}

.special-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    flex-shrink: 0;
}

.message-special.group-invite .special-icon {
    background: linear-gradient(135deg, #25d366, #128c7e);
}

.special-content {
    flex: 1;
    min-width: 0;
}

.special-title {
    font-size: 14px;
    font-weight: 600;
}

.special-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* System Message */
.system-message {
    text-align: center;
    padding: 6px 12px;
    background: rgba(0,0,0,0.04);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Unsupported Message */
.message-unsupported {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(0,0,0,0.05);
    border-radius: 6px;
    border-right: 3px solid var(--text-muted);
    font-size: 13px;
    color: var(--text-secondary);
}

/* Placeholder for missing media */
.message-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13px;
}

/* Placeholder for unavailable media with reload button */
.message-placeholder-unavailable {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    background: rgba(0,0,0,0.08);
    border-radius: 12px;
    min-width: 180px;
}

.message-placeholder-unavailable .placeholder-icon {
    font-size: 32px;
    opacity: 0.6;
}

.message-placeholder-unavailable .placeholder-text {
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

.reload-media-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 4px;
}

.reload-media-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.reload-media-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.reload-media-btn svg {
    flex-shrink: 0;
}

/* Quoted Message Enhanced */
.quoted-message {
    background: rgba(0,0,0,0.08);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 6px;
    border-right: 3px solid var(--accent);
    cursor: pointer;
    transition: background 0.15s;
}

.quoted-message:hover {
    background: rgba(0,0,0,0.12);
}

.quoted-sender {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 2px;
}

.quoted-content {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.message.outgoing .quoted-message {
    border-right-color: rgba(255,255,255,0.5);
}

.message.outgoing .quoted-sender {
    color: rgba(255,255,255,0.9);
}

/* Forwarded Indicator Enhanced */
.forwarded-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-style: italic;
}

.forwarded-indicator::before {
    display: none;
}

.forwarded-indicator svg {
    opacity: 0.7;
}

/* Load Older Messages Button */
.load-older-container {
    text-align: center;
    padding: 16px;
}

.load-older-btn {
    background: var(--bg-hover);
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    color: var(--accent);
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.load-older-btn:hover {
    background: var(--bg-input);
    transform: scale(1.02);
}

.load-older-btn:active {
    transform: scale(0.98);
}

.load-older-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Message Actions (hover) */
.message-actions {
    position: absolute;
    top: 4px;
    left: 4px;
    display: none;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 4px;
    box-shadow: var(--shadow-md);
    gap: 2px;
}

.message:hover .message-actions,
.message.show-actions .message-actions {
    display: flex;
}

.message-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.message-action-btn:hover {
    background: var(--bg-hover);
}

/* Scroll to Bottom Button */
.scroll-bottom-btn {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 44px;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-bottom-btn.show {
    opacity: 1;
    visibility: visible;
}

.scroll-bottom-btn:hover {
    background: var(--bg-hover);
    transform: translateX(-50%) scale(1.1);
}

.scroll-bottom-btn .unread-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* ===== Input Area ===== */
.input-area {
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-area-bottom));
    background: var(--bg-secondary);
    display: flex;
    align-items: flex-end;
    gap: 10px;
    z-index: 5;
}

@media (max-width: 768px) {
    .input-area {
        padding: 10px 12px;
        padding-bottom: calc(10px + var(--safe-area-bottom));
    }
}

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

.input-wrapper {
    flex: 1;
    position: relative;
}

.reply-preview {
    background: var(--bg-input);
    padding: 10px 14px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-right: 3px solid var(--accent);
    margin-bottom: -4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.reply-preview-content {
    flex: 1;
    min-width: 0;
}

.reply-preview-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 2px;
}

.reply-preview-text {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-close {
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.reply-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.message-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-xl);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    resize: none;
    min-height: 48px;
    max-height: 120px;
    outline: none;
    transition: background var(--transition-fast);
}

.message-input:focus {
    background: var(--bg-tertiary);
}

.message-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 48px;
    height: 48px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

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

.voice-btn {
    width: 48px;
    height: 48px;
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.voice-btn:hover {
    background: var(--bg-hover);
}

.voice-btn.recording {
    background: var(--danger);
    color: white;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* Recording Indicator */
.recording-indicator {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-input);
    border-radius: var(--radius-xl);
    flex: 1;
}

.recording-indicator.show {
    display: flex;
}

.recording-dot {
    width: 12px;
    height: 12px;
    background: var(--danger);
    border-radius: var(--radius-full);
    animation: pulse 1s infinite;
}

.recording-time {
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.recording-cancel {
    margin-right: auto;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.recording-cancel:hover {
    background: var(--bg-hover);
    color: var(--danger);
}

/* ===== Empty State ===== */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    z-index: 1;
}

.empty-icon {
    font-size: 80px;
    margin-bottom: 24px;
    opacity: 0.4;
}

@media (min-width: 769px) {
    .empty-icon {
        font-size: 120px;
    }
}

.empty-title {
    font-size: 24px;
    font-weight: 300;
    color: var(--text-primary);
    margin-bottom: 8px;
}

@media (min-width: 769px) {
    .empty-title {
        font-size: 32px;
    }
}

.empty-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 300px;
}

/* ===== Modals ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 420px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.3s var(--spring);
}

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

@media (max-width: 480px) {
    .modal {
        max-height: 90vh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: 100%;
        animation: slideUp 0.3s var(--spring);
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
}

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

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* Dialog Modal (Confirm/Prompt) */
.dialog-modal .modal {
    max-width: 350px;
    animation: dialogIn 0.25s var(--spring);
}

@keyframes dialogIn {
    from {
        opacity: 0;
        transform: scale(0.85);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.dialog-modal .btn {
    min-height: 44px;
    font-weight: 600;
}

.dialog-modal .btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
}

.dialog-modal .btn-secondary:hover {
    background: var(--bg-hover);
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    outline: none;
    transition: all var(--transition-fast);
}

.form-input:focus {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.form-input::placeholder {
    color: var(--text-muted);
}

textarea.form-input {
    resize: vertical;
    min-height: 100px;
}

.btn {
    width: 100%;
    padding: 14px 24px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn:hover {
    background: var(--accent-hover);
}

.btn:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
}

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

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: #dc2626;
}

/* ===== QR Modal ===== */
.qr-container {
    background: white;
    padding: 20px;
    border-radius: var(--radius-lg);
    display: inline-block;
    margin: 20px 0;
}

.qr-steps {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 2;
    padding-right: 24px;
    text-align: right;
}

/* ===== Attachments Menu ===== */
.attach-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 12px;
    margin-bottom: 12px;
    display: none;
    box-shadow: var(--shadow-xl);
    min-width: 200px;
}

.attach-menu.show {
    display: block;
    animation: slideUp 0.2s var(--spring);
}

.attach-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

@media (min-width: 480px) {
    .attach-menu {
        min-width: 280px;
    }

    .attach-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.attach-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background var(--transition-fast);
}

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

.attach-item:active {
    transform: scale(0.95);
}

.attach-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.attach-icon.purple { background: #7c3aed; }
.attach-icon.blue { background: #0ea5e9; }
.attach-icon.green { background: #22c55e; }
.attach-icon.orange { background: #f97316; }
.attach-icon.pink { background: #ec4899; }
.attach-icon.red { background: #ef4444; }

.attach-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Context Menu ===== */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 8px 0;
    min-width: 200px;
    box-shadow: var(--shadow-xl);
    z-index: 1001;
    display: none;
    animation: contextIn 0.15s ease;
}

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

.context-menu.show {
    display: block;
}

.context-item {
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 14px;
    transition: background var(--transition-fast);
}

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

.context-item:active {
    background: var(--bg-active);
}

.context-icon {
    width: 20px;
    font-size: 16px;
    text-align: center;
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

@media (max-width: 768px) {
    .toast-container {
        bottom: calc(80px + var(--safe-area-bottom));
        left: 16px;
        right: 16px;
        transform: none;
    }
}

.toast {
    background: var(--bg-secondary);
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s var(--spring);
    pointer-events: auto;
}

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

.toast.success {
    border-right: 4px solid var(--online);
}

.toast.error {
    border-right: 4px solid var(--danger);
}

.toast.warning {
    border-right: 4px solid var(--warning);
}

.toast-icon {
    font-size: 20px;
}

.toast-message {
    font-size: 14px;
    flex: 1;
}

/* ===== Settings Tabs ===== */
.settings-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}

.settings-tabs::-webkit-scrollbar {
    display: none;
}

.settings-tab {
    flex: 1;
    min-width: max-content;
    padding: 14px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-fast);
    position: relative;
    white-space: nowrap;
}

.settings-tab:hover {
    background: var(--bg-hover);
}

.settings-tab.active {
    color: var(--accent);
}

.settings-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

.settings-tab-content.hidden {
    display: none;
}

/* ===== List Items ===== */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-hover);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    transition: background var(--transition-fast);
}

.list-item:hover {
    background: var(--bg-active);
}

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

.list-item-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-sub {
    font-size: 12px;
    color: var(--text-secondary);
}

.list-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.list-item-btn {
    padding: 8px 14px;
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.list-item-btn:hover {
    background: var(--accent);
}

.list-item-btn.danger:hover {
    background: var(--danger);
}

/* ===== Setting Items ===== */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-hover);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
}

.setting-item label {
    font-size: 14px;
}

.setting-item select {
    background: var(--bg-input);
    border: none;
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    outline: none;
}

.setting-item select:focus {
    box-shadow: 0 0 0 2px var(--accent-light);
}

/* Privacy Toggle Buttons */
.privacy-setting-item {
    background: var(--bg-hover);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 10px;
}

.privacy-setting-label {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.privacy-toggle-group {
    display: flex;
    gap: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 4px;
}

.privacy-toggle-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

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

.privacy-toggle-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 168, 132, 0.3);
}

.privacy-toggle-btn .toggle-icon {
    font-size: 18px;
}

.privacy-toggle-btn .toggle-label {
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

/* ===== Audio Player ===== */
.audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px 16px;
    border-radius: var(--radius-full);
    min-width: 280px;
}

.audio-player audio {
    display: none;
}

.audio-play-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--accent);
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.audio-play-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.audio-progress-container {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.audio-progress {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s linear;
}

.audio-time {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 40px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.audio-speed-btn {
    padding: 6px 10px;
    border-radius: var(--radius-full);
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    font-size: 11px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.audio-speed-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===== Loading Spinner ===== */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-hover);
    border-top-color: var(--accent);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Messages Loading ===== */
.messages-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 14px;
}

.messages-loading .loading-spinner {
    width: 32px;
    height: 32px;
}

/* ===== Search Results ===== */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    cursor: pointer;
    border-radius: var(--radius-lg);
    transition: background var(--transition-fast);
}

.search-result-item:hover {
    background: var(--bg-hover);
}

.search-result-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-name {
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-time {
    font-size: 11px;
    color: var(--text-muted);
}

/* ===== Starred Messages ===== */
.starred-message-item {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.starred-message-item:hover {
    background: var(--bg-hover);
}

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

.starred-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.starred-message-chat {
    font-weight: 600;
    color: var(--accent);
    font-size: 14px;
}

.starred-message-time {
    font-size: 11px;
    color: var(--text-muted);
}

.starred-message-content {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== WhatsApp Text Formatting ===== */
.message-text strong {
    font-weight: 700;
}

.message-text em {
    font-style: italic;
}

.message-text del {
    text-decoration: line-through;
}

.message-text code.wa-code {
    background: rgba(0, 0, 0, 0.25);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
}

.message-text code.wa-code-block {
    display: block;
    background: rgba(0, 0, 0, 0.25);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    margin: 6px 0;
}

/* ===== Format Menu ===== */
.format-menu {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 8px;
    margin-bottom: 8px;
    display: none;
    box-shadow: var(--shadow-lg);
    gap: 4px;
}

.format-menu.show {
    display: flex;
}

.format-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-hover);
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.format-btn:hover {
    background: var(--bg-active);
}

.format-btn code {
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

/* ===== Emoji Picker ===== */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 16px;
    margin-bottom: 12px;
    display: none;
    max-width: 320px;
    max-height: 280px;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.emoji-picker.show {
    display: block;
    animation: slideUp 0.2s var(--spring);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.emoji-btn {
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-btn:hover {
    background: var(--bg-hover);
    transform: scale(1.15);
}

/* ===== Chat Menu (Dropdown) ===== */
.chat-menu {
    position: absolute;
    top: 100%;
    left: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 8px 0;
    min-width: 200px;
    box-shadow: var(--shadow-xl);
    z-index: 100;
    animation: contextIn 0.15s ease;
}

.chat-menu-item {
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 14px;
    transition: background var(--transition-fast);
}

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

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

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

::-webkit-scrollbar-thumb {
    background: var(--bg-active);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Thin scrollbar for chat list */
.chat-list::-webkit-scrollbar {
    width: 4px;
}

/* ===== Keyboard Shortcut Hints ===== */
.shortcut-hint {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 8px;
    font-family: 'Menlo', 'Monaco', monospace;
}

/* ===== Mobile Bottom Navigation ===== */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    padding-bottom: var(--safe-area-bottom);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    z-index: 1000;
}

@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    .sidebar {
        padding-bottom: var(--mobile-nav-height);
    }
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

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

.nav-icon {
    font-size: 24px;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

.nav-item .badge {
    position: absolute;
    top: 4px;
    right: 8px;
    min-width: 18px;
    height: 18px;
    background: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Pull to Refresh (Mobile) ===== */
.pull-indicator {
    display: none;
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-fast);
}

.pull-indicator.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pull-indicator.loading .loading-spinner {
    width: 24px;
    height: 24px;
}

/* ===== Swipe Actions (Mobile) ===== */
.swipe-actions {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
}

.swipe-actions.left {
    right: 100%;
    padding-left: 16px;
}

.swipe-actions.right {
    left: 100%;
    padding-right: 16px;
}

.swipe-action {
    width: 60px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: white;
    font-size: 12px;
}

.swipe-action.reply {
    background: var(--accent);
}

.swipe-action.archive {
    background: var(--info);
}

.swipe-action.delete {
    background: var(--danger);
}

.swipe-action-icon {
    font-size: 20px;
}

/* ===== Image Lightbox ===== */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox.show {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-lg);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.lightbox-close:hover {
    background: var(--bg-hover);
    transform: scale(1.1);
}

/* ===== View Once Badge ===== */
.view-once-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
}

/* ===== Mentions ===== */
.mention {
    color: var(--info);
    font-weight: 500;
    cursor: pointer;
}

.mention:hover {
    text-decoration: underline;
}

/* ===== Link Preview ===== */
.link-preview {
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-top: 8px;
}

.link-preview-image {
    width: 100%;
    max-height: 150px;
    object-fit: cover;
}

.link-preview-content {
    padding: 10px 12px;
}

.link-preview-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.link-preview-description {
    font-size: 12px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.link-preview-url {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== Poll Message ===== */
.poll-container {
    min-width: 250px;
}

.poll-question {
    font-weight: 600;
    margin-bottom: 12px;
}

.poll-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.poll-option:hover {
    background: rgba(0, 0, 0, 0.25);
}

.poll-option-radio {
    width: 18px;
    height: 18px;
    border: 2px solid var(--text-muted);
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.poll-option.selected .poll-option-radio {
    background: var(--accent);
    border-color: var(--accent);
}

.poll-option-text {
    flex: 1;
    font-size: 14px;
}

.poll-option-votes {
    font-size: 12px;
    color: var(--text-muted);
}

/* Poll Vote Results */
.poll-option {
    position: relative;
    overflow: hidden;
}

.poll-option-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--accent);
    opacity: 0.2;
    transition: width 0.3s ease;
    border-radius: inherit;
}

.poll-option.has-votes {
    padding-right: 60px;
}

.poll-vote-count {
    position: absolute;
    right: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.poll-total-votes {
    font-size: 12px;
    color: var(--text-secondary);
    margin-right: auto;
}

/* Poll Voters Section */
.poll-voters-section {
    margin-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.08);
    padding-top: 8px;
}

.poll-voters-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 0;
}

.poll-voters-toggle svg {
    transition: transform 0.2s ease;
}

.poll-voters-section.expanded .poll-voters-toggle svg {
    transform: rotate(180deg);
}

.poll-voters-list {
    display: none;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.poll-voters-section.expanded .poll-voters-list {
    display: flex;
}

.poll-voter {
    font-size: 12px;
    color: var(--text-primary);
    padding: 4px 8px;
    background: rgba(0,0,0,0.03);
    border-radius: 4px;
}

.poll-voter.pending {
    color: var(--text-muted);
    font-style: italic;
}

.poll-voter .voter-name {
    font-weight: 500;
    color: var(--accent);
}

.poll-footer {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== Location Message ===== */
.location-preview {
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
}

.location-map {
    width: 100%;
    height: 150px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
}

.location-info {
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.15);
}

.location-name {
    font-weight: 600;
    font-size: 14px;
}

.location-address {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ===== Contact Message ===== */
.contact-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-md);
    min-width: 200px;
}

.contact-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    color: white;
}

.contact-info {
    flex: 1;
}

.contact-name {
    font-weight: 600;
    font-size: 14px;
}

.contact-phone {
    font-size: 12px;
    color: var(--text-secondary);
    direction: ltr;
}

/* ===== Document Message ===== */
.document-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-md);
    min-width: 200px;
}

.document-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.document-icon.pdf { background: #ef4444; }
.document-icon.doc { background: #3b82f6; }
.document-icon.xls { background: #22c55e; }
.document-icon.ppt { background: #f97316; }
.document-icon.zip { background: #8b5cf6; }

.document-info {
    flex: 1;
    min-width: 0;
}

.document-name {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-size {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Sticker Message ===== */
.sticker-container {
    max-width: 180px;
}

.sticker-container img {
    width: 100%;
    display: block;
}

/* ===== Typing Indicator ===== */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: var(--radius-full);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ===== Responsive Utilities ===== */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

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

/* ===== Print Styles ===== */
@media print {
    .sidebar,
    .input-area,
    .chat-area-header,
    .modal-overlay {
        display: none !important;
    }

    .chat-area {
        position: static;
        transform: none;
    }

    .messages-container {
        max-height: none;
        overflow: visible;
    }

    .message {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Premium Message Toolbar ===== */
.msg-toolbar {
    display: none;
    gap: 2px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}

.message:hover .msg-toolbar {
    display: flex;
}

.message.incoming .msg-toolbar {
    justify-content: flex-start;
}

.message.outgoing .msg-toolbar {
    justify-content: flex-end;
}

.toolbar-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.15s;
}

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

.toolbar-btn.delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.toolbar-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Premium Message Content Wrapper */
.msg-content-wrapper {
    position: relative;
}

/* Premium Message Meta (time, status) */
.msg-meta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    float: left;
    margin: 0 0 -4px 6px;
    position: relative;
    top: 4px;
}

.message.outgoing .msg-meta {
    float: left;
    margin: 0 0 -4px 6px;
}

.msg-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

.message.incoming .msg-time {
    color: var(--text-muted);
}

.msg-star {
    font-size: 10px;
}

.msg-edited {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
}

.message.incoming .msg-edited {
    color: var(--text-muted);
}

/* Mention Tag Styling */
.mention-tag {
    color: var(--accent);
    cursor: pointer;
    font-weight: 500;
    padding: 0 2px;
    border-radius: 3px;
    transition: background 0.15s;
}

.mention-tag:hover {
    background: rgba(0, 168, 132, 0.15);
    text-decoration: underline;
}

/* Message Link Styling */
.msg-link {
    color: var(--info);
    text-decoration: none;
    word-break: break-all;
}

.msg-link:hover {
    text-decoration: underline;
}

/* RTL Fix for Voice/Audio Player */
.voice-message {
    direction: ltr;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    min-width: 260px;
}

.voice-message * {
    direction: ltr;
}

/* RTL Fix for Video */
.message-media video {
    direction: ltr;
}

video::-webkit-media-controls {
    direction: ltr;
}

/* Header Actions Active State */
.header-actions .icon-btn.active {
    color: var(--accent);
    background: var(--accent-light);
}

.header-actions .icon-btn svg {
    width: 20px;
    height: 20px;
    display: block;
    fill: currentColor;
}

/* ===== High Contrast Mode ===== */
@media (prefers-contrast: high) {
    :root {
        --border: #444;
        --text-secondary: #aaa;
    }
}
