/* KonstruktorBot - Main Styles */
:root {
    --primary: #6C5CE7;
    --primary-dark: #5A4BD1;
    --primary-light: #A29BFE;
    --secondary: #00CEC9;
    --success: #00B894;
    --warning: #FDCB6E;
    --danger: #E17055;
    --dark: #2D3436;
    --gray: #636E72;
    --gray-light: #B2BEC3;
    --gray-lighter: #DFE6E9;
    --light: #F5F6FA;
    --white: #FFFFFF;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: var(--light);
    color: var(--dark);
    line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { font-weight: 700; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 24px; border: 2px solid transparent; border-radius: var(--radius-sm);
    font-size: 15px; font-weight: 600; cursor: pointer; transition: var(--transition);
    text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-ghost { background: transparent; color: var(--gray); }
.btn-ghost:hover { background: var(--gray-lighter); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 32px; font-size: 17px; }
.btn-block { width: 100%; }
.btn-danger { background: var(--danger); color: white; }

/* ============ NAVBAR ============ */
.navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    background: rgba(255,255,255,0.95); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--gray-lighter);
    height: 64px;
}
.nav-container {
    max-width: 1200px; margin: 0 auto; padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between; height: 100%;
}
.logo {
    display: flex; align-items: center; gap: 10px;
    font-size: 20px; font-weight: 800; color: var(--dark);
}
.nav-links { display: flex; gap: 24px; }
.nav-links a { color: var(--gray); font-weight: 500; transition: var(--transition); }
.nav-links a:hover { color: var(--primary); }
.nav-right { display: flex; align-items: center; gap: 12px; }
.lang-switch { display: flex; gap: 4px; }
.lang-btn {
    padding: 4px 10px; border: 1px solid var(--gray-lighter); border-radius: 6px;
    background: white; cursor: pointer; font-size: 12px; font-weight: 600;
    transition: var(--transition);
}
.lang-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.hamburger span { display: block; width: 24px; height: 2px; background: var(--dark); margin: 5px 0; }

.user-menu { position: relative; }
.user-btn { background: none; border: none; cursor: pointer; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
}
.user-dropdown {
    position: absolute; top: 100%; right: 0; background: white; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); min-width: 160px; display: none; overflow: hidden;
}
.user-dropdown.show { display: block; }
.user-dropdown a { display: block; padding: 10px 16px; color: var(--dark); transition: var(--transition); }
.user-dropdown a:hover { background: var(--light); }

/* ============ HERO ============ */
.hero {
    padding: 140px 0 80px;
    background: linear-gradient(135deg, #6C5CE7 0%, #A29BFE 50%, #00CEC9 100%);
    color: white;
}
.hero .container { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: center; }
.hero h1 { font-size: 48px; line-height: 1.2; margin-bottom: 20px; }
.hero h1 span { color: #FFEAA7; }
.hero p { font-size: 18px; opacity: 0.9; margin-bottom: 32px; }
.hero-buttons { display: flex; gap: 16px; flex-wrap: wrap; }
.hero .btn-primary { background: white; color: var(--primary); }
.hero .btn-primary:hover { background: #FFEAA7; }
.hero .btn-outline { border-color: white; color: white; }
.hero .btn-outline:hover { background: white; color: var(--primary); }

/* Flow demo animation */
.flow-demo { display: flex; flex-direction: column; align-items: center; gap: 0; }
.demo-node {
    background: white; border-radius: var(--radius-sm); padding: 16px 28px;
    display: flex; align-items: center; gap: 12px;
    box-shadow: var(--shadow-lg); animation: fadeInUp 0.6s ease;
    min-width: 180px;
}
.demo-node:nth-child(3) { animation-delay: 0.2s; }
.demo-node:nth-child(5) { animation-delay: 0.4s; }
.node-icon { font-size: 24px; }
.node-text { font-weight: 600; color: var(--dark); }
.demo-line { width: 2px; height: 30px; background: white; opacity: 0.5; }
.demo-trigger { border-left: 4px solid var(--warning); }
.demo-message { border-left: 4px solid var(--primary); }
.demo-menu { border-left: 4px solid var(--secondary); }

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

/* ============ FEATURES ============ */
.features { padding: 80px 0; }
.features h2 { text-align: center; font-size: 36px; margin-bottom: 48px; }
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.feature-card {
    background: white; padding: 32px; border-radius: var(--radius);
    box-shadow: var(--shadow); transition: var(--transition);
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.feature-icon { font-size: 40px; margin-bottom: 16px; }
.feature-card h3 { margin-bottom: 8px; font-size: 20px; }
.feature-card p { color: var(--gray); }

/* ============ CTA ============ */
.cta-section {
    padding: 80px 0; text-align: center;
    background: linear-gradient(135deg, var(--dark) 0%, #636E72 100%);
    color: white;
}
.cta-section h2 { font-size: 36px; margin-bottom: 12px; }
.cta-section p { font-size: 18px; opacity: 0.8; margin-bottom: 32px; }

/* ============ PRICING ============ */
.pricing-page { padding: 100px 0 60px; }
.pricing-page h1 { text-align: center; font-size: 36px; margin-bottom: 48px; }
.pricing-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.pricing-card {
    background: white; border-radius: var(--radius); padding: 32px;
    box-shadow: var(--shadow); text-align: center; position: relative;
    transition: var(--transition);
}
.pricing-card.popular {
    border: 2px solid var(--primary);
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}
.popular-badge {
    position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
    background: var(--primary); color: white; padding: 4px 16px;
    border-radius: 20px; font-size: 12px; font-weight: 700;
}
.pricing-card h3 { font-size: 22px; margin-bottom: 16px; }
.pricing-price { margin-bottom: 24px; }
.price-amount { font-size: 36px; font-weight: 800; color: var(--primary); }
.price-period { color: var(--gray); font-size: 14px; }
.pricing-features { list-style: none; text-align: left; margin-bottom: 24px; }
.pricing-features li { padding: 8px 0; border-bottom: 1px solid var(--gray-lighter); }

/* ============ AUTH ============ */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 80px 20px 20px;
    background: linear-gradient(135deg, #6C5CE7 0%, #A29BFE 100%);
}
.auth-card {
    background: white; border-radius: var(--radius); padding: 40px;
    box-shadow: var(--shadow-lg); width: 100%; max-width: 420px;
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-card h2 { text-align: center; margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px; border: 2px solid var(--gray-lighter);
    border-radius: var(--radius-sm); font-size: 15px; transition: var(--transition);
    font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary); outline: none;
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}
.form-group small { color: var(--gray); font-size: 12px; margin-top: 4px; display: block; }
.auth-switch { text-align: center; margin-top: 20px; color: var(--gray); }

/* ============ DASHBOARD ============ */
.dashboard { padding: 84px 20px 40px; max-width: 1200px; margin: 0 auto; }
.dash-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.dash-loading { text-align: center; padding: 60px; color: var(--gray); }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
    background: white; border-radius: var(--radius); padding: 24px;
    box-shadow: var(--shadow); text-align: center;
}
.stat-number { font-size: 36px; font-weight: 800; color: var(--primary); }
.stat-label { color: var(--gray); font-size: 14px; margin-top: 4px; }

.bots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 20px; }
.bot-card {
    background: white; border-radius: var(--radius); padding: 24px;
    box-shadow: var(--shadow); transition: var(--transition);
}
.bot-card:hover { box-shadow: var(--shadow-lg); }
.bot-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.bot-avatar {
    width: 48px; height: 48px; border-radius: 12px;
    background: var(--light); display: flex; align-items: center; justify-content: center;
    font-size: 24px;
}
.bot-info { flex: 1; }
.bot-info h3 { font-size: 18px; }
.bot-username { color: var(--gray); font-size: 13px; }
.status-badge {
    padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.status-active { background: #D4F5E9; color: #00B894; }
.status-paused { background: #FFF3CD; color: #E17055; }
.status-draft { background: var(--gray-lighter); color: var(--gray); }
.status-error { background: #FECDD3; color: #E17055; }

.bot-card-stats { display: flex; gap: 20px; margin-bottom: 16px; font-size: 14px; color: var(--gray); }
.bot-card-stats strong { color: var(--dark); }
.bot-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 60px 20px; grid-column: 1 / -1; }
.empty-icon { font-size: 64px; margin-bottom: 16px; }

.profile-card { background: white; padding: 32px; border-radius: var(--radius); box-shadow: var(--shadow); max-width: 500px; }
.profile-card hr { border: none; border-top: 1px solid var(--gray-lighter); margin: 20px 0; }

/* ============ MODAL ============ */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal {
    background: white; border-radius: var(--radius); padding: 24px;
    width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--gray); }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; }

/* ============ FLOW BUILDER ============ */
.flow-builder {
    position: fixed; top: 64px; left: 0; right: 0; bottom: 0;
    display: flex; flex-direction: column; background: var(--light);
}
.flow-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 16px; background: white; border-bottom: 1px solid var(--gray-lighter);
    z-index: 10;
}
.flow-toolbar-left { display: flex; align-items: center; gap: 16px; }
.flow-name { font-weight: 600; }
.flow-toolbar-right { display: flex; gap: 8px; }

.flow-container { display: flex; flex: 1; overflow: hidden; }

/* Sidebar - node palette */
.flow-sidebar {
    width: 220px; background: white; border-right: 1px solid var(--gray-lighter);
    padding: 16px; overflow-y: auto; flex-shrink: 0;
}
.flow-sidebar h4 { margin-bottom: 12px; font-size: 14px; color: var(--gray); }
.node-palette { display: flex; flex-direction: column; gap: 6px; }
.palette-node {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    background: var(--light); cursor: grab; transition: var(--transition);
    font-size: 14px; border: 1px solid transparent;
}
.palette-node:hover { border-color: var(--primary); background: white; }
.palette-node span { font-size: 18px; }
.palette-node em { font-style: normal; }

/* Canvas */
.flow-canvas-wrap {
    flex: 1; position: relative; overflow: auto;
    background:
        radial-gradient(circle, var(--gray-lighter) 1px, transparent 1px);
    background-size: 20px 20px;
}
.flow-canvas {
    position: relative; min-width: 3000px; min-height: 2000px;
}
.flow-connections {
    position: absolute; top: 0; left: 0;
    pointer-events: none; z-index: 1;
}
.conn-line {
    fill: none; stroke: var(--primary); stroke-width: 2.5;
    pointer-events: stroke; cursor: pointer;
    transition: stroke 0.2s;
}
.conn-line:hover { stroke: var(--danger); stroke-width: 3.5; }
.conn-true { stroke: var(--success); }
.conn-false { stroke: var(--danger); }

/* Flow nodes */
.flow-node {
    position: absolute; min-width: 180px; max-width: 260px;
    background: white; border-radius: var(--radius-sm);
    box-shadow: var(--shadow); border: 2px solid transparent;
    cursor: move; z-index: 2; transition: box-shadow 0.2s;
    user-select: none;
}
.flow-node:hover { box-shadow: var(--shadow-lg); }
.flow-node.dragging { opacity: 0.8; z-index: 10; box-shadow: var(--shadow-lg); }

.node-header {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-weight: 600; font-size: 13px;
}
.node-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-delete {
    background: none; border: none; font-size: 16px;
    cursor: pointer; color: var(--gray-light); opacity: 0;
    transition: var(--transition);
}
.flow-node:hover .node-delete { opacity: 1; }
.node-delete:hover { color: var(--danger); }

.node-preview {
    padding: 4px 12px 8px; font-size: 12px; color: var(--gray);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Node type colors */
.flow-node-trigger .node-header { background: #FFF3CD; }
.flow-node-trigger { border-color: #FDCB6E; }
.flow-node-message .node-header { background: #E8E0FF; }
.flow-node-message { border-color: var(--primary-light); }
.flow-node-condition .node-header { background: #D4F5E9; }
.flow-node-condition { border-color: var(--success); }
.flow-node-input .node-header { background: #DCEEFB; }
.flow-node-input { border-color: #74B9FF; }
.flow-node-action .node-header { background: #E8E0FF; }
.flow-node-action { border-color: #A29BFE; }
.flow-node-api_request .node-header { background: #FFE0D4; }
.flow-node-api_request { border-color: #E17055; }
.flow-node-delay .node-header { background: var(--gray-lighter); }
.flow-node-delay { border-color: var(--gray-light); }
.flow-node-menu .node-header { background: #D4F5F0; }
.flow-node-menu { border-color: var(--secondary); }
.flow-node-media .node-header { background: #FFE0EC; }
.flow-node-media { border-color: #FD79A8; }

/* Ports */
.node-ports {
    position: relative; height: 0;
}
.node-port {
    position: absolute; width: 14px; height: 14px;
    border-radius: 50%; border: 2px solid white;
    cursor: crosshair; z-index: 5; transition: transform 0.2s;
}
.node-port:hover { transform: scale(1.4); }
.port-in {
    top: -7px; left: 50%; transform: translateX(-50%);
    background: var(--primary);
}
.port-in:hover { transform: translateX(-50%) scale(1.4); }
.port-out {
    bottom: -30px; left: 50%; transform: translateX(-50%);
    background: var(--primary);
}
.port-out:hover { transform: translateX(-50%) scale(1.4); }
.port-true {
    bottom: -30px; left: 30%; background: var(--success);
    font-size: 8px; color: white; text-align: center; line-height: 10px;
}
.port-false {
    bottom: -30px; left: 70%; background: var(--danger);
    font-size: 8px; color: white; text-align: center; line-height: 10px;
}

/* Properties panel */
.flow-properties {
    width: 300px; background: white; border-left: 1px solid var(--gray-lighter);
    padding: 16px; overflow-y: auto; flex-shrink: 0;
    flex-direction: column;
}
.props-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.props-header h4 { font-size: 16px; }

.btn-row { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.btn-item { display: flex; gap: 4px; align-items: center; flex: 1; }
.btn-item input { font-size: 12px; padding: 6px; }
.btn-remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 18px; }

.menu-item-edit { display: flex; gap: 4px; margin-bottom: 6px; align-items: center; }
.menu-item-edit input { font-size: 12px; padding: 6px; flex: 1; }

.text-muted { color: var(--gray-light); font-size: 13px; }

/* ============ TOAST ============ */
.toast {
    position: fixed; bottom: 20px; right: 20px; z-index: 9999;
    padding: 12px 24px; border-radius: var(--radius-sm);
    color: white; font-weight: 600; font-size: 14px;
    transform: translateY(100px); opacity: 0; transition: all 0.3s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

/* ============ FOOTER ============ */
.footer {
    padding: 32px 0; text-align: center; background: var(--dark); color: var(--gray-light);
    font-size: 14px;
}
.footer p { margin-bottom: 4px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .hero .container { grid-template-columns: 1fr; }
    .hero h1 { font-size: 32px; }
    .hero-visual { display: none; }
    .features-grid { grid-template-columns: 1fr; }
    .pricing-grid { grid-template-columns: 1fr; }
    .pricing-card.popular { transform: none; }
    .stats-grid { grid-template-columns: 1fr; }
    .bots-grid { grid-template-columns: 1fr; }
    .nav-links { display: none; position: absolute; top: 64px; left: 0; right: 0;
        background: white; flex-direction: column; padding: 16px; box-shadow: var(--shadow);
    }
    .nav-links.open { display: flex; }
    .hamburger { display: block; }
    .flow-sidebar { width: 60px; padding: 8px; }
    .flow-sidebar h4 { display: none; }
    .palette-node em { display: none; }
    .flow-properties { width: 260px; }
}

@media (max-width: 480px) {
    .hero-buttons { flex-direction: column; }
    .btn-lg { padding: 12px 24px; }
    .auth-card { padding: 24px; }
}
