/* Kito Dashboard — Dark Theme, Mobile-First */

:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #1a1a24;
    --bg-card: #22222e;
    --bg-card-hover: #2a2a38;
    --bg-input: #1a1a24;
    --border: #2e2e3e;
    --border-light: #3a3a4e;

    --text-primary: #e8e8f0;
    --text-secondary: #9898b0;
    --text-muted: #6868808;

    --accent: #7c5cfc;
    --accent-hover: #9078ff;
    --accent-glow: rgba(124, 92, 252, 0.15);

    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --info: #60a5fa;

    --hot: #f87171;
    --warm: #fbbf24;
    --cold: #60a5fa;

    --sidebar-width: 240px;
    --topbar-height: 56px;
    --bottom-nav-height: 60px;
    --radius: 12px;
    --radius-sm: 8px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 200ms ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* === Typography === */
h1, h2, h3 { font-weight: 600; }
h2 { font-size: 1.5rem; }
a { color: var(--accent); text-decoration: none; }
.text-muted { color: var(--text-secondary); font-size: 0.875rem; }

/* === Topbar (mobile) === */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-height);
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
}
.topbar__menu {
    background: none; border: none; color: var(--text-primary); cursor: pointer;
    padding: 4px;
}
.topbar__title { font-size: 1.125rem; font-weight: 600; flex: 1; }
.topbar__user { display: flex; align-items: center; gap: 8px; }
.topbar__name { font-size: 0.875rem; color: var(--text-secondary); }

/* === Sidebar === */
.sidebar {
    position: fixed;
    top: 0; left: -var(--sidebar-width); bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform var(--transition);
    transform: translateX(0);
    left: calc(-1 * var(--sidebar-width));
}
.sidebar.open { transform: translateX(var(--sidebar-width)); }

.sidebar__logo {
    display: flex; align-items: center; gap: 10px;
    padding: 20px; font-size: 1.25rem; font-weight: 700;
}
.logo-icon { font-size: 1.5rem; }

.sidebar__nav { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.sidebar__footer { padding: 8px; border-top: 1px solid var(--border); }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 0.9rem; font-weight: 500;
    transition: all var(--transition);
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active {
    background: var(--accent-glow); color: var(--accent);
}
.nav-item--logout:hover { color: var(--danger); }

.sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 150; display: none;
}
.sidebar-overlay.active { display: block; }

/* === Content === */
.content {
    margin-top: var(--topbar-height);
    padding: 20px 16px;
    padding-bottom: calc(var(--bottom-nav-height) + 20px);
    min-height: calc(100vh - var(--topbar-height));
}

/* === Bottom Nav (mobile) === */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-around;
    z-index: 100;
}
.bottom-nav__item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: var(--text-secondary); font-size: 0.65rem; font-weight: 500;
    padding: 6px 0;
    transition: color var(--transition);
}
.bottom-nav__item.active { color: var(--accent); }
.bottom-nav__item:hover { color: var(--text-primary); }

/* === Page header === */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}

/* === Stat cards === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex; flex-direction: column; gap: 4px;
    transition: all var(--transition);
    backdrop-filter: blur(12px);
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat-card__icon { font-size: 1.5rem; }
.stat-card__value { font-size: 1.75rem; font-weight: 700; }
.stat-card__label { font-size: 0.8rem; color: var(--text-secondary); }

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px; border-radius: var(--radius-sm);
    font-family: var(--font); font-size: 0.875rem; font-weight: 500;
    border: none; cursor: pointer; transition: all var(--transition);
    white-space: nowrap;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn--ghost:hover { border-color: var(--text-primary); color: var(--text-primary); }
.btn--success { background: var(--success); color: #000; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--sm { padding: 6px 10px; font-size: 0.75rem; border-radius: 6px; }

/* === Filter bar === */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-btn {
    padding: 8px 14px; border-radius: 20px; border: 1px solid var(--border);
    background: transparent; color: var(--text-secondary); font-family: var(--font);
    font-size: 0.8rem; cursor: pointer; transition: all var(--transition);
}
.filter-btn.active, .filter-btn:hover {
    background: var(--accent-glow); border-color: var(--accent); color: var(--accent);
}

/* === Tables === */
.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%; border-collapse: collapse; font-size: 0.875rem;
}
.data-table th {
    text-align: left; padding: 10px 12px; color: var(--text-secondary);
    font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 12px; border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.data-table tr:hover td { background: var(--bg-card); }
.actions { display: flex; gap: 6px; }

/* === Badges === */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 0.75rem; font-weight: 500;
}
.badge--owner { background: var(--accent-glow); color: var(--accent); }
.badge--manager { background: rgba(96,165,250,0.15); color: var(--info); }
.badge--open { background: rgba(96,165,250,0.15); color: var(--info); }
.badge--done { background: rgba(52,211,153,0.15); color: var(--success); }
.badge--deleted { background: rgba(248,113,113,0.15); color: var(--danger); }
.badge--success { background: rgba(52,211,153,0.15); color: var(--success); }
.badge--danger { background: rgba(248,113,113,0.15); color: var(--danger); }
.badge--hot { background: rgba(248,113,113,0.15); color: var(--hot); }
.badge--warm { background: rgba(251,191,36,0.15); color: var(--warm); }
.badge--cold { background: rgba(96,165,250,0.15); color: var(--cold); }

/* === Form === */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block; margin-bottom: 6px;
    font-size: 0.8rem; color: var(--text-secondary); font-weight: 500;
}
.form-input {
    width: 100%; padding: 10px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-input);
    color: var(--text-primary); font-family: var(--font); font-size: 0.9rem;
    transition: border-color var(--transition);
}
.form-input:focus { outline: none; border-color: var(--accent); }
select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; }

/* === Modal === */
.modal {
    position: fixed; inset: 0; z-index: 300;
    display: none; align-items: center; justify-content: center;
}
.modal.active { display: flex; }
.modal__backdrop {
    position: absolute; inset: 0; background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}
.modal__content {
    position: relative; background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; width: 90%; max-width: 440px;
    max-height: 85vh; overflow-y: auto;
    animation: modalIn 200ms ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.modal__content h3 { margin-bottom: 16px; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* === Empty state === */
.empty-state {
    text-align: center; padding: 40px 20px; color: var(--text-secondary);
    font-size: 1rem;
}

/* === Chat === */
.chat-container {
    display: flex; flex-direction: column;
    height: calc(100vh - var(--topbar-height) - var(--bottom-nav-height) - 40px);
}
.chat-messages {
    flex: 1; overflow-y: auto; padding: 16px 0;
    display: flex; flex-direction: column; gap: 12px;
}
.chat-welcome {
    text-align: center; margin: auto; color: var(--text-secondary);
}
.chat-welcome__icon { font-size: 3rem; margin-bottom: 12px; }
.chat-msg { display: flex; }
.chat-msg--user { justify-content: flex-end; }
.chat-msg--bot { justify-content: flex-start; }
.chat-msg__bubble {
    max-width: 80%; padding: 10px 16px; border-radius: 16px;
    font-size: 0.9rem; line-height: 1.4;
}
.chat-msg--user .chat-msg__bubble {
    background: var(--accent); color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg--bot .chat-msg__bubble {
    background: var(--bg-card); color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.chat-input {
    display: flex; gap: 10px; padding: 12px 0;
    border-top: 1px solid var(--border);
}
.chat-input .form-input { flex: 1; }
.chat-send { padding: 10px 14px; }

/* === Settings === */
.settings-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
}
.settings-card code {
    background: var(--bg-input); padding: 2px 6px; border-radius: 4px;
    font-size: 0.85rem;
}

/* === Login === */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--bg-primary);
}
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 40px 32px; text-align: center;
    backdrop-filter: blur(16px);
}
.login-logo { font-size: 3.5rem; margin-bottom: 12px; }
.login-title { font-size: 1.5rem; margin-bottom: 8px; }
.login-subtitle { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 24px; }
.login-divider { height: 1px; background: var(--border); margin: 20px 0; }
.login-hint { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 20px; }
.login-telegram { display: flex; justify-content: center; margin-bottom: 20px; }
.login-footer { color: var(--text-muted); font-size: 0.75rem; }

/* === Desktop === */
@media (min-width: 768px) {
    .topbar { display: none; }
    .bottom-nav { display: none; }
    .sidebar-overlay { display: none !important; }

    .sidebar {
        left: 0;
        transform: none;
    }

    .content {
        margin-top: 0;
        margin-left: var(--sidebar-width);
        padding: 28px 32px;
        padding-bottom: 32px;
    }

    .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
    .stat-card { padding: 20px; }
    .stat-card__value { font-size: 2rem; }

    .chat-container {
        height: calc(100vh - 56px);
    }
}

@media (min-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}
