/* BotFabric admin — тёмная тема в духе Telegram Desktop */
:root {
    --tg-bg: #0e1621;
    --tg-sidebar: #17212b;
    --tg-border: rgba(255, 255, 255, 0.06);
    --tg-text: #f5f5f7;
    --tg-muted: #8a9aa7;
    --tg-accent: #2aabee;
    --tg-bubble-in: #182533;
    --tg-bubble-out: #2b5278;
    --tg-hover: rgba(42, 171, 238, 0.12);
}

html, body {
    min-height: 100%;
    background: var(--tg-bg) !important;
    color: var(--tg-text) !important;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

.bf-shell {
    display: flex;
    min-height: 100vh;
}

.bf-sidebar {
    width: 268px;
    min-width: 268px;
    background: var(--tg-sidebar);
    border-right: 1px solid var(--tg-border);
    padding: 1rem 0.75rem;
}

.bf-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.6rem 1.25rem;
    text-decoration: none;
    color: var(--tg-text) !important;
    font-weight: 700;
    font-size: 1.05rem;
}

.bf-brand-badge {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--tg-accent), #5288c1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 4px 14px rgba(42, 171, 238, 0.35);
}

.bf-nav .nav-link {
    color: var(--tg-muted) !important;
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 2px;
    font-weight: 500;
    font-size: 0.92rem;
}

.bf-nav .nav-link:hover {
    background: var(--tg-hover);
    color: var(--tg-text) !important;
}

.bf-nav .nav-link.active {
    background: rgba(42, 171, 238, 0.18);
    color: var(--tg-accent) !important;
}

.bf-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.bf-topbar {
    background: var(--tg-sidebar);
    border-bottom: 1px solid var(--tg-border);
    padding: 0.65rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.bf-content {
    padding: 1.25rem 1.5rem;
    flex: 1;
}

.bf-card {
    background: rgba(23, 33, 43, 0.65);
    border: 1px solid var(--tg-border);
    border-radius: 12px;
    padding: 1.25rem;
}

.table-dark {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    --bs-table-hover-bg: var(--tg-hover);
    color: var(--tg-text) !important;
}

.form-control, .form-select {
    background: #0d131a !important;
    border: 1px solid var(--tg-border) !important;
    color: var(--tg-text) !important;
    border-radius: 10px !important;
}

.btn-primary {
    background: var(--tg-accent) !important;
    border: none !important;
}

/* ——— Telegram-like chat ——— */
.tg-chat-app {
    display: flex;
    height: calc(100vh - 120px);
    min-height: 480px;
    border: 1px solid var(--tg-border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--tg-bg);
}

.tg-chat-list {
    width: 320px;
    min-width: 280px;
    background: var(--tg-sidebar);
    border-right: 1px solid var(--tg-border);
    overflow-y: auto;
}

.tg-chat-list a {
    display: block;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--tg-border);
    color: inherit;
    text-decoration: none;
}

.tg-chat-list a:hover { background: var(--tg-hover); }
.tg-chat-list a.active {
    background: rgba(42, 171, 238, 0.12);
    border-left: 3px solid var(--tg-accent);
}

.tg-chat-title { font-weight: 600; font-size: 0.95rem; }
.tg-chat-meta { font-size: 0.75rem; color: var(--tg-muted); margin-top: 0.2rem; }
.tg-chat-preview {
    font-size: 0.8rem;
    color: var(--tg-muted);
    margin-top: 0.35rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.tg-chat-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tg-chat-header {
    padding: 0.85rem 1.1rem;
    background: var(--tg-sidebar);
    border-bottom: 1px solid var(--tg-border);
    font-weight: 600;
}

.tg-chat-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='%2318212b' fill-opacity='0.35'%3E%3Cpath d='M0 0h40v40H0zM40 40h40v40H40z'/%3E%3C/g%3E%3C/svg%3E");
}

.tg-msg-row {
    display: flex;
    margin-bottom: 0.65rem;
}
.tg-msg-row.in { justify-content: flex-start; }
.tg-msg-row.out { justify-content: flex-end; }

.tg-bubble {
    max-width: 78%;
    padding: 0.45rem 0.75rem 0.35rem;
    border-radius: 12px;
    font-size: 0.92rem;
    line-height: 1.45;
    word-break: break-word;
}
.tg-bubble.in {
    background: var(--tg-bubble-in);
    border-bottom-left-radius: 4px;
}
.tg-bubble.out {
    background: var(--tg-bubble-out);
    border-bottom-right-radius: 4px;
}

.tg-bubble .who {
    font-size: 0.72rem;
    color: var(--tg-accent);
    margin-bottom: 0.2rem;
    font-weight: 600;
}
.tg-bubble .tm {
    font-size: 0.68rem;
    color: var(--tg-muted);
    text-align: right;
    margin-top: 0.25rem;
}

.login-tg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 30% 20%, rgba(42, 171, 238, 0.2), transparent 50%), var(--tg-bg);
}
.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    border-radius: 16px;
    background: var(--tg-sidebar);
    border: 1px solid var(--tg-border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.stat-tile {
    background: var(--tg-sidebar);
    border: 1px solid var(--tg-border);
    border-radius: 12px;
    padding: 1rem 1.15rem;
}
.stat-tile .num { font-size: 1.75rem; font-weight: 700; color: var(--tg-accent); }
