/* Секция инструкций и базы знаний */

.instructions-section {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.instructions-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

/* Поле поиска инструкций использует классы global-search-* из layout.css */

/* Панель результатов поиска */
.search-results-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 8px;
    overflow: hidden;
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--bg-tertiary, #fff);
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.search-results-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.search-results-header h3 span {
    color: var(--primary-color, #4a90d9);
}

.search-results-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg-tertiary, #fff);
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color, #e0e0e0);
}

.search-result-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: var(--primary-color, #4a90d9);
}

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

.search-result-title {
    display: block;
    font-weight: 500;
    color: var(--text-primary, #333);
    margin-bottom: 5px;
}

.search-result-meta {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.search-result-meta small {
    color: var(--text-secondary, #666);
}

.search-result-category {
    background: var(--primary-light, #e8f4fd);
    color: var(--primary-color, #4a90d9);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.instructions-container {
    display: flex;
    flex: 1;
    gap: 20px;
    min-height: 0;
}

/* Боковая панель с подразделами */
.instructions-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    background: var(--bg-tertiary, #fff);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary, #333);
}

.categories-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-tertiary, #fff);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.category-item:hover {
    background: var(--bg-hover, #e8e8e8);
    transform: translateX(3px);
}

.category-item.active {
    border-color: var(--primary-color, #4a90d9);
    background: var(--primary-light, #e8f4fd);
}

.category-icon {
    font-size: 1.5rem;
    min-width: 35px;
    text-align: center;
}

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

.category-name {
    display: block;
    font-weight: 500;
    color: var(--text-primary, #333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-desc {
    display: block;
    color: var(--text-secondary, #666);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

.category-item:hover .category-actions {
    opacity: 1;
}

.btn-icon-sm {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-icon-sm:hover {
    background: var(--bg-hover, rgba(0,0,0,0.1));
}

.empty-categories {
    text-align: center;
    padding: 30px 15px;
    color: var(--text-secondary, #666);
}

.empty-categories p {
    margin: 0 0 5px 0;
}

/* Контент инструкций */
.instructions-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.instructions-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-secondary, #666);
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 8px;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    opacity: 0.6;
}

.instructions-placeholder h3 {
    margin: 0 0 10px 0;
    color: var(--text-primary, #333);
}

.instructions-placeholder p {
    margin: 0;
}

/* Панель со списком инструкций */
.instructions-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 8px;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--bg-tertiary, #fff);
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.panel-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.instructions-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    margin-bottom: 10px;
    background: var(--bg-tertiary, #fff);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color, #e0e0e0);
}

.instruction-item:hover {
    background: var(--bg-hover, #f0f0f0);
    border-color: var(--primary-color, #4a90d9);
    transform: translateX(5px);
}

.instruction-type-icon {
    font-size: 1.8rem;
    min-width: 40px;
    text-align: center;
}

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

.instruction-title {
    display: block;
    font-weight: 500;
    font-size: 1.05rem;
    color: var(--text-primary, #333);
    margin-bottom: 5px;
}

.instruction-meta {
    display: flex;
    gap: 15px;
    color: var(--text-secondary, #666);
    font-size: 0.85rem;
}

.instruction-arrow {
    font-size: 1.2rem;
    color: var(--text-secondary, #999);
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary, #666);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Просмотр инструкции */
.instruction-viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-tertiary, #fff);
    border-radius: 8px;
    overflow: hidden;
}

.viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    background: var(--bg-secondary, #f9f9f9);
}

.viewer-actions {
    display: flex;
    gap: 10px;
}

.instruction-content {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
}

.instruction-view-title {
    margin: 0 0 25px 0;
    font-size: 1.5rem;
    color: var(--text-primary, #333);
    border-bottom: 2px solid var(--primary-color, #4a90d9);
    padding-bottom: 15px;
}

.instruction-video {
    margin-bottom: 25px;
}

.instruction-video iframe,
.instruction-video video {
    width: 100%;
    max-width: 800px;
    height: 450px;
    border-radius: 8px;
    background: #000;
}

.instruction-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.instruction-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.instruction-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.instruction-text {
    line-height: 1.7;
    color: var(--text-primary, #333);
    font-size: 1rem;
}

.instruction-text h2,
.instruction-text h3,
.instruction-text h4 {
    margin-top: 25px;
    margin-bottom: 15px;
    color: var(--text-primary, #333);
}

.instruction-text ul {
    margin: 15px 0;
    padding-left: 25px;
}

.instruction-text li {
    margin-bottom: 8px;
}

.instruction-footer {
    display: flex;
    gap: 20px;
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color, #e0e0e0);
    color: var(--text-secondary, #666);
    font-size: 0.85rem;
}

/* Полноэкранный просмотр изображения */
.image-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.image-fullscreen-container {
    position: relative;
    max-width: 95%;
    max-height: 95%;
}

.image-fullscreen-container img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
}

.close-fullscreen {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    border: none;
    background: #fff;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Модальное окно - дополнительные стили */
.modal-sm .modal-content {
    max-width: 500px;
}

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

.icon-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.icon-selector input {
    width: 80px;
    text-align: center;
    font-size: 1.5rem;
}

.icon-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.icon-preset {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-preset:hover {
    background: var(--primary-light, #e8f4fd);
    transform: scale(1.1);
}

/* Табы типов контента */
.content-type-tabs {
    display: flex;
    gap: 5px;
    background: var(--bg-secondary, #f5f5f5);
    padding: 5px;
    border-radius: 8px;
}

.tab-btn {
    flex: 1;
    padding: 10px 15px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary, #666);
    transition: all 0.2s;
}

.tab-btn:hover {
    background: var(--bg-hover, rgba(0,0,0,0.05));
}

.tab-btn.active {
    background: var(--bg-tertiary, #fff);
    color: var(--primary-color, #4a90d9);
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.content-editor {
    min-height: 200px;
    font-family: inherit;
    resize: vertical;
}

/* Drop-zone для загрузки изображений */
.image-drop-zone {
    border: 2px dashed var(--border-color, #ccc);
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-secondary, #f9f9f9);
    margin-bottom: 15px;
}

.image-drop-zone:hover {
    border-color: var(--primary-color, #4a90d9);
    background: var(--primary-light, #e8f4fd);
}

.image-drop-zone.drag-over {
    border-color: var(--primary-color, #4a90d9);
    background: var(--primary-light, #e8f4fd);
    transform: scale(1.02);
}

.drop-zone-content {
    pointer-events: none;
}

.drop-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 10px;
    opacity: 0.6;
}

.drop-zone-content p {
    margin: 5px 0;
    color: var(--text-primary, #333);
}

.drop-zone-content .drop-hint {
    font-size: 0.85rem;
    color: var(--text-secondary, #666);
}

/* Список превью изображений */
.image-preview-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-secondary, #f5f5f5);
    border: 1px solid var(--border-color, #ddd);
}

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

.remove-image-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(220, 53, 69, 0.9);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.image-preview-item:hover .remove-image-btn {
    opacity: 1;
}

.remove-image-btn:hover {
    background: #c82333;
}

/* Секция добавления по URL */
.image-url-section,
.video-url-section {
    margin-top: 10px;
}

.image-url-input,
.video-url-input {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.image-url-input input,
.video-url-input input {
    flex: 1;
}

/* Drop-zone для видео */
.video-drop-zone {
    border: 2px dashed var(--border-color, #ccc);
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-secondary, #f9f9f9);
    margin-bottom: 15px;
}

.video-drop-zone:hover {
    border-color: var(--primary-color, #4a90d9);
    background: var(--primary-light, #e8f4fd);
}

.video-drop-zone.drag-over {
    border-color: var(--primary-color, #4a90d9);
    background: var(--primary-light, #e8f4fd);
    transform: scale(1.02);
}

/* Превью видео */
.video-preview-list {
    margin-bottom: 15px;
}

.video-preview-item {
    position: relative;
    width: 200px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-secondary, #f5f5f5);
    border: 1px solid var(--border-color, #ddd);
}

.video-preview-item img,
.video-preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-preview-item .video-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-secondary, #666);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.video-preview-item .video-source {
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.remove-video-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(220, 53, 69, 0.9);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.video-preview-item:hover .remove-video-btn {
    opacity: 1;
}

.remove-video-btn:hover {
    background: #c82333;
}

/* Адаптивность */
@media (max-width: 768px) {
    .instructions-container {
        flex-direction: column;
    }
    
    .instructions-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 200px;
    }
    
    .instruction-video iframe,
    .instruction-video video {
        height: 250px;
    }
    
    .content-type-tabs {
        flex-wrap: wrap;
    }
}
