/* ═══ SAYFECHAT 2027 — Telegram/WhatsApp Inspired Dark UI ═══ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=SF+Pro+Display:wght@400;500;600;700&display=swap');

:root {
    /* ═══ Core Palette ═══ */
    --bg: #0a0e17;
    --bg-panel: #111827;
    --bg-panel-hover: #1a2332;
    --bg-input: #1e293b;
    --bg-message-own: #2d5a3d;
    --bg-message-other: #1e293b;
    --bg-message-hover: #243447;
    --bg-header: #111827;
    --bg-sidebar: #0d1117;
    --bg-sidebar-hover: #161c27;
    --bg-date: #1e293b;
    --bg-popup: #1e293b;

    /* ═══ Text ═══ */
    --text: #f0f2f5;
    --text-secondary: #8696a0;
    --text-muted: #546e7a;
    --text-link: #6ab3f3;
    --text-green: #5bb88c;
    --text-blue: #6ab3f3;

    /* ═══ Accents ═══ */
    --accent: #33a853;
    --accent-hover: #2d9448;
    --accent-telegram: #3390ec;
    --accent-telegram-hover: #2a7bc7;
    --accent-red: #ef5350;
    --accent-orange: #ff9800;

    /* ═══ Borders ═══ */
    --border: rgba(255,255,255,0.04);
    --border-light: rgba(255,255,255,0.08);
    --separator: #1e2d3b;

    /* ═══ Shadows ═══ */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px rgba(51,168,83,0.15);

    /* ═══ Spacing ═══ */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 50%;

    /* ═══ Transitions ═══ */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    /* ═══ Fonts ═══ */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'SF Pro Display', 'Inter', sans-serif;
}

/* ═══ Reset & Base ═══ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ═══ App Shell ═══ */
#app { width: 100%; height: 100vh; display: flex; flex-direction: column; }
.screen { display: none; width: 100%; height: 100%; }
.screen.active { display: flex; }

/* ═══ AUTH SCREEN — Telegram Style Split ═══ */
#auth-screen {
    background: linear-gradient(135deg, #0a0e17 0%, #111827 50%, #0d1117 100%);
    position: relative;
    overflow: hidden;
}
.auth-bg {
    position: fixed; inset: 0; pointer-events: none; z-index: 0;
}
.auth-glow {
    position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.15;
    animation: authFloat 10s ease-in-out infinite;
}
.auth-glow-1 { width: 500px; height: 500px; background: var(--accent); top: -10%; left: -5%; }
.auth-glow-2 { width: 400px; height: 400px; background: var(--accent-telegram); bottom: -10%; right: -5%; animation-delay: -5s; }
@keyframes authFloat { 0%,100%{transform:translate(0,0) scale(1);} 50%{transform:translate(20px,-20px) scale(1.1);} }

.auth-split {
    display: flex; width: 100%; height: 100%; position: relative; z-index: 1;
    max-width: 1200px; margin: 0 auto;
}
.auth-brand {
    flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 60px;
    gap: 24px;
}
.auth-shield-wrap {
    position: relative; width: 80px; height: 80px; margin-bottom: 8px;
}
.auth-shield {
    width: 80px; height: 80px; border-radius: 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent-telegram));
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; box-shadow: var(--shadow-glow);
    position: relative; z-index: 2;
}
.auth-shield-ring {
    position: absolute; inset: -6px; border-radius: 26px;
    border: 2px solid rgba(51,168,83,0.3); animation: ringPulse 3s ease-in-out infinite;
}
@keyframes ringPulse { 0%,100%{opacity:0.3; transform:scale(1);} 50%{opacity:0.6; transform:scale(1.05);} }

.auth-title {
    font-family: var(--font-display); font-size: 3rem; font-weight: 700;
    background: linear-gradient(135deg, #fff, var(--text-secondary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}
.auth-subtitle { font-size: 1.1rem; color: var(--text-secondary); max-width: 400px; line-height: 1.6; }
.auth-badges { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.badge {
    display: flex; align-items: center; gap: 6px; font-size: 0.8rem;
    color: var(--text-secondary); background: rgba(255,255,255,0.04);
    padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border-light);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.badge .dot.green { background: var(--text-green); }
.badge .dot.blue { background: var(--text-blue); }

/* ═══ Auth Card — Right Side ═══ */
.auth-card {
    width: 420px; max-width: 100%; padding: 40px; margin: auto 60px auto 0;
    background: rgba(17,24,39,0.6); backdrop-filter: blur(20px);
    border: 1px solid var(--border-light); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.auth-card-header { margin-bottom: 28px; }
.auth-card-header h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 6px; }
.auth-card-header p { color: var(--text-secondary); font-size: 0.9rem; }

/* ═══ Tabs ═══ */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; padding: 4px; background: var(--bg-input); border-radius: var(--radius-md); }
.tab-btn {
    flex: 1; padding: 10px; border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-secondary); font-size: 0.9rem;
    font-weight: 500; cursor: pointer; transition: all var(--transition-fast);
    font-family: var(--font-body);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(51,168,83,0.3); }

/* ═══ Forms ═══ */
.form-panel { display: none; animation: fadeIn 0.3s ease; }
.form-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.input-wrap {
    display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 0 16px; transition: all var(--transition-fast);
}
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(51,168,83,0.1); }
.input-icon { font-size: 1rem; opacity: 0.5; flex-shrink: 0; }
.input-wrap input {
    flex: 1; padding: 14px 0; background: transparent; border: none; color: var(--text);
    font-size: 0.95rem; outline: none; font-family: var(--font-body);
}
.input-wrap input::placeholder { color: var(--text-muted); }

.auth-options {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; font-size: 0.85rem; color: var(--text-secondary);
}
.remember { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.remember input { accent-color: var(--accent); width: 16px; height: 16px; }
.forgot-link { color: var(--text-link); text-decoration: none; transition: opacity var(--transition-fast); }
.forgot-link:hover { opacity: 0.8; }

/* ═══ Buttons ═══ */
.btn-glow, .btn-primary {
    width: 100%; padding: 14px; border: none; border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff; font-size: 0.95rem; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: all var(--transition-fast); font-family: var(--font-body);
    box-shadow: 0 4px 12px rgba(51,168,83,0.25);
}
.btn-glow:hover, .btn-primary:hover {
    transform: translateY(-1px); box-shadow: 0 6px 20px rgba(51,168,83,0.35);
}
.btn-glow:active { transform: translateY(0); }

/* ═══ Error ═══ */
.error-msg {
    margin-top: 14px; padding: 10px 14px; border-radius: var(--radius-sm);
    background: rgba(239,83,80,0.1); border: 1px solid rgba(239,83,80,0.2);
    color: var(--accent-red); font-size: 0.85rem; text-align: center; display: none;
}
.error-msg.show { display: block; animation: shake 0.4s ease; }
@keyframes shake { 0%,100%{transform:translateX(0);} 25%{transform:translateX(-5px);} 75%{transform:translateX(5px);} }

/* ═══ MAIN APP — WhatsApp/Telegram Layout ═══ */
#main-screen {
    flex-direction: row;
    height: 100vh;
    overflow: hidden;
}
#main-screen.active { display: flex !important; }

/* ═══ Sidebar Overlay (Desktop hidden) ═══ */
#sidebar-overlay { display: none; }

/* ═══ Sidebar ═══ */
#sidebar {
    width: 360px; min-width: 280px; max-width: 420px;
    background: var(--bg-sidebar); border-right: 1px solid var(--separator);
    display: flex; flex-direction: column; position: relative;
    flex-shrink: 0; height: 100%;
}
.sidebar-resize { position: absolute; right: 0; top: 0; bottom: 0; width: 4px; cursor: col-resize; z-index: 10; }

/* ═══ Sidebar Header (Telegram Style) ═══ */
.sidebar-header {
    padding: 12px 16px; background: var(--bg-header);
    border-bottom: 1px solid var(--separator);
    display: flex; align-items: center; gap: 12px;
}
.sidebar-header .menu-btn {
    width: 40px; height: 40px; border-radius: var(--radius-full);
    border: none; background: transparent; color: var(--text-secondary);
    font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background var(--transition-fast);
}
.sidebar-header .menu-btn:hover { background: rgba(255,255,255,0.05); }
.sidebar-search {
    flex: 1; position: relative;
}
.sidebar-search input {
    width: 100%; padding: 10px 14px 10px 36px; border-radius: var(--radius-md);
    background: var(--bg-input); border: 1px solid var(--border); color: var(--text);
    font-size: 0.9rem; outline: none; transition: all var(--transition-fast); font-family: var(--font-body);
}
.sidebar-search input:focus { border-color: var(--accent-telegram); }
.sidebar-search::before {
    content: "🔍"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    font-size: 0.8rem; opacity: 0.4;
}

/* ═══ Sidebar Tabs ═══ */
.sidebar-tabs {
    display: flex; padding: 8px 16px; gap: 8px; background: var(--bg-header);
    border-bottom: 1px solid var(--separator);
}
.sidebar-tab {
    flex: 1; padding: 8px; border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-secondary); font-size: 0.8rem;
    font-weight: 600; cursor: pointer; transition: all var(--transition-fast);
    text-transform: uppercase; letter-spacing: 0.5px; font-family: var(--font-body);
    position: relative;
}
.sidebar-tab:hover { color: var(--text); }
.sidebar-tab.active { color: var(--accent); }
.sidebar-tab.active::after {
    content: ""; position: absolute; bottom: -8px; left: 20%; right: 20%;
    height: 3px; background: var(--accent); border-radius: 2px;
}

/* ═══ Contact List — WhatsApp Style ═══ */
.contact-list { flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.1) transparent; }
.contact-list::-webkit-scrollbar { width: 4px; }
.contact-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ═══ Contact Item ═══ */
.contact-item {
    display: flex; align-items: center; gap: 14px; padding: 10px 16px;
    cursor: pointer; transition: background var(--transition-fast);
    position: relative; border-bottom: 1px solid rgba(255,255,255,0.02);
}
.contact-item:hover { background: var(--bg-sidebar-hover); }
.contact-item.active { background: var(--bg-message-hover); }
.contact-item.active::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--accent);
}

/* ═══ Avatar ═══ */
.contact-avatar, .chat-header-avatar, .profile-avatar {
    width: 48px; height: 48px; border-radius: var(--radius-full);
    background: linear-gradient(135deg, #4a6fa5, #6ab3f3);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; font-weight: 600; color: #fff; flex-shrink: 0;
    position: relative; overflow: hidden;
}
.contact-avatar img, .chat-header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.contact-avatar .online-indicator {
    position: absolute; bottom: 2px; right: 2px; width: 10px; height: 10px;
    background: var(--accent); border-radius: 50%; border: 2px solid var(--bg-sidebar);
}

/* ═══ Contact Info ═══ */
.contact-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.contact-name {
    font-size: 0.95rem; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contact-last-msg {
    font-size: 0.82rem; color: var(--text-secondary); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px;
}
.contact-last-msg .msg-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.contact-last-msg .msg-status {
    font-size: 0.75rem; opacity: 0.6; flex-shrink: 0;
}

/* ═══ Contact Meta (Time + Badge) ═══ */
.contact-meta {
    display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0;
}
.contact-time {
    font-size: 0.72rem; color: var(--text-muted); font-weight: 500;
}
.contact-badge {
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
    background: var(--accent); color: #fff; font-size: 0.7rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.contact-badge.muted { background: var(--text-muted); }

/* ═══ CHAT AREA ═══ */
#chat-area {
    flex: 1; display: flex; flex-direction: column; background: var(--bg);
    position: relative;
}

/* ═══ Chat Header ═══ */
#chat-header {
    padding: 10px 20px; background: var(--bg-header);
    border-bottom: 1px solid var(--separator);
    display: flex; align-items: center; gap: 14px;
    backdrop-filter: blur(10px);
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name {
    font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 2px;
}
.chat-header-status {
    font-size: 0.8rem; color: var(--accent); display: flex; align-items: center; gap: 4px;
}
.chat-header-status.online::before {
    content: ""; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; display: inline-block;
}
.chat-actions { display: flex; gap: 4px; }
.chat-action-btn {
    width: 40px; height: 40px; border-radius: var(--radius-full); border: none;
    background: transparent; color: var(--text-secondary); font-size: 1.1rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast);
}
.chat-action-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }

/* ═══ Messages Container ═══ */
.messages {
    flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 2px;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* ═══ Date Divider ═══ */
.date-divider {
    align-self: center; margin: 16px 0; padding: 4px 16px;
    background: var(--bg-date); border-radius: var(--radius-xl);
    font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.5px; font-weight: 500;
}

/* ═══ Message Bubbles ═══ */
.message {
    max-width: 65%; padding: 8px 12px; margin: 1px 0;
    position: relative; font-size: 0.92rem; line-height: 1.5;
    word-wrap: break-word; animation: msgSlide 0.25s ease;
}
@keyframes msgSlide { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.message.own { align-self: flex-end; background: var(--bg-message-own); color: #fff; border-radius: var(--radius-md) var(--radius-md) var(--radius-sm) var(--radius-md); }
.message.other { align-self: flex-start; background: var(--bg-message-other); color: var(--text); border-radius: var(--radius-md) var(--radius-md) var(--radius-md) var(--radius-sm); }
.message.own:hover { background: #326b45; }
.message.other:hover { background: var(--bg-message-hover); }

/* ═══ Message Content ═══ */
.message-text { margin-bottom: 2px; }
.message-time {
    float: right; margin-left: 8px; margin-top: 2px;
    font-size: 0.7rem; color: rgba(255,255,255,0.5);
    display: flex; align-items: center; gap: 3px;
}
.message.own .message-time { color: rgba(255,255,255,0.6); }

/* ═══ Read Receipts ═══ */
.read-status { font-size: 0.7rem; }
.read-status.sent { color: rgba(255,255,255,0.4); }
.read-status.delivered { color: rgba(255,255,255,0.6); }
.read-status.read { color: #6ab3f3; }

/* ═══ Reply Preview ═══ */
.reply-preview {
    padding: 8px 16px; background: var(--bg-header); border-top: 1px solid var(--separator);
    display: flex; align-items: center; gap: 12px;
}
.reply-preview-inner {
    flex: 1; padding-left: 8px; border-left: 3px solid var(--accent-telegram);
}
.reply-label { font-size: 0.75rem; color: var(--accent-telegram); font-weight: 600; }
.reply-text { font-size: 0.85rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* ═══ Chat Input Area — WhatsApp Style ═══ */
#chat-input-area {
    padding: 10px 16px; background: var(--bg-header);
    border-top: 1px solid var(--separator);
    display: flex; align-items: flex-end; gap: 10px;
}
.input-action-btn {
    width: 40px; height: 40px; border-radius: var(--radius-full); border: none;
    background: transparent; color: var(--text-secondary); font-size: 1.2rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all var(--transition-fast);
}
.input-action-btn:hover { color: var(--text); background: rgba(255,255,255,0.05); }

.msg-wrap {
    flex: 1; margin: 0; padding: 0; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-xl); min-height: 44px; max-height: 150px; overflow-y: auto;
}
.msg-wrap input, .msg-wrap textarea {
    width: 100%; padding: 12px 16px; border: none; background: transparent; color: var(--text);
    font-size: 0.95rem; outline: none; resize: none; font-family: var(--font-body);
    max-height: 150px;
}
.msg-wrap input::placeholder, .msg-wrap textarea::placeholder { color: var(--text-muted); }

.btn-send {
    width: 44px; height: 44px; border-radius: var(--radius-full); border: none;
    background: var(--accent); color: #fff; font-size: 1.2rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: all var(--transition-fast); box-shadow: 0 2px 8px rgba(51,168,83,0.3);
}
.btn-send:hover { background: var(--accent-hover); transform: scale(1.05); }
.btn-send:active { transform: scale(0.95); }
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; }

/* ═══ Typing Indicator ═══ */
.typing-indicator {
    align-self: flex-start; padding: 12px 16px; background: var(--bg-message-other);
    border-radius: var(--radius-md) var(--radius-md) var(--radius-md) var(--radius-sm);
    display: flex; align-items: center; gap: 6px; margin: 4px 0;
}
.typing-dot { width: 6px; height: 6px; background: var(--text-secondary); border-radius: 50%; animation: typingBounce 1.4s ease-in-out infinite; }
.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);} }

/* ═══ Context Menu ═══ */
.context-menu {
    position: absolute; z-index: 1000; background: var(--bg-popup);
    border: 1px solid var(--border-light); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); min-width: 180px; overflow: hidden;
    animation: menuPop 0.15s ease;
}
@keyframes menuPop { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.context-menu-item {
    padding: 10px 16px; cursor: pointer; font-size: 0.9rem; color: var(--text);
    display: flex; align-items: center; gap: 10px; transition: background var(--transition-fast);
}
.context-menu-item:hover { background: rgba(255,255,255,0.05); }
.context-menu-item.danger { color: var(--accent-red); }
.context-menu-item.danger:hover { background: rgba(239,83,80,0.1); }
.context-divider { height: 1px; background: var(--separator); margin: 4px 0; }

/* ═══ Modals — Telegram Style ═══ */
.modal-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden { display: none !important; }
.modal {
    background: var(--bg-panel); border: 1px solid var(--border-light);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    max-width: 90vw; max-height: 90vh; overflow: hidden;
    animation: modalSlide 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalSlide { from { opacity: 0; transform: translateY(20px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--separator); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-close { width: 32px; height: 32px; border: none; background: transparent; color: var(--text-secondary); font-size: 1.3rem; cursor: pointer; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; transition: all var(--transition-fast); }
.modal-close:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.modal-body { padding: 20px 24px; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--separator); display: flex; justify-content: flex-end; gap: 10px; }

/* ═══ Settings Panel — Telegram Style ═══ */
.settings-overlay {
    position: fixed; inset: 0; z-index: 1500; background: rgba(0,0,0,0.5);
    display: flex; justify-content: flex-end;
}
.settings-panel {
    width: 420px; max-width: 100%; height: 100%;
    background: var(--bg-panel); border-left: 1px solid var(--separator);
    display: flex; flex-direction: column;
    animation: slideRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slideRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
.settings-header {
    padding: 20px 24px; background: var(--bg-header); border-bottom: 1px solid var(--separator);
    display: flex; align-items: center; gap: 16px;
}
.settings-back { width: 40px; height: 40px; border: none; background: transparent; color: var(--text-secondary); font-size: 1.2rem; cursor: pointer; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; transition: background var(--transition-fast); }
.settings-back:hover { background: rgba(255,255,255,0.05); }
.settings-title { font-size: 1.2rem; font-weight: 600; }
.settings-body { flex: 1; overflow-y: auto; padding: 16px 0; }

/* ═══ Setting Sections ═══ */
.settings-section { margin-bottom: 8px; }
.settings-section-title {
    padding: 8px 24px; font-size: 0.75rem; text-transform: uppercase;
    color: var(--text-muted); font-weight: 600; letter-spacing: 0.5px;
}
.settings-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px; cursor: pointer; transition: background var(--transition-fast);
    border-bottom: 1px solid rgba(255,255,255,0.02);
}
.settings-item:hover { background: rgba(255,255,255,0.03); }
.settings-item-label { font-size: 0.95rem; color: var(--text); }
.settings-item-desc { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }
.settings-item-value { display: flex; align-items: center; gap: 8px; }

/* ═══ Switch Toggle ═══ */
.switch { position: relative; width: 44px; height: 24px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; inset: 0; background: var(--bg-input); border-radius: 12px;
    transition: all var(--transition-fast); border: 1px solid var(--border);
}
.slider::before {
    content: ""; position: absolute; height: 18px; width: 18px; left: 2px; bottom: 2px;
    background: var(--text-secondary); border-radius: 50%; transition: all var(--transition-fast);
}
input:checked + .slider { background: var(--accent); border-color: var(--accent); }
input:checked + .slider::before { transform: translateX(20px); background: #fff; }

/* ═══ Profile Panel ═══ */
.profile-header {
    padding: 24px; text-align: center; background: linear-gradient(180deg, rgba(51,168,83,0.1) 0%, transparent 100%);
}
.profile-avatar-xl {
    width: 100px; height: 100px; border-radius: var(--radius-full); margin: 0 auto 16px;
    background: linear-gradient(135deg, #4a6fa5, #6ab3f3); display: flex; align-items: center; justify-content: center;
    font-size: 2.5rem; color: #fff; border: 4px solid var(--bg-panel); box-shadow: var(--shadow-md);
}
.profile-name { font-size: 1.3rem; font-weight: 600; margin-bottom: 4px; }
.profile-username { font-size: 0.9rem; color: var(--text-secondary); }

/* ═══ Toast Notifications ═══ */
.toast-container { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px; background: var(--bg-popup); border: 1px solid var(--border-light);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    font-size: 0.9rem; color: var(--text); display: flex; align-items: center; gap: 10px;
    animation: toastUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes toastUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.toast.success { border-color: rgba(51,168,83,0.3); }
.toast.error { border-color: rgba(239,83,80,0.3); color: var(--accent-red); }
.toast.info { border-color: rgba(106,179,243,0.3); }

/* ═══ Scrollbar Styling ═══ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ═══ Selection ═══ */
::selection { background: rgba(51,168,83,0.3); color: #fff; }

/* ═══ Mobile Responsive ═══ */
@media (max-width: 768px) {
    #sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; transform: translateX(-100%); transition: transform var(--transition-slow); width: 85vw; max-width: 340px; }
    #sidebar.open { transform: translateX(0); }
    #sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; display: none; }
    #sidebar-overlay.show { display: block; }
    #back-btn { display: flex !important; }
    .auth-split { flex-direction: column; }
    .auth-brand { padding: 30px; text-align: center; align-items: center; }
    .auth-title { font-size: 2rem; }
    .auth-card { margin: 0 auto 40px; width: 90%; padding: 24px; }
    .message { max-width: 80%; }
}

/* ═══ Animations ═══ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

/* ═══ Utility ═══ */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

/* ═══ Enterpage (Post-Login) ═══ */
#enterpage { display: none; }

/* ═══ Voice Recording UI ═══ */
.voice-recording {
    display: flex; align-items: center; gap: 10px; padding: 8px 16px;
    background: rgba(239,83,80,0.1); border-radius: var(--radius-xl);
    animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.7;} }
.voice-wave { display: flex; align-items: center; gap: 3px; }
.voice-wave-bar { width: 3px; background: var(--accent-red); border-radius: 2px; animation: waveBar 0.5s ease-in-out infinite alternate; }
@keyframes waveBar { from { height: 4px; } to { height: 16px; } }

/* ═══ Emoji Picker ═══ */
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 8px; }
.emoji-grid span { font-size: 1.4rem; padding: 6px; cursor: pointer; border-radius: var(--radius-sm); text-align: center; transition: background var(--transition-fast); }
.emoji-grid span:hover { background: rgba(255,255,255,0.05); }

/* ═══ Poll ═══ */
.poll-bar { height: 6px; border-radius: 3px; background: var(--bg-input); overflow: hidden; margin: 6px 0; }
.poll-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-hover)); border-radius: 3px; transition: width 0.5s ease; }

/* ═══ Media Preview ═══ */
.media-preview { max-width: 260px; border-radius: var(--radius-md); overflow: hidden; margin: 4px 0; }
.media-preview img { width: 100%; display: block; }
.media-preview video { width: 100%; display: block; }

/* ═══ File Attachment ═══ */
.file-attachment {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px;
    background: rgba(255,255,255,0.05); border-radius: var(--radius-md); margin: 4px 0;
}
.file-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--accent-telegram); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 0.75rem; color: var(--text-muted); }

/* ═══ Search in Chat ═══ */
.search-highlight { background: rgba(51,168,83,0.3); border-radius: 2px; }

/* ═══ User Bar (Bottom of Sidebar) ═══ */
.user-bar {
    padding: 10px 16px; background: var(--bg-header); border-top: 1px solid var(--separator);
    display: flex; align-items: center; gap: 12px; cursor: pointer; transition: background var(--transition-fast);
}
.user-bar:hover { background: var(--bg-sidebar-hover); }
.user-bar-avatar { width: 36px; height: 36px; border-radius: var(--radius-full); background: linear-gradient(135deg, #4a6fa5, #6ab3f3); display: flex; align-items: center; justify-content: center; font-size: 0.9rem; font-weight: 600; color: #fff; flex-shrink: 0; }
.user-bar-info { flex: 1; min-width: 0; }
.user-bar-name { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-bar-status { font-size: 0.75rem; color: var(--accent); }
.user-bar-actions { display: flex; gap: 4px; }
.user-bar-btn { width: 32px; height: 32px; border-radius: var(--radius-full); border: none; background: transparent; color: var(--text-secondary); font-size: 0.9rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition-fast); }
.user-bar-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }

/* ═══ Voice Message Bubble ═══ */
.voice-msg { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.voice-play-btn { width: 36px; height: 36px; border-radius: var(--radius-full); border: none; background: rgba(255,255,255,0.1); color: #fff; font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.voice-waveform { flex: 1; height: 24px; display: flex; align-items: center; gap: 2px; }
.voice-waveform-bar { flex: 1; background: rgba(255,255,255,0.3); border-radius: 2px; transition: height 0.1s ease; }
.voice-duration { font-size: 0.75rem; color: rgba(255,255,255,0.6); flex-shrink: 0; }

/* ═══ Group Admin Labels ═══ */
.admin-badge { font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; background: var(--accent-telegram); color: #fff; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-left: 6px; }
.owner-badge { background: linear-gradient(135deg, #ffd700, #ffb700); color: #000; }

/* ═══ Sticker ═══ */
.sticker-msg { max-width: 160px; margin: 4px 0; }
.sticker-msg img { width: 100%; display: block; }

/* ═══ Link Preview ═══ */
.link-preview { max-width: 280px; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; margin: 4px 0; background: var(--bg-input); }
.link-preview-img { width: 100%; height: 120px; object-fit: cover; background: var(--bg); }
.link-preview-body { padding: 10px 14px; }
.link-preview-title { font-size: 0.85rem; font-weight: 600; color: var(--text-link); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-preview-desc { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-preview-url { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
