/* ===============================
   BotForge Mini App — Telegram Theme
   =============================== */

:root {
    --radius: 12px;
    --radius-sm: 8px;
    --gap: 12px;
    --pad: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(165deg, #3390ec 0%, #2b7cd4 40%, #1a5fb4 100%);
    background-attachment: fixed;
    color: var(--tg-theme-text-color, #000);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 70px;
    min-height: 100vh;
}

/* Loading */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 16px;
    color: rgba(255,255,255,0.8);
}

/* App */
.app {
    min-height: 100vh;
}

.screen-container {
    padding: var(--pad);
    padding-bottom: 80px;
    min-height: calc(100vh - 70px);
}

/* ===============================
   Tab Bar
   =============================== */

.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(255,255,255,0.98);
    border-top: none;
    padding: 6px 0;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    z-index: 100;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}

.tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: #aab;
    font-size: 10px;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s;
    min-width: 50px;
}

.tab.active {
    color: #3390ec;
}

.tab svg {
    width: 22px;
    height: 22px;
}

.tab-create .create-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--tg-theme-button-color, #3390ec);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.tab-create .create-btn svg {
    color: var(--tg-theme-button-text-color, #fff);
}

.tab-create span {
    margin-top: -2px;
}

/* ===============================
   Cards
   =============================== */

.card {
    background: rgba(255,255,255,0.95);
    border-radius: var(--radius);
    padding: var(--pad);
    margin-bottom: var(--gap);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    color: #1a1a2e;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
}

.card-subtitle {
    font-size: 13px;
    color: #666;
}

/* ===============================
   Badges
   =============================== */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-free { background: #e0e0e0; color: #666; }
.badge-starter { background: #fff3cd; color: #856404; }
.badge-pro { background: #cce5ff; color: #004085; }
.badge-business { background: #d4edda; color: #155724; }
.badge-running { background: #d4edda; color: #155724; }
.badge-stopped { background: #f8d7da; color: #721c24; }
.badge-error { background: #fff3cd; color: #856404; }
.badge-created { background: #e0e0e0; color: #666; }

/* ===============================
   Buttons
   =============================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    width: 100%;
}

.btn:active {
    opacity: 0.7;
}

.btn-primary {
    background: #fff;
    color: #3390ec;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.btn-secondary {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
}

.btn-danger {
    background: #dc3545;
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid rgba(255,255,255,0.6);
    color: #fff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    width: auto;
}

.btn-group {
    display: flex;
    gap: 8px;
}

.btn-group .btn {
    flex: 1;
}

/* ===============================
   Stat Boxes
   =============================== */

.stats-row {
    display: flex;
    gap: var(--gap);
}

.stat-box {
    flex: 1;
    background: rgba(255,255,255,0.95);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

.stat-running .stat-value { color: #28a745; }
.stat-stopped .stat-value { color: #dc3545; }
.stat-error .stat-value { color: #ffc107; }

/* ===============================
   Screen Header
   =============================== */

.screen-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #fff;
}

.screen-subtitle {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 16px;
}

/* ===============================
   Bot List
   =============================== */

.bot-card {
    background: rgba(255,255,255,0.95);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: opacity 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    color: #1a1a2e;
}

.bot-card:active {
    opacity: 0.7;
}

.bot-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bot-name {
    font-weight: 600;
    font-size: 15px;
}

.bot-desc {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bot-detail {
    margin-top: 12px;
    display: none;
}

.bot-card.expanded .bot-detail {
    display: block;
}

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

/* ===============================
   Chat (Constructor)
   =============================== */

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-bubble.user {
    background: rgba(255,255,255,0.95);
    color: #1a1a2e;
    margin-left: auto;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.chat-bubble.ai {
    background: rgba(255,255,255,0.2);
    color: #fff;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    backdrop-filter: blur(8px);
}

.chat-input-bar {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    border-top: 1px solid rgba(255,255,255,0.15);
}

.chat-input {
    flex: 1;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    color: #fff;
    outline: none;
    backdrop-filter: blur(8px);
}

.chat-input::placeholder {
    color: rgba(255,255,255,0.5);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
    border: none;
    color: #3390ec;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* ===============================
   Template Grid
   =============================== */

.tpl-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.tpl-card {
    background: rgba(255,255,255,0.95);
    border-radius: var(--radius);
    padding: 14px;
    cursor: pointer;
    text-align: center;
    transition: opacity 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    color: #1a1a2e;
}

.tpl-card:active {
    opacity: 0.7;
}

.tpl-icon {
    font-size: 32px;
    margin-bottom: 6px;
}

.tpl-name {
    font-size: 13px;
    font-weight: 600;
}

/* Template Detail */
.tpl-detail {
    padding: 0;
}

.tpl-detail-header {
    text-align: center;
    padding: 20px var(--pad);
}

.tpl-detail-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.tpl-detail-features {
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-line;
    color: rgba(255,255,255,0.7);
    padding: 0 var(--pad);
    margin-bottom: 16px;
}

/* ===============================
   Tariff Cards
   =============================== */

.tariff-card {
    background: rgba(255,255,255,0.95);
    border-radius: var(--radius);
    padding: var(--pad);
    margin-bottom: 12px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    color: #1a1a2e;
}

.tariff-card.selected {
    border-color: #ffc107;
    box-shadow: 0 4px 16px rgba(255,193,7,0.3);
}

.tariff-name {
    font-size: 18px;
    font-weight: 700;
}

.tariff-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--tg-theme-button-color, #3390ec);
    margin: 4px 0;
}

.tariff-price span {
    font-size: 13px;
    font-weight: 400;
    color: var(--tg-theme-hint-color, #999);
}

.tariff-features {
    font-size: 13px;
    color: #888;
    line-height: 1.5;
    margin-top: 8px;
}

/* ===============================
   Payment / QR
   =============================== */

.payment-box {
    text-align: center;
    padding: 20px;
    color: #fff;
}

.payment-box h2 {
    color: #fff;
}

.qr-container {
    margin: 16px auto;
    padding: 12px;
    background: #fff;
    border-radius: var(--radius);
    display: inline-block;
}

.qr-container canvas {
    display: block;
}

.payment-address {
    font-family: monospace;
    font-size: 12px;
    word-break: break-all;
    background: rgba(255,255,255,0.15);
    padding: 10px;
    border-radius: var(--radius-sm);
    margin: 12px 0;
    cursor: pointer;
    color: #fff;
}

.payment-timer {
    font-size: 20px;
    font-weight: 700;
    color: #ffc107;
    margin: 8px 0;
}

.payment-amount {
    font-size: 16px;
    font-weight: 600;
    margin: 8px 0;
    color: #fff;
}

/* ===============================
   Network Selector
   =============================== */

.network-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 12px 0;
}

.network-btn {
    background: rgba(255,255,255,0.95);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    color: #1a1a2e;
}

.network-btn.selected {
    border-color: #ffc107;
    box-shadow: 0 4px 12px rgba(255,193,7,0.3);
}

/* ===============================
   Support / Tickets
   =============================== */

.ticket-card {
    background: rgba(255,255,255,0.95);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    color: #1a1a2e;
}

.ticket-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.ticket-status.open { background: #28a745; }
.ticket-status.closed { background: #dc3545; }

/* ===============================
   More Menu
   =============================== */

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: rgba(255,255,255,0.95);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: opacity 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    color: #1a1a2e;
}

.menu-item:active {
    opacity: 0.7;
}

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

.menu-label {
    font-size: 15px;
    font-weight: 500;
}

/* ===============================
   Forms
   =============================== */

.form-group {
    margin-bottom: 14px;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
    color: rgba(255,255,255,0.9);
}

.form-input, .form-textarea {
    width: 100%;
    background: rgba(255,255,255,0.95);
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    color: #1a1a2e;
    outline: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

.form-input::placeholder, .form-textarea::placeholder {
    color: #999;
}

/* ===============================
   Settings
   =============================== */

.lang-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: rgba(255,255,255,0.95);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    color: #1a1a2e;
}

.lang-option.active {
    border-color: #ffc107;
    box-shadow: 0 4px 16px rgba(255,193,7,0.3);
}

/* ===============================
   Logs
   =============================== */

.logs-box {
    background: #1a1a2e;
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    padding: 12px;
    border-radius: var(--radius);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.4;
}

/* ===============================
   Empty State
   =============================== */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255,255,255,0.7);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-text {
    font-size: 14px;
    margin-bottom: 16px;
}

/* ===============================
   Utility
   =============================== */

.text-hint {
    color: rgba(255,255,255,0.6);
}

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

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

.hidden {
    display: none !important;
}
