:root {
    /* Default - Dark Matte */
    --bg-main: #0b0f19;
    --bg-sidebar: #151b2c;
    --bg-hover: #222b44;
    --bg-input: #1e2640;
    --bg-message-sent: #4f46e5;
    --bg-message-received: #1e2640;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --border-color: rgba(255, 255, 255, 0.06);
    
    --font-family: 'Inter', sans-serif;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 50%;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-glass: 0 4px 30px rgba(0, 0, 0, 0.15);
    
    --backdrop-filter: none;
    --bg-body-mesh: none;
}

body[data-theme="dark-transparent"] {
    --bg-main: transparent;
    --bg-sidebar: rgba(15, 22, 38, 0.65);
    --bg-hover: rgba(255, 255, 255, 0.08);
    --bg-input: rgba(255, 255, 255, 0.05);
    --bg-message-sent: rgba(79, 70, 229, 0.85);
    --bg-message-received: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.08);
    --backdrop-filter: blur(24px) saturate(190%);
    --bg-body-mesh: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.25) 0%, transparent 45%),
                    radial-gradient(circle at 90% 80%, rgba(20, 184, 166, 0.22) 0%, transparent 45%),
                    radial-gradient(circle at 50% 50%, rgba(168, 85, 247, 0.15) 0%, transparent 50%),
                    #070a13;
}

body[data-theme="white-matte"] {
    --bg-main: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-hover: #e2e8f0;
    --bg-input: #f8fafc;
    --bg-message-sent: #6366f1;
    --bg-message-received: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: rgba(0, 0, 0, 0.06);
    --shadow-glass: 0 4px 30px rgba(0, 0, 0, 0.06);
}

body[data-theme="white-transparent"] {
    --bg-main: transparent;
    --bg-sidebar: rgba(255, 255, 255, 0.65);
    --bg-hover: rgba(0, 0, 0, 0.05);
    --bg-input: rgba(0, 0, 0, 0.03);
    --bg-message-sent: rgba(99, 102, 241, 0.85);
    --bg-message-received: rgba(0, 0, 0, 0.05);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --border-color: rgba(0, 0, 0, 0.06);
    --backdrop-filter: blur(24px) saturate(180%);
    --bg-body-mesh: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 45%),
                    radial-gradient(circle at 90% 80%, rgba(20, 184, 166, 0.1) 0%, transparent 45%),
                    radial-gradient(circle at 50% 50%, rgba(168, 85, 247, 0.08) 0%, transparent 50%),
                    #f8fafc;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--bg-body-mesh, var(--bg-main));
    background-attachment: fixed;
    background-size: cover;
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: var(--radius-full);
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 340px;
    background-color: var(--bg-sidebar);
    backdrop-filter: var(--backdrop-filter);
    -webkit-backdrop-filter: var(--backdrop-filter);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

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

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    border-radius: var(--radius-full);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

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

.search-bar {
    flex: 1;
    display: flex;
    align-items: center;
    background-color: var(--bg-main);
    border-radius: 20px;
    padding: 0 16px;
    height: 40px;
    border: 1px solid transparent;
    transition: border-color 0.3s ease;
}

.search-bar:focus-within {
    border-color: var(--accent);
}

.search-bar i {
    color: var(--text-secondary);
    font-size: 18px;
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 100%;
    padding: 0 10px;
    outline: none;
    font-family: var(--font-family);
    font-size: 14px;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

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

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

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

.chat-item.active .chat-name,
.chat-item.active .chat-last-message,
.chat-item.active .chat-time {
    color: #fff;
}

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

.gradient-1 { background: linear-gradient(135deg, #6366f1, #a855f7); }
.gradient-2 { background: linear-gradient(135deg, #ec4899, #f43f5e); }
.gradient-3 { background: linear-gradient(135deg, #10b981, #3b82f6); }

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

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

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

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

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

.unread-badge {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
}
.chat-item.active .unread-badge {
    background-color: white;
    color: var(--accent);
}

/* Main Chat Area */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    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="%23ffffff" fill-opacity="0.02"%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');
}

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

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.chat-header-info .avatar {
    width: 42px;
    height: 42px;
}

.header-text h2 {
    font-size: 16px;
    font-weight: 600;
}

.status {
    font-size: 13px;
    color: var(--text-secondary);
}

.status.online {
    color: #10b981;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-history {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message-date {
    align-self: center;
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(4px);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    margin: 16px 0;
}

.message {
    display: flex;
    max-width: 65%;
    animation: fadeIn 0.3s ease;
}

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

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

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

.message-content {
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    font-size: 15px;
    line-height: 1.4;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.message.received .message-content {
    background: var(--bg-sidebar);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.message-image {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    cursor: pointer;
}

audio {
    height: 36px;
    outline: none;
    max-width: 200px;
}

.typing-indicator {
    padding: 10px 24px;
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    font-style: italic;
}

.typing-indicator .dots span {
    animation: typing 1.4s infinite both;
}
.typing-indicator .dots span:nth-child(1) { animation-delay: 0s; }
.typing-indicator .dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 80%, 100% { opacity: 0; }
    40% { opacity: 1; }
}

.mic-btn.recording {
    color: #ef4444 !important;
    animation: pulse 1s infinite;
}

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

.message.sent .message-content {
    background-color: var(--bg-message-sent);
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    float: right;
    margin-top: 8px;
    margin-left: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.message.sent .message-time i {
    color: #a5b4fc;
}

.chat-input-area {
    padding: 16px 24px;
    background: var(--bg-sidebar);
    backdrop-filter: var(--backdrop-filter);
    -webkit-backdrop-filter: var(--backdrop-filter);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-input-area input {
    flex: 1;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 12px 20px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 15px;
    outline: none;
    transition: border-color 0.3s ease;
}

.chat-input-area input:focus {
    border-color: var(--accent);
}

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

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

/* Modals & Menus Styling */

/* Settings Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-sidebar);
    backdrop-filter: var(--backdrop-filter);
    -webkit-backdrop-filter: var(--backdrop-filter);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 400px;
    max-width: 90%;
    box-shadow: var(--shadow-glass);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

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

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

.modal-body {
    padding: 24px;
}

.profile-section {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.avatar.lg {
    width: 64px;
    height: 64px;
    font-size: 24px;
}

.profile-info h4 {
    font-size: 18px;
    margin-bottom: 4px;
}

.profile-info p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 2px;
}

.profile-info .username {
    color: var(--accent);
}

.settings-list {
    list-style: none;
}

.settings-list li {
    display: flex;
    align-items: center;
    padding: 12px 0;
    gap: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    transition: background-color 0.2s;
}

.settings-list li:last-child {
    border-bottom: none;
}

.settings-list li:hover {
    background-color: rgba(255,255,255,0.02);
}

.settings-list li.danger {
    color: #ef4444;
}

.settings-list li.danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

.settings-list i {
    font-size: 20px;
    color: var(--text-secondary);
}

.settings-list li.danger i {
    color: #ef4444;
}

.settings-list span {
    flex: 1;
    font-size: 15px;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-main);
    transition: .4s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(20px); }

/* ====== Emoji Picker ====== */
.emoji-picker {
    position: absolute;
    bottom: 80px;
    right: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px;
    display: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 100;
}

.emoji-picker.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

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

.emoji-grid span {
    cursor: pointer;
    text-align: center;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease;
}

.emoji-grid span:hover {
    background: var(--bg-hover);
}

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

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

/* ====== Mobile Responsiveness ====== */
@media (max-width: 768px) {
    .sidebar {
        width: 100% !important;
        display: flex;
    }

    .main-chat {
        display: none !important;
        width: 100%;
    }

    .app-container.mobile-chat-active .sidebar {
        display: none !important;
    }

    .app-container.mobile-chat-active .main-chat {
        display: flex !important;
    }

    #mobile-back-btn {
        display: flex !important;
    }

    .chat-header {
        height: 60px;
        padding: 0 16px;
    }

    .chat-history {
        padding: 16px;
    }

    .message {
        max-width: 85%;
    }

    .chat-input-area {
        padding: 12px 16px;
        gap: 8px;
    }

    .attachment-menu {
        left: 16px !important;
        bottom: 72px;
    }

    .emoji-picker {
        right: 16px !important;
        bottom: 72px;
        max-width: 90%;
    }

    .login-box {
        padding: 24px 16px;
        width: 100%;
        margin: 16px;
    }
}

/* Attachment Menu */
.attachment-menu {
    position: absolute;
    bottom: 80px;
    left: 364px; /* Default based on sidebar */
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 0;
    box-shadow: var(--shadow-md);
    display: none;
    z-index: 50;
    animation: popUp 0.2s ease-out forwards;
}

.attachment-menu.active {
    display: block;
}

.attach-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.attach-item:hover {
    background-color: rgba(255,255,255,0.05);
}

.attach-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.attach-icon.bg-blue { background-color: #3b82f6; }
.attach-icon.bg-green { background-color: #10b981; }
.attach-icon.bg-yellow { background-color: #f59e0b; }

/* Context Menu */
.context-menu {
    position: absolute;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 0;
    box-shadow: var(--shadow-md);
    display: none;
    z-index: 100;
    min-width: 150px;
}

.context-menu.active {
    display: block;
    animation: fadeIn 0.15s ease-out forwards;
}

.context-menu ul {
    list-style: none;
}

.context-menu li {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.context-menu li:hover {
    background-color: rgba(255,255,255,0.05);
}

.context-menu li.danger {
    color: #ef4444;
}

.context-menu li i {
    font-size: 18px;
}

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

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-main);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.login-overlay.active {
    display: flex;
}

.login-box {
    background: var(--bg-sidebar);
    padding: 40px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-glass);
    text-align: center;
    width: 360px;
    max-width: 90%;
}

.login-error-msg {
    color: #ef4444;
    font-size: 13px;
    margin-top: -8px;
    margin-bottom: 16px;
    text-align: center;
    background: rgba(239, 68, 68, 0.1);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(239, 68, 68, 0.2);
    display: none;
}

.login-box h2 {
    margin-bottom: 8px;
    color: var(--text-primary);
}

.login-box p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 14px;
}

.login-box input {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 15px;
    outline: none;
    margin-bottom: 16px;
    transition: border-color 0.3s ease;
}

.login-box input:focus {
    border-color: var(--accent);
}

.login-box button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.input-wrapper { flex: 1; position: relative; display: flex; align-items: center; }
.input-wrapper input { width: 100%; background: var(--bg-main); border: 1px solid var(--border-color); border-radius: 20px; padding: 12px 48px 12px 20px; color: var(--text-primary); outline: none; transition: var(--transition); }
.input-wrapper input:focus { border-color: var(--accent); }
.input-wrapper .emoji-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; font-size: 18px; }

/* Settings sub-views */
.settings-view {
    display: none;
    animation: fadeIn 0.2s ease-in-out;
}
.settings-view.active {
    display: block;
}

.settings-back-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    margin-bottom: 12px;
    transition: transform 0.2s ease;
}
.settings-back-btn:hover {
    transform: translateX(-4px);
    color: var(--accent-hover);
}

/* Theme Options */
.theme-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 8px;
}

.theme-card {
    background: var(--bg-hover);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    padding: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theme-card:hover {
    transform: scale(1.03);
    background: var(--bg-sidebar);
}

.theme-card.active {
    border-color: var(--accent);
    background: var(--bg-sidebar);
}

.theme-card span {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Theme Previews */
.theme-preview {
    height: 60px;
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--border-color);
}

.preview-bubble {
    width: 60%;
    height: 12px;
    border-radius: 6px;
}

.preview-bubble.received {
    align-self: flex-start;
}

.preview-bubble.sent {
    align-self: flex-end;
    width: 45%;
}

/* Theme Preview Colors */
.dark-matte-preview {
    background: #0b0f19;
}
.dark-matte-preview .preview-bubble.received { background: #1e2640; }
.dark-matte-preview .preview-bubble.sent { background: #4f46e5; }

.dark-transparent-preview {
    background: linear-gradient(135deg, #1e1b4b, #0f172a, #134e5e);
}
.dark-transparent-preview .preview-bubble.received { background: rgba(255,255,255,0.1); }
.dark-transparent-preview .preview-bubble.sent { background: rgba(99, 102, 241, 0.8); }

.white-matte-preview {
    background: #f1f5f9;
}
.white-matte-preview .preview-bubble.received { background: #e2e8f0; }
.white-matte-preview .preview-bubble.sent { background: #6366f1; }

.white-transparent-preview {
    background: linear-gradient(135deg, #e0e7ff, #f1f5f9, #e2e8f0);
}
.white-transparent-preview .preview-bubble.received { background: rgba(0,0,0,0.06); }
.white-transparent-preview .preview-bubble.sent { background: rgba(99, 102, 241, 0.85); }

/* ====== Image Viewer Modal (iOS 27 & OxygenOS 16 style) ====== */
.image-viewer-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(5, 5, 10, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.image-viewer-modal.active {
    display: flex;
    opacity: 1;
}

.image-viewer-content {
    max-width: 90%;
    max-height: 85dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); /* Spring Physics! */
}

.image-viewer-modal.active .image-viewer-content {
    transform: scale(1) translateY(0);
}

.image-viewer-modal img {
    max-width: 100%;
    max-height: 85dvh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

/* Circular Close Button (iOS style) */
.image-viewer-close {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10000;
}

.image-viewer-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.image-viewer-close:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .image-viewer-close {
        top: 16px;
        right: 16px;
    }
}

/* Document Message Styling */
.message-document {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.12);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
}

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

.document-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    display: block;
    word-break: break-all;
}

.document-link:hover {
    text-decoration: underline;
    color: var(--accent-hover);
}

/* Poll Message Styling */
.message-poll {
    background: rgba(0, 0, 0, 0.12);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 8px;
    width: 280px;
    max-width: 100%;
}

.poll-question {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.poll-option {
    position: relative;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s, background-color 0.2s;
}

.poll-option:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.poll-option.voted {
    border-color: var(--accent);
}

.poll-option-bar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    background: rgba(99, 102, 241, 0.25);
    transition: width 0.4s cubic-bezier(0.1, 0.8, 0.3, 1);
    z-index: 1;
}

.poll-option.voted .poll-option-bar {
    background: rgba(99, 102, 241, 0.4);
}

.poll-option-text-wrapper {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
}

.poll-option-text {
    color: var(--text-primary);
}

.poll-option-percent {
    color: var(--text-secondary);
}

.poll-footer {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
}

/* Modal form controls */
.modal-content input {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 15px;
    outline: none;
    transition: border-color 0.3s ease;
}

.modal-content input:focus {
    border-color: var(--accent);
}

/* Header Dropdown Menu */
.header-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    min-width: 180px;
    padding: 6px 0;
    display: none;
    animation: fadeIn 0.15s ease-out forwards;
}

.header-dropdown.active {
    display: block;
}

.header-dropdown ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.header-dropdown li {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-primary);
    transition: background-color 0.2s;
}

.header-dropdown li:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.header-dropdown li.danger {
    color: #ef4444;
}

.header-dropdown li.danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

.header-dropdown li i {
    font-size: 18px;
}

/* Header Search Container */
.header-search-container {
    display: none;
    align-items: center;
    gap: 10px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-sidebar);
    padding: 0 20px;
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: var(--backdrop-filter);
    animation: fadeIn 0.2s ease-in-out;
}

.header-search-container.active {
    display: flex;
}

.header-search-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 16px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 14px;
    outline: none;
}

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

/* Microphone Recording State */
.mic-btn.recording {
    color: #ef4444 !important;
    animation: pulseRecording 1.2s infinite ease-in-out;
    background-color: rgba(239, 68, 68, 0.1);
    border-radius: 50%;
}

@keyframes pulseRecording {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}
