/* =====================================================
   ВИЗУАЛЬНЫЙ КОНСТРУКТОР TELEGRAM БОТОВ
   ===================================================== */

/* === БОТЫ - СЕТКА === */
.bots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 24px;
    padding: 24px;
}

.bot-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.bot-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    border-color: var(--primary);
}

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

.bot-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
}

.bot-avatar {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    flex-shrink: 0;
}

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

.bot-name {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bot-username {
    font-size: 14px;
    color: var(--text-secondary);
}

.bot-status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--bg-secondary);
}

.bot-status-badge.active {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.bot-status-badge.inactive {
    color: #6b7280;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.bot-card-body {
    padding: 20px;
}

.bot-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.6;
    min-height: 42px;
}

.bot-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.bot-stats .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.bot-stats .stat-item i {
    color: var(--primary);
    font-size: 16px;
}

.bot-stats .stat-item strong {
    font-size: 16px;
    color: var(--text-primary);
}

.bot-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.webhook-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #f59e0b;
}

.webhook-status.active {
    color: #10b981;
}

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

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

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

.btn-icon.danger:hover {
    background: #ef4444;
}

/* === СЦЕНАРИИ === */
.scenarios-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-radius: 16px;
    margin: 24px;
    margin-bottom: 0;
}

.scenarios-header h2 {
    flex: 1;
    margin: 0;
    font-size: 20px;
}

.scenarios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 16px;
    padding: 24px;
}

.scenario-card {
    background: var(--bg-secondary);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    gap: 16px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    position: relative;
}

.scenario-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.scenario-card.inactive {
    opacity: 0.6;
}

.scenario-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    flex-shrink: 0;
}

.scenario-content {
    flex: 1;
    min-width: 0;
}

.scenario-content h4 {
    margin: 0 0 8px;
    font-size: 16px;
    color: var(--text-primary);
}

.scenario-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.trigger-label {
    color: var(--text-secondary);
}

.scenario-trigger code {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

.scenario-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 0;
}

.scenario-status {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--bg-tertiary);
}

.scenario-status.active {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.scenario-actions {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.scenario-card:hover .scenario-actions {
    opacity: 1;
}

/* === ВИЗУАЛЬНЫЙ РЕДАКТОР === */
.editor-container {
    display: flex;
    height: calc(100vh - 180px);
    gap: 0;
}

.editor-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.editor-header h2 {
    flex: 1;
    margin: 0;
    font-size: 18px;
}

.header-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.header-hint i {
    color: var(--primary);
}

.tools-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.tools-header h4 {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tools-header h4 i {
    color: var(--primary);
}

/* Панель инструментов */
#tools-panel {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    flex-shrink: 0;
}

.tools-list {
    padding: 16px;
}

.tool-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: grab;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.tool-item:hover {
    border-color: var(--tool-color, var(--primary));
    transform: translateX(4px);
}

.tool-item:active {
    cursor: grabbing;
}

.tool-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

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

.tool-name {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.tool-desc {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Canvas редактора */
.scenario-editor-canvas {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
    background-image: 
        radial-gradient(circle, var(--border-color) 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: auto;
    min-height: 600px;
}

.svg-connections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.connection-line {
    fill: none;
    stroke: #3b82f6;
    stroke-width: 2;
    stroke-linecap: round;
}

.connection-line.temp {
    stroke-dasharray: 8, 4;
    stroke: #8b5cf6;
}

.connection-line.alternative {
    stroke: #f59e0b;
    stroke-dasharray: 4, 4;
}

.connection-arrow {
    fill: #3b82f6;
}

.connection-arrow.alternative {
    fill: #f59e0b;
}

/* Блоки редактора */
.editor-block {
    position: absolute;
    width: 280px;
    background: var(--bg-secondary);
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 10;
    cursor: move;
    transition: box-shadow 0.2s, transform 0.1s;
    border: 2px solid transparent;
}

.editor-block:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.editor-block.dragging {
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
    transform: scale(1.02);
    border-color: var(--primary);
}

.editor-block.selected {
    border-color: var(--primary);
}

.block-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px 12px 0 0;
    color: white;
    font-size: 13px;
    font-weight: 600;
}

.block-header i {
    font-size: 14px;
}

.entry-badge {
    margin-left: auto;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.25);
    font-weight: 500;
}

.block-menu {
    margin-left: auto;
    position: relative;
}

.block-menu-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.block-menu-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.block-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-secondary);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    min-width: 160px;
    z-index: 100;
    display: none;
    overflow: hidden;
}

.block-menu-dropdown.active {
    display: block;
}

.block-menu-dropdown button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
}

.block-menu-dropdown button:hover {
    background: var(--bg-tertiary);
}

.block-menu-dropdown button.danger {
    color: #ef4444;
}

.block-menu-dropdown button i {
    width: 16px;
    color: var(--text-secondary);
}

.block-menu-dropdown button.danger i {
    color: #ef4444;
}

.block-content {
    padding: 14px;
    font-size: 13px;
    color: var(--text-secondary);
    min-height: 60px;
    max-height: 120px;
    overflow: hidden;
}

.preview-text {
    margin: 0;
    line-height: 1.5;
    color: var(--text-primary);
}

.preview-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.preview-btn {
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}

.preview-more {
    padding: 4px 8px;
    color: var(--text-secondary);
    font-size: 11px;
}

.preview-timer,
.preview-condition,
.preview-image,
.preview-crm {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    color: var(--text-primary);
    font-weight: 500;
}

.preview-timer i,
.preview-condition i,
.preview-image i,
.preview-crm i {
    font-size: 20px;
    opacity: 0.7;
}

.preview-variable {
    margin-top: 10px;
    font-size: 12px;
}

.preview-variable code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Коннекторы */
.block-connectors {
    position: relative;
}

.connector {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 3px solid #3b82f6;
    cursor: crosshair;
    z-index: 20;
    transition: transform 0.2s, background 0.2s;
}

.connector:hover {
    transform: scale(1.3);
    background: #3b82f6;
}

.connector-in {
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
}

.connector-out {
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
}

.connector-out:hover {
    background: #10b981;
    border-color: #10b981;
}

/* Подсказка редактора */
.editor-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-secondary);
    pointer-events: none;
}

.editor-hint i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.editor-hint p {
    font-size: 16px;
    max-width: 300px;
}

/* === МОДАЛЬНЫЕ ОКНА === */
.modal-window {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-window.active {
    display: flex;
}

.modal-window .modal-content {
    background: var(--bg-secondary);
    border-radius: 20px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-window .modal-content.modal-lg {
    max-width: 700px;
}

.modal-window .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-window .modal-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
}

.modal-window .modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    padding: 4px;
}

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

.modal-window form {
    padding: 24px;
}

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

.modal-window .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Форма редактора блоков */
.form-divider {
    height: 1px;
    background: var(--border-color);
    margin: 20px 0;
}

.buttons-editor {
    margin-bottom: 12px;
}

.button-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.button-row input {
    flex: 1;
}

.button-row .btn-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.timer-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.timer-preset {
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.timer-preset:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

.timer-preset.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* === WEBHOOK СЕКЦИЯ === */
.webhook-section {
    margin-top: 16px;
}

.section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.section-label i {
    color: var(--primary);
}

.webhook-status-block {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border-radius: 12px;
}

.webhook-status-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #6b7280;
}

.status-indicator.active {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.status-indicator.inactive {
    background: #f59e0b;
}

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

.btn-success {
    background: #10b981;
    color: white;
    border: none;
}

.btn-success:hover {
    background: #059669;
}

.btn-success:disabled {
    background: #6b7280;
    cursor: not-allowed;
}

/* === ПУСТЫЕ СОСТОЯНИЯ === */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-secondary);
}

.empty-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 24px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-icon i {
    font-size: 40px;
    color: var(--text-tertiary);
}

.empty-state h3 {
    margin: 0 0 8px;
    color: var(--text-primary);
    font-size: 20px;
}

.empty-state p {
    margin: 0 0 24px;
    font-size: 15px;
}

/* === ТУТОРИАЛ === */
.tutorial-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(8px);
}

.tutorial-content {
    background: #ffffff;
    border-radius: 24px;
    padding: 40px;
    max-width: 520px;
    text-align: center;
    color: #1e293b;
}

.tutorial-header {
    margin-bottom: 32px;
}

.tutorial-icon {
    font-size: 64px;
    display: block;
    margin-bottom: 16px;
}

.tutorial-header h2 {
    margin: 0;
    font-size: 24px;
    color: #1e293b;
}

.tutorial-body {
    text-align: left;
    margin-bottom: 32px;
}

.tutorial-step {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 12px;
    margin-bottom: 12px;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #3b82f6;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.step-content h4 {
    margin: 0 0 4px;
    font-size: 15px;
    color: #1e293b;
}

.step-content p {
    margin: 0;
    font-size: 13px;
    color: #64748b;
}

.tutorial-footer {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.tutorial-checkbox {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* === КАРТОЧКИ БОТОВ (улучшенные) === */
.bot-card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.webhook-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--bg-secondary);
}

.webhook-indicator.connected {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.webhook-indicator.disconnected {
    color: #f59e0b;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

/* === GETTING STARTED === */
.getting-started-steps {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 20px;
    margin: 24px 0;
    text-align: left;
}

.gs-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.gs-icon {
    font-size: 20px;
}

/* === ПОЛЬЗОВАТЕЛИ БОТА === */
.users-container {
    padding: 24px;
}

.users-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.users-stats .stat-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.users-stats .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.users-stats .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.users-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
}

.search-box {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-box input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    font-size: 14px;
}

.users-table-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th {
    text-align: left;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.users-table td {
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
}

.user-row.blocked {
    opacity: 0.6;
}

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

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.bot-users-table .user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.user-status {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
}

.user-status.active {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.user-status.blocked {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

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

/* === ЧАТ / ИСТОРИЯ === */
.chat-container {
    max-height: 500px;
    overflow-y: auto;
    padding: 16px;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
}

.chat-message.incoming {
    align-self: flex-start;
    background: var(--bg-tertiary);
    border-bottom-left-radius: 4px;
}

.chat-message.outgoing {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-content {
    word-break: break-word;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 6px;
    text-align: right;
}

.empty-chat {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* === РАССЫЛКА === */
.recipients-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.recipients-info i {
    color: var(--primary);
}

.message-preview {
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    min-height: 60px;
}

.message-bubble {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: inline-block;
    max-width: 100%;
    word-break: break-word;
}

.preview-placeholder {
    color: var(--text-secondary);
    font-style: italic;
}

/* === ПРИМЕРЫ СЦЕНАРИЕВ === */
.scenario-examples {
    margin: 24px 0;
}

.scenario-examples h4 {
    margin: 0 0 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.example-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.example-card {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.example-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.example-card i {
    font-size: 24px;
    color: var(--primary);
    margin-bottom: 8px;
}

.example-card span {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
}

.example-card small {
    color: var(--text-secondary);
    font-size: 11px;
}

/* === УЛУЧШЕННЫЕ БЛОКИ === */
.preview-empty {
    color: var(--text-secondary);
    font-style: italic;
    margin: 0;
}

.preview-btn-empty {
    color: var(--text-secondary);
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
}

.step-help-text {
    padding: 12px 16px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--primary);
}

.step-help-text i {
    margin-right: 8px;
}

.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* === ПОДСКАЗКА РЕДАКТОРА === */
.editor-tip {
    position: absolute;
    top: 100px;
    left: 300px;
    z-index: 100;
    animation: pulse 2s infinite;
}

.tip-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--primary);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
}

.tip-arrow {
    font-size: 24px;
    animation: bounce-left 1s infinite;
}

.tip-text {
    font-size: 14px;
    line-height: 1.4;
}

@keyframes bounce-left {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-8px); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* === EMPTY ILLUSTRATION === */
.empty-illustration {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-illustration i {
    font-size: 48px;
    color: white;
}

.empty-sparkles {
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 32px;
    animation: sparkle 1.5s infinite;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.2) rotate(15deg); }
}

/* === АДАПТИВ === */
@media (max-width: 1024px) {
    .editor-container {
        flex-direction: column;
    }
    
    #tools-panel {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .tools-list {
        display: flex;
        overflow-x: auto;
        gap: 10px;
        padding: 12px;
    }
    
    .tool-item {
        flex-shrink: 0;
        width: 160px;
        margin-bottom: 0;
    }
}

/* Bot settings sections */
.bot-settings-section { margin-top: 8px; }
.bot-settings-section .section-hint {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 10px;
}

.menu-commands-list, .reply-keyboard-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}
.menu-cmd-row, .reply-kb-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.menu-cmd-row input, .reply-kb-row input {
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
}
.btn-danger-outline {
    border: 1px solid #f87171;
    color: #f87171;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
}
.btn-danger-outline:hover { background: #fef2f2; }

/* Step editor enhancements */
.step-btn-row { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.step-btn-row input, .step-btn-row select { font-size: 13px; padding: 5px 8px; border: 1px solid #e2e8f0; border-radius: 6px; }
.step-btn-row .btn-url-input { flex: 1; min-width: 0; }
.step-goto-row { display: flex; gap: 6px; align-items: center; }
.step-goto-row select { flex: 1; font-size: 13px; padding: 5px 8px; border: 1px solid #e2e8f0; border-radius: 6px; }
.condition-paths { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.condition-path { padding: 8px; border-radius: 8px; background: #f8fafc; }
.condition-path.true-path { border-left: 3px solid #22c55e; }
.condition-path.false-path { border-left: 3px solid #ef4444; }
.condition-path label { font-size: 12px; font-weight: 600; margin-bottom: 4px; display: block; }
.var-hints { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.var-hint-tag {
    font-size: 11px; padding: 2px 8px; background: #eff6ff; color: #3b82f6; border-radius: 12px; cursor: pointer;
}
.var-hint-tag:hover { background: #dbeafe; }

@media (max-width: 768px) {
    .bots-grid {
        grid-template-columns: 1fr;
        padding: 16px;
    }
    
    .scenarios-grid {
        grid-template-columns: 1fr;
        padding: 16px;
    }
    
    .scenarios-header {
        flex-wrap: wrap;
        margin: 16px;
    }
    
    .modal-window .form-row {
        grid-template-columns: 1fr;
    }
    
    .editor-block {
        width: 240px;
    }
    
    .condition-paths { grid-template-columns: 1fr; }
}
