/* ============================================================================
   DREAM BOT BUILDER — v2 UI (2026)
   A modern, mobile-first dark design system inspired by Material 3 +
   Telegram bot dashboards. Purple accent, rounded cards, horizontal pill
   tabs, responsive phone / tablet / desktop.
   ============================================================================ */

/* -------- Design tokens -------- */
:root {
    /* Surfaces */
    --bg:            #07070c;
    --bg-2:          #0d0d15;
    --surface:       #12121b;
    --surface-2:     #171722;
    --surface-3:     #1e1e2c;
    --elevated:      #1a1a26;

    /* Borders */
    --border:        rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.14);
    --divider:       rgba(255,255,255,0.05);

    /* Text */
    --text:          #f4f4f8;
    --text-muted:    #a0a0b3;
    --text-dim:      #6c6c82;

    /* Accents */
    --primary:       #8b5cf6;      /* violet-500 */
    --primary-2:     #7c3aed;      /* violet-600 */
    --primary-3:     #6d28d9;      /* violet-700 */
    --primary-soft:  rgba(139,92,246,0.14);
    --primary-glow:  rgba(139,92,246,0.35);

    --success:       #22c55e;
    --success-soft:  rgba(34,197,94,0.14);
    --danger:        #ef4444;
    --danger-soft:   rgba(239,68,68,0.12);
    --warn:          #f59e0b;
    --warn-soft:     rgba(245,158,11,0.14);
    --info:          #3b82f6;
    --info-soft:     rgba(59,130,246,0.14);

    /* Gradients */
    --grad-primary:  linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    --grad-primary-h:linear-gradient(135deg, #a78bfa 0%, #7c3aed 100%);
    --grad-danger:   linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    --grad-success:  linear-gradient(135deg, #22c55e 0%, #15803d 100%);
    --grad-surface:  linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));

    /* Radius */
    --r-sm: 8px;
    --r:    12px;
    --r-md: 14px;
    --r-lg: 18px;
    --r-xl: 22px;
    --r-pill: 999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow:    0 4px 16px rgba(0,0,0,0.35);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.55);
    --shadow-glow: 0 8px 32px rgba(139,92,246,0.35);

    /* Typography */
    --font:      'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;

    /* Motion */
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    --dur:  180ms;
}

/* Back-compat token aliases (older templates still reference these) */
:root {
    --gold: var(--primary);
    --gold-dark: var(--primary-2);
    --black: var(--text);
    --gray-dark: var(--text-muted);
    --white: var(--surface);
    --gray: var(--bg);
    --red: var(--danger);
    --green: var(--success);
    --blue: var(--info);
    --amber: var(--warn);
    --font-display: var(--font);
    --shadow-hover: var(--shadow-lg);
    --transition: all var(--dur) var(--ease);
}

/* -------- Reset -------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
main { flex: 1; width: 100%; }
main > .container { padding-top: 1rem; padding-bottom: 3rem; }

img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; transition: color var(--dur) var(--ease); }
a:hover { color: #a78bfa; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

::selection { background: var(--primary-soft); color: var(--text); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2a2a3c; }

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1.2;
}
h1 { font-size: clamp(1.6rem, 3.5vw, 2.25rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }
.mono, code, pre, .bot-id, .api-token { font-family: var(--font-mono); }
.highlight { color: var(--primary); font-weight: 700; }
small, .small { font-size: 0.82rem; color: var(--text-muted); }
.text-muted { color: var(--text-muted) !important; }
.text-danger { color: var(--danger) !important; }

/* Layout container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}
@media (min-width: 768px) { .container { padding: 0 24px; } }

/* ============================================================================
   NAVBAR
   ============================================================================ */
.navbar {
    background: rgba(7,7,12,0.85);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--divider);
    position: sticky; top: 0; z-index: 900;
    padding: 10px 0;
}
.navbar .container { display: flex; align-items: center; gap: 12px; }

.navbar-brand {
    display: inline-flex; align-items: center; gap: 10px;
    color: var(--text); font-weight: 700; font-size: 1.05rem;
    text-decoration: none; letter-spacing: -0.01em;
}
.navbar-brand:hover { color: var(--text); }
.navbar-logo {
    width: 34px; height: 34px; border-radius: 10px; object-fit: cover;
    box-shadow: 0 2px 8px rgba(139,92,246,0.35);
    background: var(--surface-2);
}

/* Right-side icons area */
.navbar-toggler {
    margin-left: auto;
    width: 40px; height: 40px; border-radius: 12px;
    background: var(--surface); border: 1px solid var(--border);
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text); cursor: pointer; padding: 0;
    transition: var(--transition);
}
.navbar-toggler:hover { background: var(--surface-2); border-color: var(--border-strong); }
.navbar-toggler:focus { box-shadow: 0 0 0 3px var(--primary-soft); outline: none; }
.navbar-toggler-icon {
    width: 20px; height: 20px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f4f4f8' stroke-width='2.2' stroke-linecap='round'><line x1='4' y1='7' x2='20' y2='7'/><line x1='4' y1='12' x2='20' y2='12'/><line x1='4' y1='17' x2='20' y2='17'/></svg>");
    background-repeat: no-repeat; background-position: center; background-size: contain;
    display: inline-block;
}

/* Collapse menu (mobile) */
.navbar-collapse {
    flex-basis: 100%;
}
.navbar-nav {
    list-style: none; display: flex; flex-direction: column;
    gap: 4px; padding: 12px 0 4px; margin: 0;
}
.nav-item { display: block; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border-radius: var(--r);
    color: var(--text-muted); font-weight: 500;
    transition: var(--transition);
}
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link i { width: 20px; text-align: center; color: var(--primary); }
.nav-link.btn-nav-primary,
.btn-nav-primary {
    background: var(--grad-primary);
    color: #fff !important;
    box-shadow: var(--shadow-glow);
}
.btn-nav-primary i { color: #fff; }
.btn-nav-primary:hover { background: var(--grad-primary-h); }

/* Dropdown */
.dropdown-menu {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 6px;
    box-shadow: var(--shadow-lg);
    color: var(--text);
    min-width: 200px;
}
.dropdown-item {
    color: var(--text); padding: 10px 12px; border-radius: 8px;
    display: flex; align-items: center; gap: 10px;
    font-size: 0.9rem;
}
.dropdown-item:hover, .dropdown-item:focus {
    background: var(--surface-3); color: var(--text);
}
.dropdown-item i { width: 18px; color: var(--primary); }
.dropdown-divider { border-color: var(--border); margin: 4px 0; }

/* Desktop navbar */
@media (min-width: 992px) {
    .navbar-toggler { display: none; }
    .navbar-collapse { display: flex !important; flex-basis: auto; margin-left: auto; }
    .navbar-nav { flex-direction: row; align-items: center; padding: 0; }
    .nav-link { padding: 8px 14px; font-size: 0.92rem; }
}

/* ============================================================================
   BANNERS (impersonation, verify-email)
   ============================================================================ */
.impersonation-banner, .verify-banner {
    padding: 10px 16px; text-align: center; font-size: 0.9rem; font-weight: 500;
    display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
}
.impersonation-banner { background: var(--warn-soft); color: #fbbf24; border-bottom: 1px solid var(--warn); }
.verify-banner { background: var(--info-soft); color: #93c5fd; border-bottom: 1px solid var(--info); }
.impersonation-banner .btn, .verify-banner .btn {
    padding: 4px 10px; font-size: 0.8rem; background: rgba(0,0,0,0.35);
    color: inherit; border: 1px solid rgba(255,255,255,0.2); border-radius: 8px;
}

/* ============================================================================
   FLASH MESSAGES + TOASTS
   ============================================================================ */
.flash-message {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; margin: 12px 0; border-radius: var(--r);
    background: var(--surface-2); border: 1px solid var(--border);
    font-size: 0.92rem;
}
.flash-message i { font-size: 1.1rem; }
.flash-success { border-color: var(--success); color: var(--success); background: var(--success-soft); }
.flash-danger  { border-color: var(--danger);  color: var(--danger);  background: var(--danger-soft); }
.flash-info    { border-color: var(--info);    color: var(--info);    background: var(--info-soft); }
.flash-warning { border-color: var(--warn);    color: var(--warn);    background: var(--warn-soft); }

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; font-family: var(--font); font-weight: 600; font-size: 0.9rem;
    border-radius: var(--r); border: 1px solid transparent; cursor: pointer;
    transition: var(--transition); line-height: 1; text-decoration: none;
    background: var(--surface-2); color: var(--text);
    white-space: nowrap;
}
.btn:hover { background: var(--surface-3); color: var(--text); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-sm { padding: 6px 10px; font-size: 0.8rem; border-radius: 8px; }
.btn i { line-height: 1; }

.btn-primary, .btn-save, .btn-add-bot, .btn-manage {
    background: var(--grad-primary); color: #fff; border: none;
    box-shadow: var(--shadow-glow);
}
.btn-primary:hover, .btn-save:hover, .btn-add-bot:hover, .btn-manage:hover {
    background: var(--grad-primary-h); color: #fff; box-shadow: 0 12px 40px var(--primary-glow);
}

.btn-secondary { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-strong); }

.btn-edit { background: var(--surface-2); border: 1px solid var(--primary); color: var(--primary); }
.btn-edit:hover { background: var(--primary-soft); color: #fff; }

.btn-start { background: var(--grad-success); color: #fff; border: none; }
.btn-start:hover { color: #fff; filter: brightness(1.1); }

.btn-stop, .btn-delete, .btn-danger {
    background: var(--grad-danger); color: #fff; border: none;
}
.btn-stop:hover, .btn-delete:hover, .btn-danger:hover { color: #fff; filter: brightness(1.1); }

.btn-back {
    background: var(--surface); color: var(--text-muted); border: 1px solid var(--border);
}
.btn-back:hover { background: var(--surface-2); color: var(--text); }

.btn-recovery {
    background: transparent; border: 1px dashed var(--border-strong); color: var(--text-muted);
}
.btn-recovery:hover { color: var(--text); border-color: var(--primary); }

/* Bootstrap overrides for close & basic bg-* on badges */
.btn-close {
    filter: invert(1) grayscale(1) brightness(1.5); opacity: 0.7;
}
.btn-close:hover { opacity: 1; }

/* ============================================================================
   CARDS / PANELS (shared)
   ============================================================================ */
.card, .command-editor, .settings-block, .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

/* Named form label used on many screens */
.settings-label,
.field-label {
    display: block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px;
}

/* ============================================================================
   FORMS
   ============================================================================ */
.form-group { margin-bottom: 14px; }
.form-group label, form label {
    display: block; font-size: 0.85rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: 8px;
}
.form-control, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], textarea, select {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 14px;
    border-radius: var(--r);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}
.form-control.mono, input.mono, textarea.mono { font-family: var(--font-mono); font-size: 0.88rem; }
.form-control:focus, input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
    background: var(--surface);
}
.form-control::placeholder { color: var(--text-dim); }
textarea.form-control { resize: vertical; min-height: 96px; }

/* Input group: input + button in a row */
.settings-value-row {
    display: flex; gap: 8px; align-items: stretch;
}
.settings-value-row .form-control { flex: 1; min-width: 0; }
.settings-block { margin-bottom: 14px; }
.settings-block .settings-value-row .btn { align-self: stretch; }

/* Danger zone card */
.danger-zone {
    border-color: rgba(239,68,68,0.35);
    background: linear-gradient(180deg, rgba(239,68,68,0.05), rgba(239,68,68,0));
}
.danger-zone .settings-label { color: var(--danger); }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
    position: absolute; inset: 0; background: var(--surface-3); border-radius: 999px;
    transition: var(--transition); cursor: pointer;
}
.switch-slider::before {
    content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px;
    background: #fff; border-radius: 50%; transition: var(--transition);
}
.switch input:checked + .switch-slider { background: var(--grad-primary); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }

/* ============================================================================
   BADGES
   ============================================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: var(--r-pill);
    font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
    background: var(--surface-2); color: var(--text-muted);
    border: 1px solid var(--border);
}
.badge.mono { font-family: var(--font-mono); }
.bg-warning { background: var(--warn-soft) !important; color: var(--warn) !important; border-color: transparent; }
.bg-success { background: var(--success-soft) !important; color: var(--success) !important; border-color: transparent; }
.bg-danger  { background: var(--danger-soft) !important;  color: var(--danger) !important;  border-color: transparent; }
.bg-secondary { background: var(--surface-3) !important;  color: var(--text-muted) !important; border-color: transparent; }

/* Status pill (bot cards) */
.bot-status {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: var(--r-pill);
    font-size: 0.72rem; font-weight: 600;
    background: var(--surface-3); color: var(--text-muted);
    text-transform: capitalize;
}
.bot-status.working { background: var(--success-soft); color: var(--success); }
.bot-status.stopped { background: var(--danger-soft);  color: var(--danger); }
.bot-status.needs_token { background: var(--warn-soft); color: var(--warn); }

.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; }
.status-dot.working { background: var(--success); box-shadow: 0 0 10px var(--success); }
.status-dot.stopped { background: var(--danger); }
.status-dot.needs-token { background: var(--warn); }

/* ============================================================================
   HERO / LANDING (index)
   ============================================================================ */
.hero-section {
    padding: 3rem 0 2rem;
    text-align: center;
    position: relative;
}
.hero-title {
    font-size: clamp(2rem, 6vw, 3.4rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #fff 0%, #a78bfa 100%);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}
.hero-subtitle {
    font-size: clamp(1rem, 2.5vw, 1.15rem);
    color: var(--text-muted); max-width: 640px; margin: 0 auto 2rem;
}
.hero-cta { display: inline-flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.hero-cta .btn { padding: 14px 24px; font-size: 1rem; border-radius: var(--r-md); }

/* Feature grid on landing */
.features-grid, .steps-grid {
    display: grid; gap: 14px;
    grid-template-columns: 1fr;
    margin-top: 2rem;
}
@media (min-width: 640px) { .features-grid, .steps-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 992px) { .features-grid, .steps-grid { grid-template-columns: repeat(3, 1fr); } }

.feature-card, .step-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
    padding: 22px; transition: var(--transition);
}
.feature-card:hover, .step-card:hover {
    border-color: var(--primary); transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(139,92,246,0.12);
}
.feature-icon, .step-icon {
    width: 44px; height: 44px; border-radius: 12px;
    background: var(--primary-soft); color: var(--primary);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.2rem; margin-bottom: 12px;
}
.feature-title, .step-title { font-size: 1.05rem; margin-bottom: 6px; }
.feature-desc, .step-desc { color: var(--text-muted); font-size: 0.9rem; }

/* Section headings */
.section-header { text-align: center; margin: 3rem 0 1.5rem; }
.section-title { font-size: clamp(1.5rem, 4vw, 2rem); margin-bottom: 0.5rem; }
.section-subtitle { color: var(--text-muted); }

/* CTA panel */
.cta-panel {
    background: var(--grad-primary); border-radius: var(--r-xl);
    padding: 2.5rem 1.5rem; text-align: center; color: #fff;
    box-shadow: var(--shadow-glow); margin: 3rem 0 1rem;
}
.cta-panel .cta-title { color: #fff; margin-bottom: 0.5rem; }
.cta-panel .btn { background: #fff; color: var(--primary-3); border: none; margin-top: 1rem; }
.cta-panel .btn:hover { background: #f3f4f6; color: var(--primary-3); }

/* ============================================================================
   DASHBOARD
   ============================================================================ */
.dashboard-page, .editor-page { padding: 1rem 0 2rem; }

.dashboard-header, .editor-header {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    margin-bottom: 1.25rem;
}
.dashboard-header .row, .editor-header .row { width: 100%; margin: 0; }
.dashboard-title, .editor-title {
    font-size: clamp(1.3rem, 4vw, 1.8rem);
    display: flex; align-items: center; gap: 10px; margin-bottom: 4px;
}
.dashboard-title i, .editor-title i { color: var(--primary); }
.dashboard-welcome { color: var(--text-muted); font-size: 0.9rem; }

.bot-info { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* Stats grid */
.stats-grid, .stat-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
    margin-bottom: 1.25rem;
}
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
    padding: 14px; display: flex; align-items: center; gap: 12px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg);
}
.stat-icon {
    width: 40px; height: 40px; border-radius: 10px;
    background: var(--primary-soft); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem; flex-shrink: 0;
}
.stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-number, .stat-value { font-size: 1.3rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* Recovery */
.recovery-section { margin: 1rem 0; }

/* Section header inside dashboard */
.section-header-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    flex-wrap: wrap; margin-bottom: 12px;
}
.section-header-bar .section-title { font-size: 1rem; margin: 0; display: flex; align-items: center; gap: 8px; }
.section-header-bar .section-title i { color: var(--primary); }
.bot-count {
    font-size: 0.75rem; color: var(--text-muted);
    background: var(--surface-2); padding: 4px 10px; border-radius: var(--r-pill);
    border: 1px solid var(--border);
}
.layout-toggle {
    display: inline-flex; background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--r); overflow: hidden;
}
.layout-btn {
    background: transparent; border: none; color: var(--text-muted);
    padding: 6px 10px; cursor: pointer; transition: var(--transition);
}
.layout-btn:hover { color: var(--text); }
.layout-btn.active { background: var(--primary-soft); color: var(--primary); }

/* Bot cards / list */
.bot-grid {
    display: grid; grid-template-columns: 1fr; gap: 12px;
}
@media (min-width: 720px) { .bot-grid:not(.list) { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1080px) { .bot-grid:not(.list) { grid-template-columns: repeat(3, 1fr); } }
.bot-grid.list { grid-template-columns: 1fr; }

.bot-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 14px;
    transition: var(--transition);
    display: flex; flex-direction: column; gap: 12px;
}
.bot-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.bot-card.pinned { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary-soft) inset; }
.pin-ribbon {
    position: absolute; top: 10px; right: 10px;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 0.7rem;
}

.bot-card-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.bot-avatar {
    width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.bot-card-titles { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.bot-name, .bot-card-name { font-size: 0.98rem; font-weight: 700; color: var(--text); truncate: ellipsis;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-id-small { font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-mono);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bot-card-stats {
    display: flex; gap: 14px; flex-wrap: wrap;
    font-size: 0.78rem; color: var(--text-muted);
    padding-top: 10px; border-top: 1px solid var(--divider);
}
.bot-card-stats i { color: var(--primary); margin-right: 4px; }

.bot-card-actions {
    display: flex; gap: 8px; align-items: center; padding-top: 4px;
}
.btn-manage { flex: 1; padding: 10px; }
.btn-manage i { margin-right: 6px; }

.btn-more {
    width: 40px; height: 40px; padding: 0; flex-shrink: 0;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
}
.btn-more:hover { color: var(--text); background: var(--surface-3); }
.bot-card-more { position: relative; }
.bot-card-menu {
    display: none; position: absolute; right: 0; top: calc(100% + 6px);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--r); box-shadow: var(--shadow-lg);
    min-width: 180px; padding: 6px; z-index: 30;
}
.bot-card-menu.open { display: block; }
.bot-card-menu button {
    display: flex; align-items: center; gap: 10px;
    width: 100%; background: transparent; border: none; color: var(--text);
    padding: 10px; border-radius: 8px; cursor: pointer; font-size: 0.88rem;
    text-align: left;
}
.bot-card-menu button:hover { background: var(--surface-3); }
.bot-card-menu button i { width: 16px; color: var(--primary); }
.bot-card-menu button.text-danger i { color: var(--danger); }

/* Empty state */
.empty-state {
    text-align: center; padding: 3rem 1rem;
    background: var(--surface); border: 1px dashed var(--border-strong);
    border-radius: var(--r-lg);
}
.empty-state i { font-size: 2.5rem; color: var(--primary); margin-bottom: 1rem; }
.empty-state h4 { margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-muted); margin-bottom: 1rem; }

/* ============================================================================
   EDITOR (bot-editor.html, admin.html)
   Horizontal scrollable pill tabs — matches the screenshot exactly.
   ============================================================================ */
.editor-header { flex-direction: column; align-items: stretch; gap: 8px; }
.editor-header .row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.editor-header .col-md-8, .editor-header .col-md-4 { flex: 1 1 auto; min-width: 0; padding: 0; }
.editor-header .col-md-4 { text-align: right; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* Back-to-list "Bots" chip */
.back-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-pill); color: var(--text-muted); font-size: 0.85rem;
    text-decoration: none; margin-bottom: 12px; width: fit-content;
}
.back-chip:hover { color: var(--text); border-color: var(--border-strong); }

/* Pill tab bar */
.editor-tabs {
    display: flex; gap: 6px; overflow-x: auto; scroll-behavior: smooth;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-pill); padding: 6px; margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.editor-tabs::-webkit-scrollbar { display: none; }
.editor-tab-btn {
    flex: 0 0 auto;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    background: transparent; border: none; color: var(--text-muted);
    font-family: var(--font); font-weight: 600; font-size: 0.88rem;
    border-radius: var(--r-pill); cursor: pointer; white-space: nowrap;
    transition: var(--transition);
}
.editor-tab-btn i { font-size: 0.95rem; }
.editor-tab-btn:hover { color: var(--text); background: var(--surface-2); }
.editor-tab-btn.active {
    background: var(--grad-primary); color: #fff;
    box-shadow: 0 4px 16px rgba(139,92,246,0.4);
}
.editor-tab-btn.active i { color: #fff; }

/* Tab panels */
.editor-tab-panel { display: none; animation: fadeIn 0.25s var(--ease); }
.editor-tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Panel empty */
.panel-empty {
    padding: 2.5rem 1rem; text-align: center; color: var(--text-muted);
    background: var(--surface); border: 1px dashed var(--border);
    border-radius: var(--r-lg);
}

/* Overview identity card */
.editor-tab-panel .command-editor {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); padding: 18px; margin-top: 12px;
}
.editor-tab-panel .command-editor p {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 8px; color: var(--text-muted); font-size: 0.9rem;
}
.editor-tab-panel .command-editor p i { color: var(--primary); width: 18px; }
.editor-tab-panel .command-editor strong { color: var(--text); }

/* Big start/stop hero button (matches Telebot Creator's purple gradient Start Bot) */
.editor-tab-panel .start-bot,
.editor-tab-panel .stop-bot {
    padding: 16px; font-size: 1rem; border-radius: var(--r-lg);
    justify-content: center; box-shadow: var(--shadow-glow);
}

/* ============================================================================
   COMMAND LIST — matches screenshot: card per command with visible name pill
   on top and a full-width "Edit TPY" button below with pen + trash icons.
   ============================================================================ */
.command-list-toolbar {
    display: flex; gap: 8px; align-items: center;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); padding: 8px;
    margin-bottom: 12px;
}
.command-list-toolbar .form-control {
    flex: 1; background: transparent; border: none; padding: 8px 10px;
}
.command-list-toolbar .form-control:focus { box-shadow: none; background: transparent; }
.command-list-toolbar .btn { flex-shrink: 0; }

#command-list { display: grid; gap: 10px; }

.command-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 12px;
    display: grid;
    gap: 10px;
}
.command-row > code {
    display: inline-flex; align-items: center;
    background: var(--primary-soft); color: var(--primary);
    padding: 6px 12px; border-radius: 8px;
    font-family: var(--font-mono); font-size: 0.85rem; font-weight: 600;
    width: fit-content; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
    border: 1px solid rgba(139,92,246,0.25);
}
.command-row-actions {
    display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: stretch;
}
.command-row-actions .edit-command-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--surface-2); border: 1px solid var(--border);
    color: #60a5fa; padding: 10px; border-radius: var(--r);
    font-weight: 600; font-size: 0.88rem; text-decoration: none;
    transition: var(--transition);
}
.command-row-actions .edit-command-btn:hover {
    background: var(--info-soft); border-color: var(--info); color: #93c5fd;
}
.command-row-actions .edit-command-btn i { color: #60a5fa; }

/* Icon buttons (edit/delete on right) */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; padding: 0; flex-shrink: 0;
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text-muted); border-radius: var(--r); cursor: pointer;
    transition: var(--transition); text-decoration: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.icon-btn-danger { color: var(--danger); border-color: rgba(239,68,68,0.35); }
.icon-btn-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ============================================================================
   COMMAND EDITOR (advanced modal-style page)
   ============================================================================ */
.command-editor-page { padding-top: 0.5rem; }
.code-editor-toolbar {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface); border: 1px solid var(--border);
    padding: 10px; border-radius: var(--r-lg);
    margin-bottom: 10px; flex-wrap: wrap;
}
.command-name-input {
    flex: 1 1 200px; min-width: 160px;
    background: var(--bg-2); border: 1px solid var(--border);
    font-family: var(--font-mono);
}
.code-editor-toolbar-actions {
    display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-left: auto;
}
#codemirror-host {
    border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden;
    background: #0a0a10;
}
.CodeMirror {
    font-family: var(--font-mono) !important;
    font-size: 14px !important;
    height: 60vh !important;
    background: #0a0a10 !important;
}

/* Function palette */
.fn-search-palette {
    position: fixed; top: 20%; left: 50%; transform: translateX(-50%);
    width: min(90vw, 520px); background: var(--surface-2);
    border: 1px solid var(--border-strong); border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg); z-index: 1000; padding: 12px;
}
.fn-search-palette input {
    width: 100%; margin-bottom: 8px;
}
#fn-search-results { max-height: 50vh; overflow-y: auto; }
#fn-search-results > div {
    padding: 10px; border-radius: 8px; cursor: pointer;
    display: flex; flex-direction: column; gap: 2px;
}
#fn-search-results > div:hover, #fn-search-results > div.active {
    background: var(--surface-3);
}
.hint-fn { color: var(--primary); font-family: var(--font-mono); font-size: 0.88rem; }
.hint-desc { color: var(--text-muted); font-size: 0.78rem; }

/* Test result */
.test-result-box {
    margin-top: 12px; padding: 14px; border-radius: var(--r-lg);
    background: var(--surface); border: 1px solid var(--border);
    font-family: var(--font-mono); font-size: 0.85rem; white-space: pre-wrap;
    max-height: 40vh; overflow-y: auto;
}

/* ============================================================================
   ADMIN PANEL sub-tabs (nested pill row)
   ============================================================================ */
.admin-subtabs { margin-bottom: 12px; }

/* Tables */
.table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    color: var(--text); font-size: 0.88rem;
}
.table thead th {
    text-align: left; font-size: 0.72rem; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600;
    padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.table tbody td { padding: 12px; border-bottom: 1px solid var(--divider); }
.table tbody tr:hover { background: var(--surface-2); }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ============================================================================
   MODALS (Bootstrap overrides)
   ============================================================================ */
.modal-content {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--r-lg); color: var(--text); box-shadow: var(--shadow-lg);
}
.modal-header { border-bottom: 1px solid var(--border); padding: 16px 18px; }
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-body { padding: 18px; }
.modal-footer { border-top: 1px solid var(--border); padding: 12px 18px; gap: 8px; }
.modal-backdrop.show { opacity: 0.7; }

/* ============================================================================
   AUTH pages (login, signup, forgot, reset)
   ============================================================================ */
.auth-wrap {
    min-height: calc(100vh - 200px);
    display: flex; align-items: center; justify-content: center; padding: 2rem 0;
}
.auth-card {
    width: 100%; max-width: 420px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-xl); padding: 28px;
    box-shadow: var(--shadow-lg);
}
.auth-header { text-align: center; margin-bottom: 1.5rem; }
.auth-header .auth-logo {
    width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 12px;
    background: var(--grad-primary); display: flex; align-items: center;
    justify-content: center; color: #fff; font-size: 1.5rem;
    box-shadow: var(--shadow-glow);
}
.auth-header h3 { margin-bottom: 6px; }
.auth-header p { color: var(--text-muted); font-size: 0.9rem; }
.auth-card .btn-primary { width: 100%; padding: 12px; }
.auth-footer {
    text-align: center; margin-top: 1rem; color: var(--text-muted); font-size: 0.9rem;
}

/* ============================================================================
   FOOTER
   ============================================================================ */
footer {
    border-top: 1px solid var(--divider);
    padding: 1.5rem 0;
    margin-top: auto;
    background: var(--bg-2);
}
.footer-grid {
    display: flex; flex-direction: column; align-items: center;
    gap: 12px; text-align: center;
}
.footer-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.footer-logo { width: 28px; height: 28px; border-radius: 8px; }
.footer-tagline { color: var(--text-muted); font-size: 0.85rem; margin-left: 6px; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.footer-links a { color: var(--text-muted); font-size: 0.88rem; display: inline-flex; align-items: center; gap: 6px; }
.footer-links a:hover { color: var(--primary); }
.footer-copy { color: var(--text-dim); font-size: 0.8rem; }
@media (min-width: 768px) {
    .footer-grid { flex-direction: row; justify-content: space-between; text-align: left; }
}

/* ============================================================================
   Helpers
   ============================================================================ */
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-block { display: block !important; }
.d-none { display: none !important; }
.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-end { justify-content: flex-end !important; }
.text-end { text-align: right !important; }
.text-center { text-align: center !important; }
.w-100 { width: 100% !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.flex-wrap { flex-wrap: wrap !important; }
.small { font-size: 0.82rem; }

/* Print / reduced motion */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* Responsive tweaks — tablet & desktop breathing room */
@media (min-width: 768px) {
    main > .container { padding-top: 1.5rem; padding-bottom: 4rem; }
    .editor-tab-btn { padding: 10px 18px; font-size: 0.92rem; }
    .command-row { padding: 14px 16px; }
    .command-row-actions { grid-template-columns: 1fr auto auto; }
}
@media (min-width: 1024px) {
    body { font-size: 15px; }
    .editor-header .row { flex-wrap: nowrap; }
}


/* ===== Sidebar navigation (dark, matches the rest of the app) ===== */
:root { --sidebar-w: 240px; --topbar-h: 56px; }
.sidebar-nav {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  display: flex; flex-direction: column; align-items: stretch;
  padding: 1rem .75rem; z-index: 1030; overflow-y: auto;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  color: var(--text);
  box-shadow: 4px 0 24px rgba(0,0,0,0.25);
}
.sidebar-nav .navbar-brand,
.sidebar-nav .navbar-brand:hover,
.sidebar-brand { color: var(--text); }
.sidebar-brand {
  display: flex; align-items: center; gap: .55rem;
  padding: .5rem .75rem 1rem;
  font-weight: 700; font-size: 1.02rem;
  border-bottom: 1px solid var(--divider);
  margin-bottom: .5rem;
}
.sidebar-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: .15rem;
}
.sidebar-list .nav-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .8rem; border-radius: var(--r);
  color: var(--text-muted);
  font-weight: 500; font-size: .92rem;
  transition: var(--transition);
}
.sidebar-list .nav-link:hover {
  background: var(--surface);
  color: var(--text);
}
.sidebar-list .nav-link i {
  width: 18px; text-align: center; color: var(--primary);
}
.sidebar-list .nav-link.btn-nav-primary,
.sidebar-list .btn-nav-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: var(--shadow-glow);
  margin-top: .25rem;
}
.sidebar-list .btn-nav-primary i { color: #fff; }
.sidebar-list .btn-nav-primary:hover {
  background: var(--grad-primary-h); color: #fff;
}
.sidebar-spacer { height: .75rem; }
main.with-sidebar { margin-left: var(--sidebar-w); }
.sidebar-backdrop { display: none; }

/* Top bar (mobile) — brand + hamburger stay visible so nothing is invisible */
.mobile-topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  z-index: 1029;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  align-items: center; gap: .6rem; padding: 0 .75rem;
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
}
.mobile-topbar .brand {
  display: inline-flex; align-items: center; gap: .5rem;
  color: var(--text); font-weight: 700; text-decoration: none;
}
.mobile-topbar .brand img { width: 28px; height: 28px; border-radius: 8px; }
.sidebar-toggle-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text);
  width: 40px; height: 40px; border-radius: 10px;
  display: none; align-items: center; justify-content: center;
  cursor: pointer;
}
.sidebar-toggle-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }

@media (max-width: 991.98px) {
  .sidebar-nav {
    transform: translateX(-100%);
    transition: transform .22s var(--ease);
  }
  body.sidebar-open .sidebar-nav { transform: translateX(0); }
  main.with-sidebar {
    margin-left: 0;
    padding-top: calc(var(--topbar-h) + .5rem);
  }
  .sidebar-toggle-btn { display: inline-flex; }
  .mobile-topbar { display: flex; }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,.55); z-index: 1020;
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
}

/* ============================================================================
   CONTRAST HARDENING — never let dark-on-dark or light-on-light happen.
   Fixes: typing in inputs showing invisible text; browser autofill turning
   fields white; native selects rendering with white bg + white text.
   ============================================================================ */
input, textarea, select, .form-control {
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--primary);
  background-color: var(--bg-2);
}
input::placeholder, textarea::placeholder, .form-control::placeholder {
  color: var(--text-dim) !important;
  -webkit-text-fill-color: var(--text-dim);
  opacity: 1;
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 1000px var(--bg-2) inset !important;
  box-shadow: 0 0 0 1000px var(--bg-2) inset !important;
  caret-color: var(--primary);
  transition: background-color 9999s ease-in-out 0s;
}
select option { background: var(--surface-2); color: var(--text); }

/* ============================================================================
   CUSTOM CONFIRM / ALERT / PROMPT — replaces native chrome popups
   ============================================================================ */
.db-modal-backdrop {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(4,4,10,0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: dbFadeIn .18s var(--ease);
}
.db-modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 420px;
  overflow: hidden;
  animation: dbPop .22s var(--ease);
}
.db-modal-head {
  display: flex; align-items: center; gap: .75rem;
  padding: 18px 20px 4px;
}
.db-modal-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 1.05rem;
}
.db-modal-icon.info    { background: var(--info-soft); color: var(--info); }
.db-modal-icon.warn    { background: var(--warn-soft); color: var(--warn); }
.db-modal-icon.danger  { background: var(--danger-soft); color: var(--danger); }
.db-modal-icon.success { background: var(--success-soft); color: var(--success); }
.db-modal-title {
  font-size: 1.05rem; font-weight: 700; color: var(--text);
  margin: 0; line-height: 1.25;
}
.db-modal-body {
  padding: 8px 20px 4px;
  color: var(--text-muted);
  font-size: .92rem; line-height: 1.5;
}
.db-modal-body input {
  width: 100%; margin-top: 12px;
}
.db-modal-body input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.db-modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px 18px;
}
.db-modal-foot .btn { min-width: 92px; }
@keyframes dbFadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes dbPop {
  from { opacity: 0; transform: translateY(8px) scale(.98) }
  to   { opacity: 1; transform: none }
}

/* ============================================================================
   ============  v3 "AURORA" ADVANCED UI LAYER — 2026 REFRESH  ================
   Pro-grade visual system: aurora background, glassmorphism, gradient borders,
   micro-interactions, scroll reveal, skeletons, Lottie slots, motion polish.
   Loaded last so it upgrades every existing component without markup churn.
   ============================================================================ */

:root {
  --primary:        #a855f7;
  --primary-2:      #7c3aed;
  --primary-3:      #5b21b6;
  --accent-cyan:    #22d3ee;
  --accent-pink:    #f472b6;
  --primary-soft:   rgba(168,92,246,.16);
  --primary-glow:   rgba(168,85,247,.45);

  --grad-primary:   linear-gradient(135deg, #a855f7 0%, #6d28d9 55%, #4c1d95 100%);
  --grad-primary-h: linear-gradient(135deg, #c084fc 0%, #7c3aed 60%, #5b21b6 100%);
  --grad-aurora:    linear-gradient(120deg, #a855f7, #22d3ee 45%, #f472b6 90%);
  --grad-glass:     linear-gradient(160deg, rgba(255,255,255,.07), rgba(255,255,255,.015));

  --glass-blur:     saturate(160%) blur(18px);
  --shadow-glow:    0 10px 40px -8px var(--primary-glow);
  --shadow-lg:      0 24px 60px -20px rgba(0,0,0,.75);
  --ease:           cubic-bezier(.22,.9,.24,1);
  --ease-spring:    cubic-bezier(.34,1.56,.64,1);
  --dur:            220ms;
}

/* ---------- Aurora / grain animated backdrop ---------- */
body { position: relative; background: var(--bg); overflow-x: hidden; }
body::before {
  content: ""; position: fixed; inset: -20vmax; z-index: -2; pointer-events: none;
  background:
    radial-gradient(38vmax 38vmax at 12% 8%,  rgba(168,85,247,.20), transparent 62%),
    radial-gradient(34vmax 34vmax at 88% 12%, rgba(34,211,238,.13), transparent 62%),
    radial-gradient(40vmax 40vmax at 60% 96%, rgba(244,114,182,.11), transparent 60%);
  filter: blur(20px);
  animation: auroraDrift 26s var(--ease) infinite alternate;
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes auroraDrift {
  0%   { transform: translate3d(0,0,0) scale(1); }
  50%  { transform: translate3d(2.5%, -2%, 0) scale(1.06); }
  100% { transform: translate3d(-2%, 2.5%, 0) scale(1.02); }
}

/* ---------- Page boot loader (Lottie) ---------- */
#app-loader {
  position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center;
  background: radial-gradient(60vmax 60vmax at 50% 40%, #14121f, var(--bg) 70%);
  transition: opacity .5s var(--ease), visibility .5s;
}
#app-loader.hidden { opacity: 0; visibility: hidden; }
#app-loader .loader-inner { display: grid; justify-items: center; gap: 10px; }
#app-loader lottie-player, #app-loader dotlottie-player { width: 160px; height: 160px; }
#app-loader .loader-word {
  font-family: var(--font); font-weight: 800; letter-spacing: .22em; text-transform: uppercase;
  font-size: .72rem; background: var(--grad-aurora); -webkit-background-clip: text;
  background-clip: text; color: transparent; animation: pulseSoft 1.6s ease-in-out infinite;
}
@keyframes pulseSoft { 0%,100% { opacity:.45 } 50% { opacity:1 } }

/* ---------- Top progress bar ---------- */
#route-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 10000;
  background: var(--grad-aurora); box-shadow: 0 0 12px var(--primary-glow);
  transition: width .3s var(--ease), opacity .4s;
}

/* ---------- Glass surfaces ---------- */
.card, .command-editor, .settings-block, .stat-card, .bot-card,
.db-modal, .feature-card, .plan-card, .panel {
  background: var(--grad-glass), rgba(18,18,27,.72) !important;
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
  position: relative; overflow: hidden;
}
.card::after, .stat-card::after, .bot-card::after, .feature-card::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.28), transparent);
  opacity: .7; pointer-events: none;
}
.card:hover, .stat-card:hover, .bot-card:hover, .feature-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong) !important;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(168,85,247,.16);
}

/* Sheen sweep on hover */
.card::before, .bot-card::before, .stat-card::before {
  content: ""; position: absolute; top: 0; left: -60%; width: 45%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.06), transparent);
  transform: skewX(-18deg); transition: left .7s var(--ease); pointer-events: none;
}
.card:hover::before, .bot-card:hover::before, .stat-card:hover::before { left: 130%; }

/* ---------- Buttons ---------- */
.btn {
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: var(--r-md); font-weight: 600; letter-spacing: .01em;
  transition: transform var(--dur) var(--ease-spring), box-shadow var(--dur) var(--ease),
              background var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.985); }
.btn-primary, .btn-save, .btn-add-bot, .btn-manage, .btn-nav-primary {
  background: var(--grad-primary) !important; border: none !important; color: #fff !important;
  box-shadow: 0 6px 22px -8px var(--primary-glow);
}
.btn-primary:hover, .btn-save:hover, .btn-add-bot:hover, .btn-manage:hover, .btn-nav-primary:hover {
  background: var(--grad-primary-h) !important;
  box-shadow: 0 12px 34px -8px var(--primary-glow);
}
/* ripple */
.btn .ripple {
  position: absolute; border-radius: 50%; transform: scale(0);
  background: rgba(255,255,255,.35); pointer-events: none;
  animation: rippleOut .6s var(--ease) forwards; z-index: 0;
}
@keyframes rippleOut { to { transform: scale(2.6); opacity: 0; } }

/* Gradient-ring CTA */
.btn-glow {
  background: var(--grad-primary); color: #fff; border: none;
  box-shadow: 0 0 0 0 var(--primary-glow); animation: haloPulse 2.6s var(--ease) infinite;
}
@keyframes haloPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(168,85,247,.42); }
  50%     { box-shadow: 0 0 0 14px rgba(168,85,247,0); }
}

/* ---------- Sidebar ---------- */
.sidebar-nav {
  background: linear-gradient(180deg, rgba(20,18,32,.92), rgba(10,10,16,.94)) !important;
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border) !important;
}
.sidebar-nav .nav-link {
  position: relative; border-radius: var(--r-md);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              transform var(--dur) var(--ease-spring);
}
.sidebar-nav .nav-link::before {
  content: ""; position: absolute; left: 0; top: 50%; height: 0; width: 3px;
  border-radius: 0 4px 4px 0; background: var(--grad-aurora);
  transform: translateY(-50%); transition: height var(--dur) var(--ease);
}
.sidebar-nav .nav-link:hover { transform: translateX(3px); background: var(--primary-soft); }
.sidebar-nav .nav-link:hover::before,
.sidebar-nav .nav-link.active::before { height: 62%; }
.sidebar-nav .nav-link.active { background: var(--primary-soft); color: #fff; }
.sidebar-nav .nav-link i { transition: transform var(--dur) var(--ease-spring); }
.sidebar-nav .nav-link:hover i { transform: scale(1.16) rotate(-6deg); color: var(--primary); }
.sidebar-brand span, .mobile-topbar .brand span {
  background: var(--grad-aurora); -webkit-background-clip: text; background-clip: text;
  color: transparent; font-weight: 800; letter-spacing: -.02em;
}
.mobile-topbar {
  background: rgba(10,10,16,.72) !important;
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border) !important;
}
.sidebar-toggle-btn { transition: transform var(--dur) var(--ease-spring); }
body.sidebar-open .sidebar-toggle-btn { transform: rotate(90deg); }
.sidebar-backdrop { -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }

/* ---------- Headings / hero ---------- */
.hero h1, .hero-title, h1.gradient, .gradient-text {
  background: var(--grad-aurora); -webkit-background-clip: text; background-clip: text;
  color: transparent; background-size: 200% 200%; animation: gradShift 8s ease infinite;
}
@keyframes gradShift { 0%,100% { background-position: 0% 50% } 50% { background-position: 100% 50% } }

/* ---------- Stats ---------- */
.stat-card .stat-value, .stat-value { font-variant-numeric: tabular-nums; }
.stat-card i { transition: transform var(--dur) var(--ease-spring); }
.stat-card:hover i { transform: translateY(-2px) scale(1.12); }

/* ---------- Status pills ---------- */
.status-pill, .badge, .bot-status {
  border-radius: var(--r-pill); font-weight: 600; letter-spacing: .01em;
}
.status-pill.running, .bot-status.running, .badge-success {
  position: relative; box-shadow: 0 0 0 0 rgba(34,197,94,.4);
  animation: livePulse 2.2s var(--ease) infinite;
}
@keyframes livePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,.35); }
  50%     { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
}

/* ---------- Inputs ---------- */
.form-control, input, select, textarea {
  border-radius: var(--r-md) !important;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              background var(--dur) var(--ease);
}
.form-control:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 4px var(--primary-soft) !important;
  outline: none !important;
}

/* ---------- Tabs / pills ---------- */
.tab, .tab-pill, .nav-pills .nav-link {
  border-radius: var(--r-pill); transition: all var(--dur) var(--ease-spring);
}
.tab.active, .tab-pill.active, .nav-pills .nav-link.active {
  background: var(--grad-primary) !important; color: #fff !important;
  box-shadow: 0 8px 24px -10px var(--primary-glow);
}

/* ---------- Tables ---------- */
table tbody tr { transition: background var(--dur) var(--ease); }
table tbody tr:hover { background: rgba(168,85,247,.06); }

/* ---------- Flash & toasts ---------- */
.flash-message, .notification {
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  animation: toastIn .45s var(--ease-spring) both;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px) scale(.96) } to { opacity: 1; transform: none } }

/* ---------- Scroll reveal ---------- */
[data-reveal] {
  opacity: 0; transform: translateY(18px);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
  will-change: opacity, transform;
}
[data-reveal].revealed { opacity: 1; transform: none; }

/* ---------- Skeleton shimmer ---------- */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.10) 37%, rgba(255,255,255,.04) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r);
}
@keyframes shimmer { 0% { background-position: 100% 0 } 100% { background-position: 0 0 } }

/* ---------- Lottie slots ---------- */
.lottie-slot { display: grid; place-items: center; }
.lottie-slot lottie-player, .lottie-slot dotlottie-player { width: 100%; max-width: 340px; }
.lottie-xs lottie-player { width: 56px; height: 56px; }

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 2.5rem 1rem; }
.empty-state .lottie-slot { margin-bottom: .5rem; }

/* ---------- Scroll to top ---------- */
#scroll-top {
  position: fixed; right: 18px; bottom: 22px; z-index: 900;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border-strong);
  background: var(--grad-primary); color: #fff; display: grid; place-items: center;
  box-shadow: var(--shadow-glow); opacity: 0; pointer-events: none;
  transform: translateY(12px) scale(.9);
  transition: all .35s var(--ease-spring);
}
#scroll-top.show { opacity: 1; pointer-events: auto; transform: none; }

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.015), rgba(0,0,0,.35));
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
footer .footer-links a { transition: transform var(--dur) var(--ease-spring), color var(--dur); }
footer .footer-links a:hover { transform: translateY(-2px); color: var(--accent-cyan); }

/* ---------- Page transition ---------- */
main.with-sidebar > .container { animation: pageIn .5s var(--ease) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }

/* ---------- Code editors ---------- */
pre, code, .CodeMirror, .code-area {
  border-radius: var(--r-md);
}

/* ---------- Mobile polish ---------- */
@media (max-width: 991.98px) {
  main > .container { padding-bottom: 4.5rem; }
  .btn { min-height: 42px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  [data-reveal] { opacity: 1 !important; transform: none !important; }
}
