
:root {
    --bg-main: #13141f;
    --bg-panel: #1c1d2b;
    --border: #2d2e3f;
    --text-main: #e2e8f0;
    --text-muted: #8b8d9c;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --danger: #f43f5e;
}

/* ФИКС: Используем 100% вместо 100vh для корректной работы на мобильных устройствах */
html, body { height: 100%; margin: 0; padding: 0; }
* { box-sizing: border-box; font-family: 'Inter', sans-serif; }
body { background-color: var(--bg-main); color: var(--text-main); display: flex; overflow: hidden; font-size: 14px; -webkit-font-smoothing: antialiased; }

/* Боковое меню */
/* ФИКС: flex-shrink: 0 не даст меню сжиматься */
.sidebar { width: 260px; height: 100%; background: var(--bg-panel); display: flex; flex-direction: column; border-right: 1px solid var(--border); transition: transform 0.3s ease; z-index: 50; flex-shrink: 0; }
.sidebar-logo { height: 70px; padding: 0 24px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.logo-icon { width: 36px; height: 36px; background: linear-gradient(135deg, #6366f1, #8b5cf6); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fff; }
.logo-text { display: flex; flex-direction: column; }
.logo-title { font-weight: 700; font-size: 15px; color: #fff; letter-spacing: 0.5px; line-height: 1.2; }
.logo-subtitle { font-size: 10px; color: var(--text-muted); font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }

/* ФИКС: Центральная часть со скроллом */
.nav-menu { padding: 24px 16px; list-style: none; flex: 1 1 auto; overflow-y: auto; }
.btn-compose { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; background: var(--primary); color: #fff; padding: 12px; border-radius: 8px; text-decoration: none; font-weight: 500; font-size: 14px; margin-bottom: 24px; transition: 0.2s; }
.btn-compose:hover { background: var(--primary-hover); }
.nav-menu li { margin-bottom: 4px; }
.nav-menu li a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; color: var(--text-muted); text-decoration: none; border-radius: 8px; font-weight: 500; font-size: 14px; transition: 0.2s; }
.nav-menu li a i { font-size: 20px; }
.nav-menu li a:hover { color: var(--text-main); background: rgba(255,255,255,0.03); }
.nav-menu li.active a { color: var(--primary); background: rgba(99, 102, 241, 0.1); }

/* ФИКС: Жесткая фиксация футера (flex-shrink: 0) */
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--bg-panel); }
.logout-btn { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: var(--text-muted); text-decoration: none; font-weight: 500; border-radius: 8px; transition: 0.2s; }
.logout-btn:hover { color: var(--danger); background: rgba(244, 63, 94, 0.1); }

/* Оверлей для мобильных */
.sidebar-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 40; display: none; opacity: 0; transition: 0.3s; backdrop-filter: blur(2px); }
.sidebar-overlay.show { display: block; opacity: 1; }

/* Основная область */
.main-area { flex: 1 1 auto; display: flex; flex-direction: column; overflow: hidden; position: relative; height: 100%; }
.topbar { height: 70px; flex-shrink: 0; background: var(--bg-main); border-bottom: 1px solid var(--border); padding: 0 30px; display: flex; align-items: center; justify-content: space-between; z-index: 30; }
.topbar-left { display: flex; align-items: center; gap: 16px; }
.menu-toggle { background: transparent; border: none; color: var(--text-main); font-size: 24px; cursor: pointer; display: none; padding: 4px; }
.page-title { font-size: 18px; font-weight: 600; color: #fff; }
.user-badge { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--text-muted); font-size: 13px; }
.user-badge i { font-size: 20px; color: var(--primary); }

.content { padding: 30px; overflow-y: auto; flex: 1 1 auto; }

/* Панель и Таблица */
.panel { background: var(--bg-panel); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.table-responsive { overflow-x: auto; }
.mail-table { width: 100%; border-collapse: collapse; min-width: 700px; }
.mail-table th, .mail-table td { padding: 16px 24px; text-align: left; border-bottom: 1px solid var(--border); }
.mail-table th { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; padding-top: 20px; padding-bottom: 20px; }
.mail-table tr:hover td { background: rgba(255,255,255,0.02); cursor: pointer; }
.mail-table tr:last-child td { border-bottom: none; }
.mail-table .subject-col { color: #fff; font-weight: 500; font-size: 14px; }
.mail-table .from-col { color: var(--text-muted); font-size: 13px; }

/* Кнопки */
.btn { display: inline-flex; align-items: center; gap: 8px; background: transparent; color: var(--text-main); border: 1px solid var(--border); padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; text-decoration: none; transition: 0.2s; }
.btn:hover { background: rgba(255,255,255,0.05); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-icon { color: var(--text-muted); background: transparent; padding: 8px; border-radius: 6px; font-size: 18px; transition: 0.2s; text-decoration: none; display: inline-flex; }
.btn-icon:hover { color: var(--danger); background: rgba(244, 63, 94, 0.1); }

/* Формы */
.form-group { margin-bottom: 24px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; color: var(--text-muted); font-size: 13px; }
.form-control { width: 100%; padding: 14px 16px; background: var(--bg-main); border: 1px solid var(--border); border-radius: 8px; color: #fff; font-size: 14px; outline: none; transition: 0.2s; }
.form-control:focus { border-color: var(--primary); }

/* Чтение письма */
.read-header { border-bottom: 1px solid var(--border); padding-bottom: 24px; margin-bottom: 24px; display: flex; justify-content: space-between; align-items: flex-start; }
.read-title { color: #fff; font-size: 20px; font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.read-meta { color: var(--text-muted); font-size: 13px; }
.mail-reader-frame { width: 100%; min-height: 500px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.text-body { font-size: 14px; color: var(--text-main); background: var(--bg-main); padding: 24px; border-radius: 8px; line-height: 1.6; }

/* Уведомления */
.alert { padding: 16px; border-radius: 8px; margin-bottom: 24px; display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 500; }
.alert-success { background: rgba(16, 185, 129, 0.1); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.2); }
.alert-error { background: rgba(244, 63, 94, 0.1); color: var(--danger); border: 1px solid rgba(244, 63, 94, 0.2); }

/* Авторизация */
.auth-box { background: var(--bg-panel); padding: 40px; border-radius: 16px; border: 1px solid var(--border); width: 100%; max-width: 400px; margin: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }

/* Адаптивность */
@media (max-width: 768px) {
    .menu-toggle { display: block; }
    .sidebar { position: fixed; top: 0; bottom: 0; left: 0; transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .topbar { padding: 0 16px; }
    .content { padding: 16px; }
    .panel { border-radius: 8px; }
    .mail-table th, .mail-table td { padding: 12px 16px; }
    .read-header { flex-direction: column; gap: 16px; }
}

/* Стили для массовых действий */
.custom-checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
.bulk-toolbar { display: none; padding: 12px 24px; background: rgba(99, 102, 241, 0.08); border-bottom: 1px solid var(--border); align-items: center; justify-content: space-between; animation: slideDown 0.2s ease-out; }
.bulk-toolbar.active { display: flex; }
.bulk-toolbar-info { color: var(--primary); font-weight: 500; font-size: 14px; display: flex; align-items: center; gap: 8px; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Стили страницы настроек */
.settings-card { background: var(--bg-main); border: 1px solid var(--border); border-radius: 8px; padding: 24px; margin-bottom: 24px; }
.settings-card h4 { color: #fff; font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.settings-card p { color: var(--text-muted); font-size: 13px; line-height: 1.5; margin-bottom: 20px; }

/* Кастомное модальное окно (Smart Confirm) */
.custom-modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); z-index: 9999; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; backdrop-filter: blur(3px); }
.custom-modal-overlay.show { opacity: 1; pointer-events: auto; }
.custom-modal-box { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 16px; padding: 32px; width: 90%; max-width: 420px; box-shadow: 0 20px 40px rgba(0,0,0,0.5); transform: scale(0.95) translateY(10px); transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.custom-modal-overlay.show .custom-modal-box { transform: scale(1) translateY(0); }
.custom-modal-icon { width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; margin-bottom: 20px; background: rgba(99, 102, 241, 0.1); color: var(--primary); }
.custom-modal-icon.warning { background: rgba(244, 63, 94, 0.1); color: var(--danger); }
.custom-modal-title { color: #fff; font-size: 18px; font-weight: 600; margin-bottom: 12px; line-height: 1.3; }
.custom-modal-text { color: var(--text-muted); font-size: 14px; line-height: 1.6; margin-bottom: 30px; }
.custom-modal-actions { display: flex; justify-content: flex-end; gap: 12px; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #e11d48; border-color: #e11d48; box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3); }

/* Стили профиля */
.user-badge { cursor: pointer; transition: 0.2s; user-select: none; }
.user-badge:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--primary); }
.user-avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }

/* ========================================= */
/* ПЛАВНЫЕ АНИМАЦИИ И УЛУЧШЕНИЕ СТАБИЛЬНОСТИ */
/* ========================================= */

html { scroll-behavior: smooth; }

/* Анимация появления контента */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.content, .auth-box { 
    animation: fadeSlideUp 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; 
}

/* Анимация появления уведомлений */
@keyframes alertPop {
    0% { opacity: 0; transform: scale(0.96); }
    100% { opacity: 1; transform: scale(1); }
}
.alert { 
    animation: alertPop 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; 
}

/* Физический эффект продавливания при клике */
.btn:active, 
.nav-menu li a:active, 
.logout-btn:active, 
.user-badge:active { 
    transform: scale(0.95); 
    transition: transform 0.1s; 
}

/* Плавная подсветка строк таблицы */
.mail-table tr { 
    transition: background-color 0.15s ease-in-out; 
}

/* Кастомные премиальные скроллбары (для Webkit-браузеров) */
::-webkit-scrollbar { 
    width: 6px; 
    height: 6px; 
}
::-webkit-scrollbar-track { 
    background: transparent; 
}
::-webkit-scrollbar-thumb { 
    background: var(--border); 
    border-radius: 4px; 
}
::-webkit-scrollbar-thumb:hover { 
    background: var(--text-muted); 
}

/* Стили для непрочитанных писем */
.mail-table tr.unread td { background: rgba(99, 102, 241, 0.06); }
.mail-table tr.unread td:first-child { border-left: 3px solid var(--primary); padding-left: 17px; }
.mail-table tr.unread td.subject-col { font-weight: 600; color: #fff; }
.mail-table tr.unread td.from-col { font-weight: 600; color: #e2e8f0; }

/* Счетчик в боковом меню */
.unread-badge { background: var(--primary); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 12px; margin-left: auto; font-weight: 600; box-shadow: 0 2px 5px rgba(99,102,241,0.3); }
