/* =====================================================
   BuildStart Constructor — Premium Design System
   ===================================================== */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    /* Telegram Theme Variables */
    --tg-bg:           var(--tg-theme-bg-color, #0f0f13);
    --tg-text:         var(--tg-theme-text-color, #ffffff);
    --tg-hint:         var(--tg-theme-hint-color, #8a8a9a);
    --tg-link:         var(--tg-theme-link-color, #6c8bef);
    --tg-btn:          var(--tg-theme-button-color, #6c8bef);
    --tg-btn-text:     var(--tg-theme-button-text-color, #ffffff);
    --tg-secondary-bg: var(--tg-theme-secondary_bg_color, #1a1a24);

    /* Design tokens */
    --accent:          #6c8bef;
    --accent-glow:     rgba(108, 139, 239, 0.25);
    --accent-soft:     rgba(108, 139, 239, 0.12);
    --gold:            #f5c842;
    --gold-glow:       rgba(245, 200, 66, 0.2);
    --danger:          #ff4a6a;
    --success:         #34d399;

    --surface-1:       rgba(255,255,255,0.04);
    --surface-2:       rgba(255,255,255,0.07);
    --surface-hover:   rgba(255,255,255,0.1);
    --border:          rgba(255,255,255,0.08);
    --border-accent:   rgba(108,139,239,0.4);

    --radius-sm:  8px;
    --radius-md:  14px;
    --radius-lg:  20px;
    --radius-xl:  28px;

    --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
    --shadow-md:  0 8px 24px rgba(0,0,0,0.4);
    --shadow-lg:  0 16px 48px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 32px var(--accent-glow);

    --nav-height: 68px;
    --header-height: 64px;
    --font: 'Inter', -apple-system, sans-serif;
    --ease: cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ===================== RESET ===================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0; padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html { height: 100%; }

body {
    font-family: var(--font);
    background: var(--tg-bg);
    color: var(--tg-text);
    height: 100%;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* =================== LAYOUT =================== */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 600px;
    margin: 0 auto;
}

/* =================== HEADER =================== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--tg-bg);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-shrink: 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #9b6ef0);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.balance-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

.balance-chip:active { transform: scale(0.96); }
.balance-chip .balance-icon { font-size: 13px; }
.balance-chip .balance-val { color: var(--gold); }

.lang-switch {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--tg-hint);
    transition: all 0.2s var(--ease);
}
.lang-switch:active { transform: scale(0.96); }

/* =================== MAIN SCROLL AREA =================== */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px calc(var(--nav-height) + 16px);
    -webkit-overflow-scrolling: touch;
}

/* =================== BOTTOM NAV =================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    height: var(--nav-height);
    background: rgba(15, 15, 20, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 8px 4px;
    z-index: 200;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 4px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--tg-hint);
    transition: all 0.22s var(--ease);
    border-radius: var(--radius-md);
    position: relative;
}

.nav-item .nav-icon {
    font-size: 22px;
    transition: transform 0.22s var(--ease);
}

.nav-item .nav-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.nav-item.active {
    color: var(--accent);
}

.nav-item.active .nav-icon {
    transform: translateY(-2px);
    filter: drop-shadow(0 0 8px var(--accent));
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 3px 3px;
    transition: width 0.22s var(--ease);
}

.nav-item.active::before { width: 28px; }

/* =================== VIEWS =================== */
.view {
    display: none;
    animation: slideFade 0.3s var(--ease) forwards;
}
.view.active { display: block; }

@keyframes slideFade {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =================== HERO SECTION =================== */
.hero-section {
    padding: 20px 0 8px;
    text-align: center;
}

.hero-greeting {
    font-size: 13px;
    color: var(--tg-hint);
    margin-bottom: 4px;
    letter-spacing: 0.3px;
}

.hero-name {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 16px;
}

.hero-stat {
    text-align: center;
}

.hero-stat-num {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
}

.hero-stat-label {
    font-size: 11px;
    color: var(--tg-hint);
    margin-top: 2px;
}

/* =================== CARDS =================== */
.card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    transition: all 0.2s var(--ease);
}

.card-elevated {
    background: var(--surface-2);
    box-shadow: var(--shadow-md);
}

.card + .card { margin-top: 12px; }

/* =================== BOT CARD =================== */
.bot-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    margin-bottom: 10px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.bot-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, var(--accent-soft));
    opacity: 0;
    transition: opacity 0.2s;
}

.bot-card:active::after { opacity: 1; }

.bot-avatar {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent), #9b6ef0);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.bot-info { flex: 1; min-width: 0; }

.bot-name {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bot-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
}

.bot-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent);
}

.bot-tag.premium {
    background: var(--gold-glow);
    color: var(--gold);
}

.bot-username {
    font-size: 12px;
    color: var(--tg-hint);
}

.bot-arrow {
    font-size: 16px;
    color: var(--tg-hint);
    flex-shrink: 0;
}

/* =================== EMPTY STATE =================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-icon {
    font-size: 52px;
    margin-bottom: 12px;
    filter: grayscale(0.3);
}

.empty-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.empty-sub {
    font-size: 14px;
    color: var(--tg-hint);
    line-height: 1.5;
}

/* =================== SECTION HEADER =================== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
}

/* =================== BUTTONS =================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 13px 20px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.18s var(--ease);
    font-family: var(--font);
    outline: none;
    letter-spacing: -0.1px;
    position: relative;
    overflow: hidden;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #8b6ef5);
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:active { box-shadow: 0 2px 8px var(--accent-glow); }

.btn-secondary {
    background: var(--surface-2);
    color: var(--tg-text);
    border: 1px solid var(--border);
}

.btn-danger {
    background: rgba(255, 74, 106, 0.12);
    color: var(--danger);
    border: 1px solid rgba(255, 74, 106, 0.2);
}

.btn-gold {
    background: linear-gradient(135deg, #f5c842, #e8943a);
    color: #000;
    box-shadow: 0 4px 16px var(--gold-glow);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

.btn-block { width: 100%; }

.btn-icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

.btn-back {
    background: transparent;
    color: var(--accent);
    padding: 0;
    font-size: 15px;
    font-weight: 600;
    gap: 4px;
}

/* =================== FAB =================== */
.fab {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #8b6ef5);
    border: none;
    color: white;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 6px 24px var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s var(--ease);
    z-index: 150;
}

.fab:active { transform: scale(0.92); }
.fab.hidden { opacity: 0; pointer-events: none; transform: scale(0.8) translateY(10px); }

/* =================== FORMS =================== */
.form-section { margin-bottom: 20px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--tg-hint);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--tg-text);
    font-family: var(--font);
    font-size: 15px;
    outline: none;
    transition: all 0.2s var(--ease);
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--surface-2);
}

.form-input::placeholder { color: var(--tg-hint); }

textarea.form-input {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

/* =================== SPINNER =================== */
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--surface-2);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--tg-hint);
    font-size: 14px;
}

/* =================== PAGE TITLE =================== */
.page-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--tg-hint);
    margin-bottom: 20px;
}

/* =================== GRADIENT BANNER =================== */
.premium-banner {
    background: linear-gradient(135deg, #1a1240, #0f0f13);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
}

.premium-banner::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, var(--accent-glow), transparent 70%);
}

.premium-banner-icon {
    font-size: 30px;
    margin-bottom: 10px;
}

.premium-banner-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 6px;
}

.premium-banner-desc {
    font-size: 13px;
    color: var(--tg-hint);
    line-height: 1.5;
    margin-bottom: 14px;
}

/* =================== STATUS BADGE =================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.status-badge.free {
    background: var(--surface-2);
    color: var(--tg-hint);
    border: 1px solid var(--border);
}

.status-badge.premium {
    background: var(--gold-glow);
    color: var(--gold);
    border: 1px solid rgba(245,200,66,0.3);
}

/* =================== BOT SETTINGS HEADER =================== */
.bot-settings-hero {
    background: linear-gradient(135deg, var(--surface-2), var(--surface-1));
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 22px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.bot-settings-avatar {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--accent), #9b6ef0);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    flex-shrink: 0;
    box-shadow: var(--shadow-glow);
}

.bot-settings-info { flex: 1; }

.bot-settings-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 5px;
}

/* =================== LOCK OVERLAY =================== */
.lock-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 16, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: inherit;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.lock-icon { font-size: 36px; margin-bottom: 8px; }
.lock-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.lock-desc { font-size: 13px; color: var(--tg-hint); line-height: 1.5; }

/* =================== VIDEO ITEM =================== */
.video-item {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.video-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 74, 106, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.video-item-info { flex: 1; min-width: 0; }

.video-item-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-item-code {
    font-size: 12px;
    color: var(--tg-hint);
    font-family: monospace;
}

.video-item-link {
    font-size: 12px;
    color: var(--accent);
    word-break: break-all;
    margin-top: 3px;
}

/* =================== TEMPLATE CARD =================== */
.template-card {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    padding: 18px;
    background: var(--surface-1);
    transition: all 0.2s var(--ease);
    display: flex;
    align-items: center;
    gap: 14px;
}

.template-card.selected,
.template-card:active {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.template-card-icon {
    font-size: 30px;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border-radius: 14px;
    flex-shrink: 0;
}

.template-card-title { font-size: 16px; font-weight: 700; margin-bottom: 3px; }
.template-card-desc { font-size: 13px; color: var(--tg-hint); }

.template-card-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    background: var(--success);
    color: #000;
    border-radius: 20px;
    flex-shrink: 0;
}

/* =================== MENU BUTTON EDITOR =================== */
.menu-btn-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.menu-btn-row input {
    flex: 1;
    padding: 10px 12px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--tg-text);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
}

.menu-btn-row input:focus {
    border-color: var(--accent);
}

/* =================== PROFILE PAGE =================== */
.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #9b6ef0);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin: 0 auto 12px;
    box-shadow: var(--shadow-glow);
}

.profile-name {
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 4px;
}

.profile-id {
    text-align: center;
    font-size: 13px;
    color: var(--tg-hint);
    margin-bottom: 24px;
}

.menu-list { background: var(--surface-1); border-radius: var(--radius-lg); overflow: hidden; }

.menu-list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.menu-list-item:last-child { border-bottom: none; }
.menu-list-item:active { background: var(--surface-hover); }

.menu-list-icon {
    font-size: 20px;
    width: 36px;
    text-align: center;
}

.menu-list-text { flex: 1; font-size: 15px; font-weight: 500; }
.menu-list-arrow { color: var(--tg-hint); font-size: 14px; }
.menu-list-badge {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
}

/* =================== DIVIDER =================== */
.divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

/* =================== ADD BTN =================== */
.add-row-btn {
    width: 100%;
    padding: 12px;
    background: var(--surface-1);
    border: 1px dashed var(--border-accent);
    border-radius: var(--radius-md);
    color: var(--accent);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

.add-row-btn:active {
    background: var(--accent-soft);
}

/* =================== TOAST =================== */
.toast {
    position: fixed;
    top: calc(var(--header-height) + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    z-index: 999;
    opacity: 0;
    transition: all 0.3s var(--ease);
    white-space: nowrap;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* =================== HELP SECTION =================== */
.info-block {
    background: rgba(108,139,239,0.07);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-md);
    padding: 14px;
    font-size: 13px;
    color: var(--tg-hint);
    line-height: 1.6;
    margin-bottom: 14px;
}

.info-block strong { color: var(--tg-text); }

