/* ═══════════════════════════════════════════════════════════════
   TG BOT PLATFORM — DESIGN SYSTEM
   ═══════════════════════════════════════════════════════════════ */
:root {
    --bg-deepest: #0a0e1a;
    --bg-deep: #0f1629;
    --bg-card: #151d35;
    --bg-card-hover: #1a2440;
    --bg-surface: #1e2a4a;
    --bg-input: #121a30;
    --border: rgba(99, 130, 255, 0.12);
    --border-hover: rgba(99, 130, 255, 0.25);
    --text: #e2e8f0;
    --text-muted: #64748b;
    --text-dim: #475569;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-glow: rgba(99, 102, 241, 0.35);
    --accent: #06b6d4;
    --accent-glow: rgba(6, 182, 212, 0.3);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --sidebar-w: 240px;
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: var(--font);
    background: var(--bg-deepest);
    color: var(--text);
    overflow-x: hidden;
}
::selection { background: var(--primary); color: #fff; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.3); border-radius: 3px; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ═══════════════════════════════════════════════════════════════
   AUTH SCREEN
   ═══════════════════════════════════════════════════════════════ */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.auth-bg {
    position: fixed; inset: 0;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(6,182,212,0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(139,92,246,0.08) 0%, transparent 50%),
        var(--bg-deepest);
    z-index: 0;
}
.auth-card {
    position: relative; z-index: 1;
    background: rgba(21, 29, 53, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 25px 60px rgba(0,0,0,0.4), 0 0 80px var(--primary-glow);
    animation: authFadeIn 0.6s ease-out;
}
@keyframes authFadeIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: none; }
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo-icon { font-size: 48px; display: block; margin-bottom: 12px; filter: drop-shadow(0 0 20px var(--primary-glow)); }
.auth-logo h1 { font-size: 22px; font-weight: 800; background: linear-gradient(135deg, #818cf8, #06b6d4); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.auth-logo p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg-input); border-radius: 10px; padding: 4px; margin-bottom: 24px; }
.auth-tab { flex: 1; padding: 10px; border: none; background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 600; border-radius: 8px; cursor: pointer; transition: var(--transition); font-family: var(--font); }
.auth-tab.active { background: var(--primary); color: #fff; box-shadow: 0 4px 14px var(--primary-glow); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-error { color: var(--danger); font-size: 12px; text-align: center; min-height: 16px; }

/* ═══════════════════════════════════════════════════════════════
   INPUTS & BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.input-group input, .input-group select, .input-group textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    transition: var(--transition);
    outline: none;
    width: 100%;
}
.input-group input:focus, .input-group select:focus, .input-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.input-group textarea { resize: vertical; min-height: 80px; }
.input-group select { cursor: pointer; }

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px var(--primary-glow); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 6px 20px var(--primary-glow); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--primary); color: var(--text); background: rgba(99,102,241,0.08); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.btn-success:hover { background: rgba(16,185,129,0.2); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { background: transparent; border: none; font-size: 18px; cursor: pointer; padding: 4px; border-radius: 6px; transition: var(--transition); }
.btn-icon:hover { background: rgba(255,255,255,0.08); }

/* ═══════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════ */
.app { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-deep);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: var(--transition);
}
.sidebar-logo {
    padding: 20px;
    font-size: 18px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #818cf8, #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    border-bottom: 1px solid var(--border);
}
.sidebar-logo span { -webkit-text-fill-color: initial; font-size: 24px; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
}
.nav-link:hover { background: rgba(99,102,241,0.08); color: var(--text); }
.nav-link.active { background: rgba(99,102,241,0.15); color: #818cf8; font-weight: 600; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.sidebar-user {
    padding: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-user-info { display: flex; align-items: center; gap: 10px; }
.sidebar-user-avatar { font-size: 24px; }
.sidebar-user-name { font-size: 13px; font-weight: 600; }
.sidebar-user-role { font-size: 11px; color: var(--text-muted); }

/* MAIN */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 28px 32px;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 70% 10%, rgba(99,102,241,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 30% 90%, rgba(6,182,212,0.04) 0%, transparent 50%),
        var(--bg-deepest);
}
.page { display: none; animation: pageIn 0.3s ease-out; }
.page.active { display: block; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }

.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}
.page-header h2 { font-size: 24px; font-weight: 800; }
.page-header p { color: var(--text-muted); font-size: 14px; flex: 1; }

/* STATS GRID */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0;
    transition: var(--transition);
}
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.stat-card:hover::before { opacity: 1; }
.stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 800; background: linear-gradient(135deg, #fff, #94a3b8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* CARDS GRID */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    position: relative;
}
.card:hover { border-color: var(--border-hover); box-shadow: 0 8px 30px rgba(0,0,0,0.2); }
.card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-avatar { font-size: 32px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: rgba(99,102,241,0.12); border-radius: 12px; flex-shrink: 0; }
.card-title { font-size: 16px; font-weight: 700; }
.card-subtitle { font-size: 12px; color: var(--text-muted); }
.card-body { margin-bottom: 16px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; }
.card-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-active { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.badge-inactive { background: rgba(100,116,139,0.12); color: var(--text-muted); border: 1px solid rgba(100,116,139,0.2); }
.badge-type { background: rgba(99,102,241,0.12); color: #818cf8; border: 1px solid rgba(99,102,241,0.2); }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 14px; }
.card-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }

/* Linked bots on channel card */
.linked-bots { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.linked-bot {
    display: flex; align-items: center; gap: 8px;
    background: rgba(99,102,241,0.06);
    border: 1px solid rgba(99,102,241,0.1);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 12px;
}
.linked-bot .bot-emoji { font-size: 18px; }
.linked-bot .bot-name { flex: 1; font-weight: 600; }

/* LOG LIST */
.log-list { display: flex; flex-direction: column; gap: 6px; }
.log-entry {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: var(--transition);
}
.log-entry:hover { border-color: var(--border-hover); }
.log-time { color: var(--text-dim); font-size: 11px; font-family: monospace; min-width: 70px; }
.log-action { font-weight: 600; min-width: 80px; }
.log-details { flex: 1; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-bot { color: var(--accent); font-weight: 600; min-width: 100px; }

/* SETTINGS */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 20px; }
.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.settings-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.settings-card > p { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; line-height: 1.5; }
.settings-card .input-group { margin-bottom: 12px; flex-direction: row; align-items: center; gap: 10px; }
.settings-card .input-group input { flex: 1; }
.status-badge { font-size: 12px; margin-top: 8px; }

/* MODAL */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalBgIn 0.2s ease-out;
}
@keyframes modalBgIn { from { opacity: 0; } }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    width: 480px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0,0,0,0.5);
    animation: modalIn 0.25s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } }
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal .form-grid { display: flex; flex-direction: column; gap: 14px; }
.modal .btn-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* EMPTY STATE */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state p { font-size: 14px; line-height: 1.6; }

/* TOAST */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    animation: toastIn 0.3s ease-out;
    max-width: 360px;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
/* NAV SECTION TITLES */
.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    padding: 16px 14px 6px;
    margin-top: 4px;
}
.nav-section-title.admin-only { color: #f59e0b; }

/* TWO COLUMN */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.recent-section h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; color: var(--text-muted); }

/* MINI LIST (dashboard) */
.mini-list { display: flex; flex-direction: column; gap: 6px; }
.mini-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: var(--transition);
}
.mini-item:hover { border-color: var(--border-hover); }
.mini-item .mi-icon { font-size: 18px; }
.mini-item .mi-name { flex: 1; font-weight: 600; }
.mini-item .mi-meta { color: var(--text-muted); font-size: 11px; }

/* INPUT ROW */
.input-row {
    display: flex; gap: 10px; align-items: center;
}
.input-row input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: var(--transition);
}
.input-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.status-text { font-size: 12px; margin-top: 10px; }

/* ADMIN TABLE */
.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}
.data-table th {
    background: var(--bg-card);
    padding: 12px 16px;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(99,130,255,0.06);
    vertical-align: middle;
}
.data-table tr:hover td { background: rgba(99,102,241,0.04); }
.data-table .role-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}
.role-admin { background: rgba(245,158,11,0.15); color: #f59e0b; border: 1px solid rgba(245,158,11,0.2); }
.role-user { background: rgba(99,102,241,0.12); color: #818cf8; border: 1px solid rgba(99,102,241,0.2); }

/* USER DETAIL in modal */
.user-detail-section { margin-bottom: 16px; }
.user-detail-section h4 { font-size: 13px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-logo span { font-size: 20px; }
    .sidebar-logo { padding: 16px; justify-content: center; }
    .sidebar-nav .nav-link span:not(.nav-icon) { display: none; }
    .sidebar-nav .nav-section-title { display: none; }
    .sidebar-user-info div { display: none; }
    .main { margin-left: 60px; padding: 20px 16px; }
    .cards-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .two-col { grid-template-columns: 1fr; }
}
