/**
 * ========================================
 * Организационная карта - Стили
 * ========================================
 */

/* Container */
#org-map-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.org-map-header {
    padding: 16px;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.org-map-back-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    color: white;
    padding: 8px 16px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.org-map-back-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.org-map-title {
    margin: 0;
    color: white;
    font-size: 18px;
    flex: 1;
}

/* Toolbar */
.org-map-toolbar {
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: 8px;
}

.mode-btn {
    background: transparent;
    border: none;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.6);
    padding: 8px 16px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.mode-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.mode-label {
    font-size: 12px;
    font-weight: 500;
}

/* Main layout */
.org-map-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* Sidebar (Role Menu) */
.org-map-sidebar {
    width: 280px;
    background: rgba(0, 0, 0, 0.4);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.org-map-sidebar.hidden {
    transform: translateX(-100%);
}

.org-map-sidebar.dragging-active {
    transform: translateX(-240px);
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.sidebar-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-close-btn:active {
    transform: scale(0.95);
}

.sidebar-title {
    margin: 0 0 8px 0;
    color: white;
    font-size: 16px;
    font-weight: 600;
}

.sidebar-subtitle {
    margin: 0;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Role items in sidebar */
.role-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all 0.2s ease;
    user-select: none;
}

.role-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(139, 92, 246, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

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

.role-item.dragging {
    opacity: 0.5;
}

.role-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.role-emoji {
    font-size: 24px;
    flex-shrink: 0;
}

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

.role-name {
    color: white;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 4px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.role-members {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    margin: 0;
}

/* Стили для тегов только на странице org-map */
.org-map-sidebar .role-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 24px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.org-map-sidebar .role-tag.ai {
    background: rgba(139, 92, 246, 0.2);
    color: rgba(139, 92, 246, 1);
    border: 1px solid rgba(139, 92, 246, 0.4);
}

.org-map-sidebar .role-tag.human {
    background: rgba(34, 197, 94, 0.2);
    color: rgba(34, 197, 94, 1);
    border: 1px solid rgba(34, 197, 94, 0.4);
}

/* Canvas container */
.org-map-canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#org-map-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: move;
    background: transparent;
}

#org-map-canvas.dragging-role {
    cursor: grabbing;
}

#org-map-canvas.drawing-connection {
    cursor: crosshair;
}

/* Empty state */
.canvas-empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
}

.canvas-empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.canvas-empty-text {
    font-size: 16px;
    margin-bottom: 8px;
}

.canvas-empty-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
}

/* Footer hints */
.org-map-footer {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.footer-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
}

.footer-hint-key {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    color: white;
    font-size: 11px;
}

/* Toggle sidebar button (mobile) */
.sidebar-toggle {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    padding: 10px;
    font-size: 20px;
    cursor: pointer;
    display: none;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Return trigger button (показывается при перетаскивании роли) */
.role-return-trigger {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 150;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.9), rgba(124, 58, 237, 0.9));
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-left: none;
    border-radius: 0 12px 12px 0;
    color: white;
    padding: 0;
    width: 52px;
    height: 52px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 4px 0 16px rgba(139, 92, 246, 0.4);
    transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    opacity: 0;
    pointer-events: none;
}

.role-return-trigger.active {
    display: flex;
    opacity: 1;
    pointer-events: all;
}

.role-return-trigger.highlight {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.95), rgba(22, 163, 74, 0.95));
    border-color: rgba(34, 197, 94, 0.6);
    box-shadow: 0 0 28px rgba(34, 197, 94, 0.8);
}

.role-return-trigger-icon {
    width: 28px;
    height: 28px;
    transition: transform 0.1s ease;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .org-map-sidebar {
        width: 240px;
    }
    
    .mode-label {
        display: none;
    }
}

@media (max-width: 768px) {
    .org-map-header {
        padding: 12px;
    }
    
    .org-map-title {
        font-size: 16px;
    }
    
    .org-map-back-btn {
        padding: 6px 12px;
        font-size: 14px;
    }
    
    .org-map-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 100;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.4);
    }
    
    .org-map-sidebar.hidden {
        transform: translateX(-100%);
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .role-item {
        padding: 10px;
    }
    
    .role-emoji {
        font-size: 20px;
    }
    
    .role-name {
        font-size: 13px;
    }
    
    .role-members {
        font-size: 11px;
    }
    
    .org-map-footer {
        padding: 8px 12px;
        flex-wrap: wrap;
    }
    
    .footer-hint {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .org-map-sidebar {
        width: 100%;
        max-width: 280px;
    }
    
    .org-map-toolbar {
        flex-direction: column;
        padding: 2px;
    }
    
    .mode-btn {
        padding: 6px 12px;
        font-size: 16px;
    }
    
    .canvas-empty-icon {
        font-size: 48px;
    }
    
    .canvas-empty-text {
        font-size: 14px;
    }
}

/* Loading state */
.org-map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.org-map-container {
    animation: fadeIn 0.3s ease;
}
