/* ============================================================ */
/* ========== THEME V2 — Clean Architectural UI (Fast) ======== */
/* ============================================================ */

:root,
[data-theme="light"] {
    --bg: #ffffff;
    --bg-soft: #f8fafc;
    --bg-hover: #f1f5f9;
    --border: rgba(15, 23, 42, 0.08);
    --border-soft: rgba(15, 23, 42, 0.05);
    --text: #0f172a;
    --text-soft: #475569;
    --text-mute: #94a3b8;
    --bubble-in: #ffffff;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 6px 20px -4px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 48px -12px rgba(15, 23, 42, 0.16);
    --chat-bg: transparent;
    --grid-line: rgba(15, 23, 42, 0.07);
}

[data-theme="dark"] {
    --bg: #161922;
    --bg-soft: #0f1117;
    --bg-hover: #1e222e;
    --border: rgba(255, 255, 255, 0.08);
    --border-soft: rgba(255, 255, 255, 0.04);
    --text: #f8fafc;
    --text-soft: #94a3b8;
    --text-mute: #64748b;
    --bubble-in: #1e222e;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, 0.6);
    --chat-bg: transparent;
    --grid-line: rgba(255, 255, 255, 0.06);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    letter-spacing: -0.01em;
    background-color: var(--bg-soft);
}

/* --- Насыщенный живой фон (Vivid Mesh + Орбиты + Элементы) --- */
#bg-live-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at 15% 15%, var(--primary-soft) 0%, transparent 45%),
        radial-gradient(circle at 85% 85%, var(--primary-soft) 0%, transparent 50%),
        var(--bg-soft);
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(55px);
    will-change: transform;
    animation: orbFloat 16s ease-in-out infinite alternate;
}

.orb-1 {
    width: 520px;
    height: 520px;
    background: var(--primary);
    opacity: 0.22;
    top: -140px;
    right: -100px;
}

.orb-2 {
    width: 440px;
    height: 440px;
    background: var(--primary);
    opacity: 0.26;
    bottom: -120px;
    left: 12%;
    animation-delay: -6s;
}

.orb-3 {
    width: 340px;
    height: 340px;
    background: var(--primary);
    opacity: 0.16;
    top: 38%;
    left: 52%;
    animation-delay: -11s;
}

@keyframes orbFloat {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    100% { transform: translate3d(45px, -35px, 0) scale(1.12); }
}

.bg-orbits {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 1;
}

.bg-orbits circle {
    stroke-opacity: 0.32 !important;
    stroke-width: 1.8 !important;
}

.bg-float-item {
    position: absolute;
    will-change: transform;
    animation: bgFloatSlow linear infinite;
    user-select: none;
}

.bg-float-pill {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    background: var(--bg);
    border: 1.5px solid var(--primary);
    padding: 4px 10px;
    border-radius: 10px;
    box-shadow: 0 6px 18px var(--primary-soft);
    opacity: 0.88;
    letter-spacing: 0.04em;
}

.bg-float-sq {
    border: 2.5px solid var(--primary);
    border-radius: 7px;
    opacity: 0.55;
    box-shadow: 0 0 14px var(--primary-soft);
}

.bg-float-sq.filled {
    background: var(--primary);
    border: none;
    opacity: 0.32;
}

.bg-float-diamond {
    border: 2px solid var(--primary);
    border-radius: 5px;
    opacity: 0.5;
    transform: rotate(45deg);
    box-shadow: 0 0 12px var(--primary-soft);
}

@keyframes bgFloatSlow {
    0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
    50%  { transform: translate3d(24px, -38px, 0) rotate(14deg); }
    100% { transform: translate3d(0, 0, 0) rotate(0deg); }
}

.app, .auth-wrap {
    position: relative;
    z-index: 1;
    background: transparent !important;
}

/* --- Логотип по примеру ART-Bitrix24 --- */
.brand-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-soft);
}

.brand-logo-card {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px 5px 8px;
    border-radius: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.brand-logo-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.brand-logo-svg {
    width: 34px;
    height: 28px;
    flex-shrink: 0;
}

.brand-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-title {
    font-weight: 700;
    font-size: 13.5px;
    color: var(--text);
    letter-spacing: -0.02em;
}

.brand-title span { color: var(--primary); }

.brand-sub {
    font-size: 9.5px;
    font-weight: 600;
    color: var(--text-mute);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.brand-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Сайдбар --- */
.sidebar {
    background: var(--bg);
    border-right: 1px solid var(--border);
}

.sidebar-header {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-soft);
}

.me {
    padding: 6px 10px 6px 6px;
    border-radius: 12px;
    transition: background 0.15s ease;
}
.me:hover { background: var(--bg-hover); }

.search-wrap, .sidebar-search { padding: 10px 14px; }

#chat-search {
    border-radius: 12px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    padding: 9px 14px;
    font-size: 13.5px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#chat-search:focus {
    background: var(--bg);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.chat-list { padding: 4px 8px; }

.chat-item {
    border-radius: 12px;
    margin-bottom: 3px;
    padding: 10px 12px;
    transition: background 0.15s ease;
    border: 1px solid transparent;
}
.chat-item:hover { background: var(--bg-hover); }

.chat-item.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 6px 18px -4px rgba(37, 99, 235, 0.35);
}
.chat-item.active .chat-item-time,
.chat-item.active .chat-item-preview,
.chat-item.active .msg-prefix {
    color: rgba(255, 255, 255, 0.85);
}

.chat-item-time {
    font-variant-numeric: tabular-nums;
    font-size: 11.5px;
}

.badge {
    border-radius: 999px;
    font-weight: 600;
    font-size: 11px;
    padding: 2px 7px;
}

/* --- Основная область чата --- */
.main {
    background: transparent !important;
    background-image: none !important;
}

.chat-top {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 10px 18px;
}

.pinned-bar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

/* --- Пузыри сообщений --- */
.msg {
    border-radius: 16px;
    padding: 9px 14px 7px;
    box-shadow: var(--shadow-sm);
    line-height: 1.45;
}

.msg.other {
    background: var(--bubble-in);
    border: 1px solid var(--border);
}

.msg.own {
    background: var(--bubble-out);
    border: 1px solid transparent;
}

.msg-meta {
    font-variant-numeric: tabular-nums;
    opacity: 0.75;
}

/* --- Панель ввода --- */
.composer {
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 10px 16px;
    gap: 8px;
}

#msg-input {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 14px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#msg-input:focus {
    background: var(--bg);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.icon-btn { border-radius: 10px; transition: background 0.15s ease; }

.send-btn {
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--primary-soft);
    transition: filter 0.15s ease;
}
.send-btn:hover { filter: brightness(1.08); }

/* --- Модальные окна и карточки --- */
.modal-card, .auth-card {
    background: var(--bg);
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.emoji-panel, .sticker-panel, .quick-reply-popup, .mention-suggest, .notif-toast {
    background: var(--bg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    border-radius: 16px;
}

.jump-down {
    background: var(--bg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

/* --- Фикс слоёв: фон строго под интерфейсом --- */
#bg-live-layer {
    z-index: 0 !important;
    pointer-events: none !important;
}
.app, .auth-wrap {
    position: relative !important;
    z-index: 2 !important;
}
.modal {
    z-index: 200 !important;
}

/* --- Окно аудиозвонка --- */
.call-card {
    text-align: center;
    width: 92%;
    max-width: 340px;
    margin: auto;
    padding: 28px 24px;
}
.call-avatar-ring {
    width: 68px;
    height: 68px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}
.call-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}
#call-mute.active {
    background: var(--danger);
    color: #fff;
}

/* --- Фикс окна звонка --- */
.call-card {
    width: 92% !important;
    max-width: 380px !important;
    padding: 28px 20px !important;
    overflow: hidden !important;
}
.call-card .hidden {
    display: none !important;
}
.call-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
    justify-content: center !important;
    margin-top: 20px !important;
}
.call-actions .btn {
    flex: 1 1 auto;
    min-width: 110px;
}
