/* ── Bot Factory Design System ── */

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.8);
    --bg-card-hover: rgba(31, 41, 55, 0.9);
    --border: rgba(75, 85, 99, 0.4);
    --border-accent: rgba(59, 130, 246, 0.5);

    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.2);

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --gradient-launch: linear-gradient(135deg, #3b82f6, #8b5cf6);

    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Login Screen ── */

.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
    width: 90%;
    max-width: 380px;
    text-align: center;
    backdrop-filter: blur(10px);
    animation: modalIn 0.3s ease;
}

.login-logo {
    font-size: 56px;
    margin-bottom: 8px;
}

.login-card h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.login-card .form-group {
    text-align: left;
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--radius-sm);
}

.login-card .btn-launch {
    margin-top: 8px;
}

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

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

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* ── Header ── */

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

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

.logo-icon {
    font-size: 32px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-badge.connected .status-dot {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.status-badge.disconnected .status-dot {
    background: var(--danger);
}

.status-badge.partial .status-dot {
    background: var(--warning);
    box-shadow: 0 0 6px var(--warning);
}

/* ── Tabs ── */

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 4px;
    border: 1px solid var(--border);
    overflow-x: auto;
}

.tab {
    flex: 1;
    min-width: fit-content;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    white-space: nowrap;
    font-family: var(--font);
}

.tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab.active {
    color: var(--text-primary);
    background: var(--accent);
}

.tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ── Cards ── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    backdrop-filter: blur(10px);
}

.card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

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

.card-header h2 {
    margin-bottom: 0;
}

.card-actions {
    display: flex;
    gap: 8px;
}

/* ── Buttons ── */

.btn {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

.btn-launch {
    width: 100%;
    padding: 14px;
    background: var(--gradient-launch);
    color: white;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font);
}

.btn-launch:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-launch:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Forms ── */

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

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.required {
    color: var(--danger);
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    transition: var(--transition);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.hint a {
    color: var(--accent);
}

.hint code {
    background: rgba(59, 130, 246, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
    font-size: 12px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
}

.checkbox-row:hover {
    color: var(--text-primary);
}

.format-examples {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.format-examples code {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.25);
    padding: 4px 10px;
    border-radius: 6px;
    color: var(--accent);
    font-size: 12px;
    font-family: monospace;
}

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

.code-input {
    font-size: 28px !important;
    text-align: center;
    letter-spacing: 8px;
    font-weight: 700;
    padding: 14px !important;
}

/* ── Empty states ── */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

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

/* ── Bot List ── */

.bot-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bot-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.bot-item-info h4 {
    font-size: 14px;
    font-weight: 600;
}

.bot-item-info p {
    font-size: 12px;
    color: var(--text-muted);
}

.bot-item-actions {
    display: flex;
    gap: 6px;
}

/* ── Account Cards ── */

.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.account-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.account-card:hover {
    border-color: var(--border-accent);
}

.account-info {
    flex: 1;
}

.account-info .account-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.account-info .account-phone {
    font-size: 13px;
    color: var(--text-secondary);
}

.account-info .account-stats {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.account-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-tag {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-tag.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.status-tag.code_required,
.status-tag.auth_pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.status-tag.flood_wait {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.status-tag.paused {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}

.status-tag.banned,
.status-tag.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.status-tag.password_required {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
}

.account-actions {
    display: flex;
    gap: 6px;
    margin-left: 12px;
}

.auth-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
}

/* ── Jobs List ── */

.jobs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.job-card {
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.job-card:hover {
    border-color: var(--border-accent);
}

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

.job-header h4 {
    font-size: 14px;
    font-weight: 600;
}

.job-progress {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.job-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.job-progress-bar.completed {
    background: var(--success);
}

.job-progress-bar.failed {
    background: var(--danger);
}

.job-stats {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Results within job detail ── */

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 13px;
}

.result-item .token {
    font-family: monospace;
    font-size: 11px;
    color: var(--text-muted);
    word-break: break-all;
}

/* ── Check Results ── */

.results-list {
    margin-top: 16px;
}

.check-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    margin-bottom: 6px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.check-result.available {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.check-result.taken {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ── Modals ── */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

.modal-wide {
    max-width: 640px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ── Toasts ── */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: white;
    animation: slideIn 0.3s ease;
    min-width: 250px;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.info {
    background: var(--accent);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ── Responsive ── */

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .card-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .card-actions {
        width: 100%;
    }

    .card-actions .btn {
        flex: 1;
        justify-content: center;
    }

    .account-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .account-status {
        width: 100%;
        justify-content: space-between;
    }

    .tabs {
        overflow-x: auto;
    }

    .tab {
        font-size: 12px;
        padding: 8px 10px;
    }
}

/* ── Type Selector ── */

.type-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.type-btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font);
    transition: var(--transition);
}

.type-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.type-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ── Channel Result Tags ── */

.tag-channel {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.tag-group {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.tag-supergroup {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}
/* Streams grid */
.streams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}

.stream-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.15s;
}

.stream-card:hover {
    border-color: var(--accent);
}

.stream-card .stream-title {
    font-weight: 600;
    font-size: 1.05em;
    margin: 0;
}

.stream-card .stream-meta {
    color: var(--text-muted);
    font-size: 0.82em;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.stream-card .stream-meta span {
    background: rgba(255, 255, 255, 0.04);
    padding: 2px 8px;
    border-radius: 4px;
}

.stream-card .stream-progress {
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    overflow: hidden;
}

.stream-card .stream-progress-bar {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
}

.stream-card .stream-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.stream-status-idle { color: var(--text-muted); }
.stream-status-running { color: #22c55e; }
.stream-status-completed { color: #3b82f6; }
.stream-status-failed { color: #ef4444; }
.stream-status-pending { color: #f59e0b; }

/* Job type filter pills */
.job-type-pill {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}
.job-type-pill:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}
.job-type-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.job-type-pill .count {
    background: rgba(255, 255, 255, 0.15);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.85em;
    font-weight: 600;
}
.job-type-pill:not(.active) .count {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}
