@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ═══════════════════════════════════════════
   DESIGN SYSTEM — CSS CUSTOM PROPERTIES
   ═══════════════════════════════════════════ */
:root,
[data-theme="dark"] {
    --bg-primary: #0E1621;
    --bg-secondary: #17212B;
    --bg-tertiary: #1C2733;
    --bg-hover: #202D3B;
    --bg-active: #2B3A4E;
    --accent: #E63946;
    --accent-light: #FF4D5A;
    --accent-dark: #C62828;
    --accent-gradient: linear-gradient(135deg, #E63946, #FF6B6B);
    --text-primary: #FFFFFF;
    --text-secondary: #8696A6;
    --text-tertiary: #5A6F82;
    --text-link: #FF6B6B;
    --border: #1E2C3A;
    --border-light: #243447;
    --danger: #E74C3C;
    --danger-hover: #C0392B;
    --success: #2ECC71;
    --warning: #F39C12;
    --online: #2ECC71;
    --bubble-out: #2B5278;
    --bubble-out-hover: #325E89;
    --bubble-in: #182533;
    --bubble-in-hover: #1E2E3F;
    --input-bg: #242F3D;
    --scrollbar-thumb: rgba(255, 255, 255, 0.15);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.25);
    --scrollbar-track: transparent;
    --modal-overlay: rgba(0, 0, 0, 0.65);
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 50%;
    --sidebar-width: 340px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 11px;
    --font-size-sm: 13px;
    --font-size-md: 14px;
    --font-size-lg: 16px;
    --font-size-xl: 18px;
    --font-size-xxl: 24px;
    --font-size-title: 32px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

[data-theme="light"] {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F0F2F5;
    --bg-tertiary: #E4E6EB;
    --bg-hover: #E8EAED;
    --bg-active: #D8DADF;
    --text-primary: #1C1E21;
    --text-secondary: #65676B;
    --text-tertiary: #8A8D91;
    --border: #E0E0E0;
    --border-light: #ECECEC;
    --bubble-out: #E63946;
    --bubble-out-hover: #C62828;
    --bubble-in: #E4E6EB;
    --bubble-in-hover: #D8DADF;
    --input-bg: #F0F2F5;
    --scrollbar-thumb: rgba(0, 0, 0, 0.15);
    --scrollbar-thumb-hover: rgba(0, 0, 0, 0.25);
    --modal-overlay: rgba(0, 0, 0, 0.45);
}

/* ═══════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

input,
textarea,
button {
    font-family: inherit;
}

a {
    color: var(--text-link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

#app {
    height: 100%;
    width: 100%;
}

/* SVG Icon base */
.icon {
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

/* ═══════════════════════════════════════════
   SPLASH SCREEN
   ═══════════════════════════════════════════ */
.splash-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

.splash-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.splash-logo {
    animation: splashPulse 1.5s ease-in-out infinite;
}

@keyframes splashPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.08);
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════
   SKELETON LOADING
   ═══════════════════════════════════════════ */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeletonShimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
}

.skeleton-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-line {
    height: 12px;
    border-radius: 6px;
}

.skeleton-line.w-70 {
    width: 70%;
}

.skeleton-line.w-50 {
    width: 50%;
}

.skeleton-line.w-30 {
    width: 30%;
}

/* ═══════════════════════════════════════════
   AUTH SCREENS
   ═══════════════════════════════════════════ */
.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    background: #080c14;
    background-image: radial-gradient(ellipse at 30% 20%, rgba(230, 57, 70, 0.08) 0%, transparent 60%), radial-gradient(ellipse at 70% 80%, rgba(255, 107, 107, 0.05) 0%, transparent 50%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.auth-card {
    background: rgba(23, 33, 43, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5), 0 0 80px rgba(230, 57, 70, 0.06);
    animation: fadeSlideUp 0.5s ease;
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 32px;
}

.auth-logo .logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-logo .logo-icon img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    filter: drop-shadow(0 0 24px rgba(230, 57, 70, 0.3));
}

.auth-logo .logo-text {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #ffffff 40%, #E63946 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-card h2 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
}

.auth-card .auth-subtitle {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 24px;
    font-size: var(--font-size-sm);
}

.form-group {
    margin-bottom: 16px;
    position: relative;
}

.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--font-size-md);
    transition: border-color var(--transition-fast);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent);
}

.form-input.error {
    border-color: var(--danger);
}

.form-error {
    color: var(--danger);
    font-size: var(--font-size-xs);
    margin-top: 4px;
    min-height: 16px;
}

.form-hint {
    color: var(--text-tertiary);
    font-size: var(--font-size-xs);
    margin-top: 4px;
}

.form-hint.success {
    color: var(--success);
}

.form-hint.error {
    color: var(--danger);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    user-select: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    width: 100%;
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    filter: none;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--accent);
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: rgba(230, 57, 70, 0.1);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-full);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    transform: scale(1.05);
}

.btn-icon:active {
    transform: scale(0.95);
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--accent);
    cursor: pointer;
}

/* Avatar upload */
.avatar-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-full);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
    color: #fff;
    transition: filter var(--transition-fast);
}

.avatar-preview:hover {
    filter: brightness(0.8);
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-preview .avatar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
    font-size: 14px;
    font-weight: 500;
    color: #fff;
}

.avatar-preview:hover .avatar-overlay {
    opacity: 1;
}

.avatar-upload-hint {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin-top: 8px;
}

/* ═══════════════════════════════════════════
   MAIN LAYOUT
   ═══════════════════════════════════════════ */
.messenger {
    display: flex;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    height: 56px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.search-wrapper {
    flex: 1;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    background: var(--input-bg);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    outline: none;
    transition: background var(--transition-fast);
}

.search-input:focus {
    background: var(--bg-tertiary);
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
    display: flex;
    align-items: center;
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background var(--transition-fast);
    position: relative;
    user-select: none;
}

.chat-item:hover {
    background: var(--bg-hover);
}

.chat-item.active {
    background: var(--bg-active);
}

.chat-item .avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.chat-item .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar .online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    background: var(--online);
    border: 2px solid var(--bg-secondary);
    border-radius: var(--radius-full);
    z-index: 2;
}

.chat-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-item-name {
    font-size: var(--font-size-md);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-item-name .type-icon {
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
}

.chat-item-time {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.chat-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-item-preview {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.chat-item-preview .sender-prefix {
    color: var(--accent-light);
    font-weight: 500;
}

.unread-badge {
    background: var(--accent);
    color: #fff;
    font-size: var(--font-size-xs);
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    flex-shrink: 0;
}

/* ── Chat Area ── */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    background: var(--bg-primary);
    position: relative;
}

.chat-area-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    gap: 16px;
}

.chat-area-empty .empty-logo {
    opacity: 0.15;
}

.chat-area-empty .empty-text {
    font-size: var(--font-size-lg);
}

.chat-area-empty .empty-hint {
    font-size: var(--font-size-sm);
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 5;
}

.chat-header .back-btn {
    display: none;
}

.chat-header .avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    overflow: hidden;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
}

.chat-header .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.chat-header-name {
    font-size: var(--font-size-lg);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-header-status {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.chat-header-status.online {
    color: var(--online);
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

.messages-list {
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: auto;
}

.date-separator {
    text-align: center;
    margin: 12px 0;
}

.date-separator span {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 12px;
}

.message {
    display: flex;
    max-width: 70%;
    animation: msgIn 0.2s ease;
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.out {
    align-self: flex-end;
}

.message.in {
    align-self: flex-start;
}

.message .msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    margin-right: 8px;
    align-self: flex-end;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: var(--bg-tertiary);
}

.message .msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msg-bubble {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    position: relative;
    word-break: break-word;
    min-width: 80px;
}

.message.out .msg-bubble {
    background: var(--bubble-out);
    border-bottom-right-radius: var(--radius-xs);
}

.message.in .msg-bubble {
    background: var(--bubble-in);
    border-bottom-left-radius: var(--radius-xs);
}

.msg-sender {
    font-size: var(--font-size-sm);
    font-weight: 600;
    margin-bottom: 2px;
}

.msg-reply {
    background: rgba(255, 255, 255, 0.08);
    border-left: 2px solid var(--accent);
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    margin-bottom: 4px;
    font-size: var(--font-size-sm);
    cursor: pointer;
}

.msg-reply .reply-name {
    color: var(--accent-light);
    font-weight: 600;
    font-size: var(--font-size-xs);
}

.msg-reply .reply-text {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-content {
    font-size: var(--font-size-md);
    line-height: 1.45;
    white-space: pre-wrap;
}

.msg-media {
    max-width: 320px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 4px;
}

.msg-media img {
    width: 100%;
    display: block;
    cursor: pointer;
}

.msg-media video {
    width: 100%;
    display: block;
}

.msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 2px;
}

.msg-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

.msg-edited {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    font-style: italic;
}

.msg-check {
    display: inline-flex;
    align-items: center;
}

.msg-check.sent {
    color: rgba(255, 255, 255, 0.4);
}

.msg-check.delivered {
    color: rgba(255, 255, 255, 0.6);
}

.msg-check.read {
    color: #68D391;
}

/* Typing */
.typing-indicator {
    padding: 4px 16px;
    font-size: var(--font-size-sm);
    color: var(--accent-light);
    min-height: 24px;
}

.typing-dots {
    display: inline-flex;
    gap: 3px;
    margin-left: 4px;
}

.typing-dots span {
    width: 5px;
    height: 5px;
    background: var(--accent-light);
    border-radius: var(--radius-full);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Scroll down btn */
.new-msg-btn {
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 5;
    transition: all var(--transition-fast);
}

.new-msg-btn:hover {
    background: var(--bg-hover);
    transform: scale(1.05);
}

/* Input Area */
.input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
}

.reply-preview {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent);
    padding: 6px 12px;
    border-radius: var(--radius-xs);
    gap: 12px;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    z-index: 2;
}

.reply-preview-content {
    flex: 1;
    min-width: 0;
}

.reply-preview-name {
    font-size: var(--font-size-sm);
    color: var(--accent-light);
    font-weight: 600;
}

.reply-preview-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reply-close {
    cursor: pointer;
    color: var(--text-tertiary);
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color var(--transition-fast);
}

.reply-close:hover {
    color: var(--text-primary);
}

.input-wrapper {
    flex: 1;
    position: relative;
}

.msg-input {
    width: 100%;
    max-height: 150px;
    padding: 10px 14px;
    background: var(--input-bg);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--font-size-md);
    resize: none;
    outline: none;
    line-height: 1.4;
    overflow-y: auto;
}

.msg-input::placeholder {
    color: var(--text-tertiary);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    padding-bottom: 4px;
}

.send-btn {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-full);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    align-self: flex-end;
    margin-bottom: 4px;
}

.send-btn:hover {
    transform: scale(1.08);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ═══════════════════════════════════════════
   SLIDE MENU
   ═══════════════════════════════════════════ */
.slide-menu {
    position: fixed;
    top: 0;
    left: -320px;
    width: 300px;
    height: 100%;
    background: var(--bg-secondary);
    z-index: 100;
    transition: left var(--transition-normal);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
}

.slide-menu.open {
    left: 0;
}

.slide-menu-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.slide-menu-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.slide-menu-header {
    padding: 24px 20px 16px;
    background: var(--accent-gradient);
}

.slide-menu-avatar {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-full);
    margin-bottom: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
}

.slide-menu-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.slide-menu-name {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: #fff;
}

.slide-menu-username {
    font-size: var(--font-size-sm);
    color: rgba(255, 255, 255, 0.7);
}

.slide-menu-items {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.slide-menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background var(--transition-fast);
    color: var(--text-primary);
    font-size: var(--font-size-md);
}

.slide-menu-item:hover {
    background: var(--bg-hover);
}

.slide-menu-item .menu-icon {
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.slide-menu-sep {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--bg-hover);
}

.toggle-track {
    width: 42px;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    position: relative;
    transition: background var(--transition-fast);
}

.toggle-thumb {
    width: 20px;
    height: 20px;
    background: var(--text-primary);
    border-radius: var(--radius-full);
    position: absolute;
    top: 2px;
    left: 2px;
    transition: left var(--transition-fast);
}

.theme-toggle.active .toggle-track {
    background: var(--accent);
}

.theme-toggle.active .toggle-thumb {
    left: 20px;
}

/* ═══════════════════════════════════════════
   CONTEXT MENU
   ═══════════════════════════════════════════ */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    min-width: 180px;
    padding: 4px 0;
    animation: contextFade 0.15s ease;
}

@keyframes contextFade {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: var(--font-size-sm);
    transition: background var(--transition-fast);
    color: var(--text-primary);
}

.context-menu-item:hover {
    background: var(--bg-hover);
}

.context-menu-item.danger {
    color: var(--danger);
}

.context-menu-item .ctx-icon {
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ═══════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modalFade 0.2s ease;
}

@keyframes modalFade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.modal-close {
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: var(--radius-xs);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

/* Emoji Panel */
.emoji-panel {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    box-shadow: var(--shadow-lg);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 10;
    animation: contextFade 0.15s ease;
}

.emoji-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 22px;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.emoji-item:hover {
    background: var(--bg-hover);
    transform: scale(1.15);
}

/* ═══════════════════════════════════════════
   CALL SCREENS
   ═══════════════════════════════════════════ */
.call-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    animation: fadeSlideUp 0.3s ease;
}

.incoming-call {
    position: fixed;
    inset: 0;
    z-index: 600;
    background: linear-gradient(180deg, #1a1040 0%, #0E1621 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    animation: fadeSlideUp 0.3s ease;
}

.incoming-call .caller-avatar {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
    animation: callerPulse 2s infinite;
}

.incoming-call .caller-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@keyframes callerPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(108, 92, 231, 0.5);
    }

    50% {
        box-shadow: 0 0 0 20px rgba(108, 92, 231, 0);
    }
}

.incoming-call .caller-name {
    font-size: var(--font-size-xxl);
    font-weight: 700;
}

.incoming-call .call-type {
    font-size: var(--font-size-md);
    color: var(--text-secondary);
}

.call-actions {
    display: flex;
    gap: 48px;
    margin-top: 40px;
}

.call-action-btn {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: transform var(--transition-fast);
}

.call-action-btn:hover {
    transform: scale(1.1);
}

.call-action-btn.accept {
    background: var(--success);
}

.call-action-btn.reject {
    background: var(--danger);
}

.active-call {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.call-remote-video {
    flex: 1;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.call-remote-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.call-remote-video .no-video {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
}

.call-remote-video .no-video .call-avatar {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
}

.call-remote-video .no-video .call-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.call-timer {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
}

.call-local-video {
    position: absolute;
    bottom: 100px;
    right: 20px;
    width: 180px;
    height: 240px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--border);
    background: #111;
    z-index: 10;
    box-shadow: var(--shadow-lg);
}

.call-local-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.call-controls {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    background: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(12px);
    padding: 12px 24px;
    border-radius: 40px;
    z-index: 20;
}

.call-control-btn {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--bg-tertiary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.call-control-btn:hover {
    filter: brightness(1.2);
    transform: scale(1.05);
}

.call-control-btn.active {
    background: var(--danger);
}

.call-control-btn.end {
    background: var(--danger);
    width: 60px;
}

/* User items in modals */
.user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
    border-radius: var(--radius-sm);
}

.user-item:hover {
    background: var(--bg-hover);
}

.user-item .avatar {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: var(--bg-tertiary);
    flex-shrink: 0;
    overflow: hidden;
}

.user-item .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-item-info {
    flex: 1;
    min-width: 0;
}

.user-item-name {
    font-weight: 600;
    font-size: var(--font-size-md);
}

.user-item-username {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.user-item .check-box {
    width: 22px;
    height: 22px;
    border: 2px solid var(--text-tertiary);
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: all var(--transition-fast);
}

.user-item .check-box.checked {
    background: var(--accent);
    border-color: var(--accent);
}

/* ═══════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: var(--font-size-sm);
    animation: toastIn 0.3s ease;
    max-width: 320px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--accent);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    .messenger {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        position: absolute;
        inset: 0;
        z-index: 20;
        transition: transform var(--transition-normal);
    }

    .sidebar.hidden {
        transform: translateX(-100%);
    }

    .chat-area {
        position: absolute;
        inset: 0;
        z-index: 15;
    }

    .chat-header .back-btn {
        display: flex;
    }

    .message {
        max-width: 85%;
    }

    .call-local-video {
        width: 120px;
        height: 160px;
        bottom: 90px;
        right: 12px;
    }

    .profile-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        min-width: 100%;
        z-index: 50;
    }

    .emoji-panel {
        grid-template-columns: repeat(7, 1fr);
        width: calc(100vw - 24px);
        left: 0;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --sidebar-width: 280px;
    }
}

/* ═══════════════════════════════════════════
   UTILITY
   ═══════════════════════════════════════════ */
.hidden {
    display: none !important;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-accent {
    color: var(--accent);
}

.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--success);
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════
   CHANNEL POSTS
   ═══════════════════════════════════════════ */
.message.channel-post {
    display: flex;
    justify-content: center;
    margin: 8px 16px;
}

.msg-bubble.channel-bubble {
    max-width: 600px;
    width: 100%;
    background: var(--bubble-in);
    border-radius: var(--radius-md);
    padding: 12px;
}

.msg-bubble.channel-bubble .msg-content {
    font-size: var(--font-size-md);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ═══════════════════════════════════════════
   REACTIONS
   ═══════════════════════════════════════════ */
.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.reaction-badge:hover {
    background: rgba(255, 255, 255, 0.1);
}

.reaction-badge.active {
    background: rgba(230, 57, 70, 0.15);
    border-color: rgba(230, 57, 70, 0.3);
}

.reaction-bar {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.msg-bubble.channel-bubble:hover .reaction-bar {
    opacity: 1;
}

.reaction-btn {
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 6px;
    font-size: 16px;
    transition: all var(--transition-fast);
}

.reaction-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.2);
}

/* ═══════════════════════════════════════════
   TYPING IN HEADER
   ═══════════════════════════════════════════ */
.chat-header-status.typing {
    color: var(--accent);
    animation: typingPulse 1.2s ease-in-out infinite;
}

@keyframes typingPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ═══════════════════════════════════════════
   CALL MINI BAR
   ═══════════════════════════════════════════ */
.call-mini-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9000;
    background: linear-gradient(135deg, #E63946, #C62828);
    color: #fff;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 12px rgba(230, 57, 70, 0.3);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

.call-mini-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.call-mini-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    animation: miniDotPulse 1s ease-in-out infinite;
}

@keyframes miniDotPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.call-mini-timer {
    font-variant-numeric: tabular-nums;
    opacity: 0.8;
}

.call-mini-actions {
    display: flex;
    gap: 8px;
}

.call-mini-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.call-mini-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.call-mini-btn.end {
    background: rgba(255, 255, 255, 0.3);
}

.call-mini-btn.end:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ═══════════════════════════════════════════
   FILE PREVIEW
   ═══════════════════════════════════════════ */
.file-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

/* ═══════════════════════════════════════════
   CLOSE CHAT BUTTON
   ═══════════════════════════════════════════ */
#btn-close-chat {
    margin-left: auto;
}

/* Back button visible on mobile */
@media (max-width: 768px) {
    .chat-header .back-btn {
        display: flex !important;
    }

    #btn-close-chat {
        display: none;
    }
}

@media (min-width: 769px) {
    .chat-header .back-btn {
        display: none !important;
    }
}