/* ============================================
   РЕГЛАМЕНТ И ОБУЧЕНИЕ - Premium UI
   ============================================ */

:root {
    /* Основные цвета */
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252542;
    --bg-card: #1e1e35;
    
    /* Акцентные цвета */
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-info: #3b82f6;
    
    /* Текст */
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    /* Границы */
    --border-color: rgba(255, 255, 255, 0.1);
    --border-light: rgba(255, 255, 255, 0.05);
    
    /* Тени */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.3);
    
    /* Размеры */
    --header-height: 60px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Анимации */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* ============================================
   БАЗОВЫЕ СТИЛИ
   ============================================ */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* ============================================
   ШАПКА
   ============================================ */

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: rgba(15, 15, 26, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

/* Лого */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 18px;
}

.logo i {
    font-size: 24px;
    color: var(--accent-primary);
}

/* Переключатель режимов */
.mode-switcher {
    display: flex;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 4px;
    position: relative;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: var(--transition-normal);
    position: relative;
    z-index: 1;
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    color: var(--text-primary);
}

.mode-indicator {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-md);
    transition: var(--transition-normal);
    box-shadow: var(--shadow-glow);
}

.mode-btn[data-mode="training"].active ~ .mode-indicator {
    left: calc(50%);
}

/* Zoom контролы */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 4px;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.zoom-value {
    min-width: 50px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Кнопки */
.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

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

.btn-secondary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.btn-danger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    background: var(--accent-danger);
    color: white;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.btn-large {
    padding: 14px 28px;
    font-size: 16px;
}

/* ============================================
   ОСНОВНОЙ КОНТЕНТ
   ============================================ */

.main-content {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

/* ============================================
   CANVAS (ДОСКА)
   ============================================ */

.canvas-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    cursor: grab;
    background: 
        radial-gradient(circle at center, var(--bg-secondary) 0%, var(--bg-primary) 100%),
        repeating-linear-gradient(0deg, transparent, transparent 50px, var(--border-light) 50px, var(--border-light) 51px),
        repeating-linear-gradient(90deg, transparent, transparent 50px, var(--border-light) 50px, var(--border-light) 51px);
}

.canvas-container:active {
    cursor: grabbing;
}

.connections-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    transform-origin: 0 0;
    overflow: visible;
}

.connections-layer path {
    pointer-events: stroke;
}

.blocks-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
}


/* ============================================
   БЛОКИ
   ============================================ */

.org-block {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    cursor: move;
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
    user-select: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.org-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--block-color, var(--accent-primary));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.org-block:hover {
    box-shadow: var(--shadow-lg), 0 0 0 2px var(--block-color, var(--accent-primary));
    transform: translateY(-2px);
}

.org-block.selected {
    box-shadow: var(--shadow-lg), 0 0 0 3px var(--accent-primary);
}

.org-block.dragging {
    opacity: 0.8;
    z-index: 1000 !important;
    box-shadow: var(--shadow-lg);
}

.block-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.block-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--block-color, var(--accent-primary)), var(--accent-secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.block-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.block-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.block-position {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.block-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.block-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 8px;
    background: var(--accent-warning);
    color: #000;
    font-size: 10px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.block-private-badge {
    background: var(--accent-danger);
    color: white;
}

/* Resize handle */
.block-resize {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: se-resize;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.block-resize::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
}

.org-block:hover .block-resize {
    opacity: 1;
}

/* ============================================
   СВЯЗИ (SVG)
   ============================================ */

.connection-line {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 2;
    transition: stroke var(--transition-fast);
}

.connection-line:hover {
    stroke: var(--accent-primary);
    stroke-width: 3;
}

.connection-line.reports-to {
    stroke: var(--accent-info);
    marker-end: url(#arrowhead);
}

.connection-line.collaborates {
    stroke: var(--accent-success);
    stroke-dasharray: 8, 4;
}

/* ============================================
   МИНИКАРТА
   ============================================ */

.minimap {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    z-index: 100;
}

.minimap-viewport {
    position: absolute;
    border: 2px solid var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    border-radius: 4px;
    cursor: move;
    z-index: 1;
}

#minimap-canvas {
    width: 100%;
    height: 100%;
}

/* ============================================
   ПУСТОЕ СОСТОЯНИЕ
   ============================================ */

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
}

.empty-icon {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 40px;
    box-shadow: var(--shadow-glow);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.empty-state h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    max-width: 300px;
}

/* ============================================
   МОДАЛЬНЫЕ ОКНА
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    animation: fadeIn 0.2s ease forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

.modal-large {
    max-width: 700px;
}

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

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

.modal-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

.modal-titles {
    flex: 1;
    min-width: 0;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

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

.modal-close {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modal-close:hover {
    background: var(--accent-danger);
    color: white;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.modal-footer .spacer {
    flex: 1;
}

/* Вкладки в модальном окне */
.modal-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.tab-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

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

.tab-content {
    display: none;
}

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

/* Информационная сетка */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.info-item {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--radius-md);
}

.info-item label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item span {
    font-size: 15px;
    font-weight: 500;
}

/* Разделы контента */
.content-sections {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.content-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.section-header:hover {
    background: var(--bg-tertiary);
}

.section-icon {
    width: 32px;
    height: 32px;
    background: var(--accent-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.section-title {
    flex: 1;
    font-weight: 500;
}

.section-toggle {
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.content-section.expanded .section-toggle {
    transform: rotate(180deg);
}

.section-body {
    display: none;
    padding: 0 16px 16px;
}

.content-section.expanded .section-body {
    display: block;
}

.section-content {
    background: var(--bg-primary);
    padding: 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

.section-content ul,
.section-content ol {
    margin-left: 20px;
    margin-top: 8px;
}

.section-content li {
    margin-bottom: 6px;
}

.btn-add-section,
.btn-add-connection {
    width: 100%;
    padding: 14px;
    border: 2px dashed var(--border-color);
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.btn-add-section:hover,
.btn-add-connection:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

/* ============================================
   ФОРМЫ
   ============================================ */

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

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

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.form-row .form-group.flex-2 {
    flex: 2;
}

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

.color-picker input[type="color"] {
    width: 50px;
    height: 40px;
    padding: 4px;
    cursor: pointer;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-primary);
}

/* Редактор текста */
.editor-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.editor-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.editor-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.editor-toolbar + textarea {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ============================================
   РЕЖИМ ОБУЧЕНИЕ
   ============================================ */

.training-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 30px;
}

/* Сетка курсов */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.course-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    cursor: pointer;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.course-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--course-color, var(--accent-success));
}

.course-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--course-color, var(--accent-success));
}

.course-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--course-color, var(--accent-success)), var(--accent-info));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.course-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.course-position {
    font-size: 13px;
    color: var(--accent-primary);
    margin-bottom: 12px;
}

.course-description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.course-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.course-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Просмотр курса */
.course-view {
    max-width: 1000px;
    margin: 0 auto;
}

.course-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-back:hover {
    background: var(--bg-tertiary);
}

.course-view .course-title {
    font-size: 28px;
    font-weight: 700;
}

/* Timeline шагов */
.steps-timeline {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow-x: auto;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    cursor: pointer;
    padding: 0 20px;
    flex-shrink: 0;
}

.step-item:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 20px;
    left: calc(50% + 20px);
    width: calc(100% - 40px);
    height: 3px;
    background: var(--border-color);
}

.step-item.completed:not(:last-child)::after {
    background: var(--accent-success);
}

.step-circle {
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border: 3px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition-fast);
    z-index: 1;
}

.step-item.completed .step-circle {
    background: var(--accent-success);
    border-color: var(--accent-success);
    color: white;
}

.step-item.active .step-circle {
    border-color: var(--accent-primary);
    background: var(--accent-primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

.step-item:hover .step-circle {
    transform: scale(1.1);
}

.step-label {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.step-item.active .step-label {
    color: var(--accent-primary);
    font-weight: 500;
}

/* Контент шага */
.step-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 20px;
}

.video-container {
    position: relative;
    background: #000;
    aspect-ratio: 16 / 9;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: var(--transition-fast);
}

.video-overlay i {
    width: 80px;
    height: 80px;
    background: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    box-shadow: var(--shadow-glow);
    transition: transform var(--transition-fast);
}

.video-overlay:hover i {
    transform: scale(1.1);
}

.video-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.step-info {
    padding: 24px;
}

.step-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 12px;
}

.step-description {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

/* Таймкоды */
.timecodes-list h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

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

.timecode-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.timecode-item:hover {
    background: var(--bg-tertiary);
}

.timecode-time {
    font-family: monospace;
    font-size: 13px;
    color: var(--accent-primary);
    background: var(--bg-primary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.timecode-title {
    flex: 1;
    font-size: 14px;
}

/* Навигация по шагам */
.step-navigation {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.btn-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-nav:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

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

.btn-nav.btn-primary {
    border: none;
}

/* ============================================
   ПОИСК
   ============================================ */

.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    padding-top: 100px;
}

.search-container {
    width: 90%;
    max-width: 600px;
}

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.search-input-wrap i {
    font-size: 20px;
    color: var(--text-muted);
}

.search-input-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    outline: none;
}

.search-input-wrap input::placeholder {
    color: var(--text-muted);
}

.search-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.search-close:hover {
    background: var(--accent-danger);
    color: white;
}

.search-results {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    max-height: 400px;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border-light);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg-secondary);
}

.search-result-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.search-result-info {
    flex: 1;
}

.search-result-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.search-result-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ============================================
   КОНТЕКСТНОЕ МЕНЮ
   ============================================ */

.context-menu {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 0;
    min-width: 180px;
    box-shadow: var(--shadow-lg);
    z-index: 4000;
}

.context-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.context-item:hover {
    background: var(--bg-secondary);
}

.context-item.danger {
    color: var(--accent-danger);
}

.context-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.context-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

/* ============================================
   TOAST УВЕДОМЛЕНИЯ
   ============================================ */

.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 5000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
}

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

.toast.success {
    border-left: 4px solid var(--accent-success);
}

.toast.error {
    border-left: 4px solid var(--accent-danger);
}

.toast.info {
    border-left: 4px solid var(--accent-info);
}

.toast-icon {
    font-size: 18px;
}

.toast.success .toast-icon {
    color: var(--accent-success);
}

.toast.error .toast-icon {
    color: var(--accent-danger);
}

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

.toast-message {
    font-size: 14px;
}

/* ============================================
   АДАПТИВНОСТЬ
   ============================================ */

@media (max-width: 768px) {
    .header {
        padding: 0 12px;
    }
    
    .header-center {
        display: none;
    }
    
    .mode-switcher {
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 100;
        box-shadow: var(--shadow-lg);
    }
    
    .zoom-controls {
        display: none;
    }
    
    .minimap {
        display: none;
    }
    
    .training-container {
        padding: 20px;
    }
    
    .courses-grid {
        grid-template-columns: 1fr;
    }
    
    .modal {
        width: 95%;
        max-height: 85vh;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .steps-timeline {
        padding: 16px;
    }
    
    .step-item {
        padding: 0 12px;
    }
}

/* ============================================
   ТАЙМКОДЫ В РЕДАКТОРЕ
   ============================================ */

.timecodes-editor {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.timecodes-editor > label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.timecodes-list-edit {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.timecode-edit-item {
    display: flex;
    gap: 8px;
    align-items: center;
}

.timecode-edit-item input {
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
}

.timecode-edit-item input[type="number"] {
    width: 80px;
}

.timecode-edit-item input[type="text"] {
    flex: 1;
}

.timecode-edit-item button {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--accent-danger);
    color: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.timecode-edit-item button:hover {
    background: #dc2626;
}

.btn-add-timecode {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    border: 2px dashed var(--border-color);
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-add-timecode:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* ============================================
   СВЯЗИ В МОДАЛЬНОМ ОКНЕ
   ============================================ */

.relations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.relation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.relation-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-info);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.relation-info {
    flex: 1;
}

.relation-type {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.relation-name {
    font-weight: 500;
}

.relation-delete {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    display: none;
}

.relation-item:hover .relation-delete {
    display: flex;
    align-items: center;
    justify-content: center;
}

.relation-delete:hover {
    background: var(--accent-danger);
    color: white;
}
/* ========================================
   AVATAR PICKER
   ======================================== */

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

.avatar-preview {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    overflow: hidden;
    position: relative;
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-preview span {
    line-height: 1;
}

.avatar-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn-small {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.15s ease;
}

.btn-small:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-width: 280px;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.emoji-grid span {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.emoji-grid span:hover {
    background: var(--bg-tertiary);
}

/* Руководитель hint */
.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}
/* Block avatar */
.block-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}
/* Connection modal */
.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
}

/* Relations list */
.empty-relations {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
}

.empty-relations i {
    font-size: 32px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.relation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 8px;
}

.relation-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 20px;
}

.relation-info {
    flex: 1;
}

.relation-name {
    font-weight: 500;
    color: var(--text-primary);
}

.relation-type {
    font-size: 12px;
    color: var(--text-muted);
}

.btn-delete-relation {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-delete-relation:hover {
    background: var(--danger);
    color: white;
}
/* Connection Editor */
#connection-editor path {
    pointer-events: none;
}

.control-point circle {
    transition: r 0.15s ease, fill 0.15s ease;
}

.control-point.control circle:hover {
    r: 14;
    fill: #4f46e5;
}

.connection-group:hover .connection-line {
    stroke-width: 4;
}

.connection-line {
    transition: stroke-width 0.2s ease;
}
