/* =============================================
   STUDIO85 IT — Визуализация дерева сценариев
   ============================================= */

/* Табы */
.tree-tabs {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 32px;
}

.tree-tab {
    padding: 10px 24px;
    background: #f5f5f7;
    border: 1px solid transparent;
    border-radius: 100px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: #86868b;
    cursor: pointer;
    transition: all 0.2s;
}

.tree-tab:hover {
    background: #e8e8ed;
    color: #1d1d1f;
}

.tree-tab.active {
    background: #1d1d1f;
    color: #fff;
}

/* Контейнер */
.tree-showcase {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
    margin-bottom: 48px;
}

/* Карта дерева */
.tree-map {
    background: #f8f9fa;
    border-radius: 16px;
    padding: 24px;
    min-height: 480px;
    overflow-y: auto;
    max-height: 600px;
}

.tree-map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e5e5;
}

.tree-map-title {
    font-size: 15px;
    font-weight: 600;
    color: #1d1d1f;
}

.tree-map-stats {
    font-size: 12px;
    color: #86868b;
    background: #fff;
    padding: 4px 12px;
    border-radius: 100px;
}

/* Узлы дерева */
.tree-nodes {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tree-node {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.tree-node:hover .tree-node-label {
    background: #e8e8ed;
}

.tree-node.active > .tree-node-label {
    background: #0071e3;
    color: #fff;
}

.tree-node.active > .tree-node-label .tree-node-type {
    background: rgba(255,255,255,0.25);
    color: #fff;
}

/* Отступы уровней */
.tree-node-indent {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

.tree-node-line {
    width: 20px;
    height: 28px;
    position: relative;
}

.tree-node-line::before {
    content: '';
    position: absolute;
    left: 9px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #d2d2d7;
}

.tree-node-line::after {
    content: '';
    position: absolute;
    left: 9px;
    top: 14px;
    width: 8px;
    height: 1px;
    background: #d2d2d7;
}

.tree-node-line.last::before {
    bottom: 50%;
}

/* Метка узла */
.tree-node-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: #fff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #1d1d1f;
    transition: all 0.15s;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-node-type {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.tree-node-type.branch {
    background: #e3f2fd;
    color: #1565c0;
}

.tree-node-type.leaf {
    background: #e8f5e9;
    color: #2e7d32;
}

.tree-node-type.collect {
    background: #fff3e0;
    color: #e65100;
}

.tree-node-type.faq {
    background: #f3e5f5;
    color: #7b1fa2;
}

.tree-node-type.ai {
    background: #fce4ec;
    color: #c62828;
}

/* Ветка (группа дочерних) */
.tree-branch {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-left: 0;
}

.tree-branch.collapsed {
    display: none;
}

/* Превью виджета */
.tree-preview {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 24px;
}

.tree-preview-widget {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12);
    overflow: hidden;
}

.tree-widget-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: #1d1d1f;
    color: #fff;
}

.tree-widget-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #0071e3;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

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

.tree-widget-status {
    font-size: 11px;
    color: #34c759;
}

.tree-widget-body {
    padding: 16px;
    min-height: 80px;
    background: #f8f9fa;
}

.tree-widget-msg {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    max-width: 90%;
}

.tree-widget-msg.bot {
    background: #fff;
    color: #1d1d1f;
}

.tree-widget-buttons {
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f8f9fa;
}

.tree-widget-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #e3f2fd;
    border: none;
    border-radius: 20px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    color: #0071e3;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.tree-widget-btn:hover {
    background: #d0e8fc;
}

.tree-widget-btn .btn-icon {
    font-size: 10px;
    opacity: 0.6;
}

/* Хлебные крошки */
.tree-breadcrumbs {
    font-size: 12px;
    color: #86868b;
    padding: 0 4px;
    min-height: 18px;
}

.tree-breadcrumbs span {
    cursor: pointer;
}

.tree-breadcrumbs span:hover {
    color: #0071e3;
}

.tree-breadcrumbs .sep {
    margin: 0 4px;
    cursor: default;
}

.tree-breadcrumbs .sep:hover {
    color: #86868b;
}

/* Описание под деревом */
.tree-description {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.tree-desc-item {
    text-align: center;
    padding: 24px 16px;
}

.tree-desc-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.tree-desc-item h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #1d1d1f;
}

.tree-desc-item p {
    font-size: 14px;
    color: #86868b;
    line-height: 1.5;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .tree-showcase {
        grid-template-columns: 1fr;
    }

    .tree-preview {
        position: static;
    }

    .tree-map {
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    .tree-tabs {
        flex-direction: column;
        align-items: stretch;
    }

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

    .tree-description {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .tree-map {
        padding: 16px;
    }
}
