/* Reference Tool VIZ - Основные стили */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #ffffff;
    color: #1f2937;
    line-height: 1.6;
    overflow: hidden;
}

#reference-container {
    width: 100%;
    height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Toolbar */
.editor-toolbar {
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-wrap: wrap;
}

.toolbar-block {
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-right: 8px;
    margin-bottom: 6px;
    min-width: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.toolbar-block.actions-block {
    margin-left: auto;
    margin-right: 0;
    align-self: center;
}

.toolbar-block.actions-block .block-content {
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
}

.block-title {
    font-size: 10px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    border-bottom: 1px solid #f3f4f6;
    background: #f8f9fa;
    border-radius: 5px 5px 0 0;
}

.block-content {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
}

.tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tool-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.tool-btn:active {
    background: #e5e7eb;
    transform: scale(0.95);
}

/* Active state for toggles (bold, italic, underline, alignment, lists) */
.tool-btn.active {
    background: #eef2ff;
    border-color: #c7d2fe;
    box-shadow: inset 0 0 0 1px #8677c4;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #374151;
    width: 16px;
    height: 16px;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

.format-select {
    min-width: 140px;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    padding: 0 8px;
    font-size: 13px;
    margin-right: 8px;
}

.size-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.size-input {
    width: 48px;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
}

.size-label {
    font-size: 11px;
    color: #6b7280;
    font-weight: 500;
}

.color-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    padding: 8px;
}

.color-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
}

.color-label {
    font-size: 10px;
    color: #6b7280;
    font-weight: 500;
    margin-top: 2px;
}

.color-trigger {
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    padding: 4px;
    transition: all 0.15s ease;
}

.color-trigger:hover {
    border-color: #8677c4;
    box-shadow: 0 0 0 2px rgba(134, 119, 196, 0.1);
}

.color-preview {
    width: 100%;
    height: 100%;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1);
}

.color-popup {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 12px;
    z-index: 1000;
    min-width: 200px;
}

.color-popup-header {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.color-hex-input {
    flex: 1;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
}

.color-picker-input {
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
}

.color-swatches {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    cursor: pointer;
    transition: all 0.15s ease;
}

.color-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.toolbar-spacer {
    flex: 1;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid #e5e7eb;
    margin-right: 8px;
    min-width: 0;
    white-space: nowrap;
}

.action-btn.primary {
    background: #8677c4;
    color: white;
    border-color: #8677c4;
}

.action-btn.primary:hover {
    background: #7568b5;
    border-color: #7568b5;
}

.action-btn.secondary {
    background: white;
    color: #6b7280;
}

.action-btn.secondary:hover {
    background: #f9fafb;
    color: #374151;
}

.action-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.action-text {
    font-size: 13px;
    font-weight: 500;
}

@media (max-width: 768px) {
    .editor-toolbar {
        padding: 8px;
        gap: 6px;
    }
    
    .toolbar-block {
        margin-right: 6px;
        margin-bottom: 6px;
    }
    
    .format-select {
        min-width: 120px;
    }
}

/* Область контента */
.reference-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Сообщение об отсутствии данных */
.message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    text-align: center;
    color: #6b7280;
}

/* По умолчанию сообщение о пустых данных скрыто, показываем только явно из JS */
#no-data-message { display: none; }

.message svg {
    margin-bottom: 16px;
    opacity: 0.7;
}

.message h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
}

.message p {
    font-size: 0.875rem;
    max-width: 300px;
    line-height: 1.5;
}

/* Форматированный текст */
.formatted-text {
    width: 100%;
    height: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    outline: none;
}

/* Базовые стили текста - будут переопределяться через настройки */
.formatted-text h1,
.formatted-text h2,
.formatted-text h3,
.formatted-text h4,
.formatted-text h5,
.formatted-text h6 {
    margin-bottom: 0.75em;
    font-weight: 600;
    line-height: 1.3;
}

.formatted-text p {
    margin-bottom: 1em;
    line-height: 1.6;
}

.formatted-text ul,
.formatted-text ol {
    margin-bottom: 1em;
    padding-left: 1.5em;
}

.formatted-text li {
    margin-bottom: 0.25em;
}

.formatted-text blockquote {
    margin: 1em 0;
    padding-left: 1em;
    border-left: 4px solid #e5e7eb;
    font-style: italic;
}

.formatted-text code {
    background: #f3f4f6;
    padding: 0.125em 0.25em;
    border-radius: 0.25em;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.875em;
    color: #111827;
}

.formatted-text pre {
    background: #0f172a;
    color: #e5e7eb;
    padding: 12px 14px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1em;
    border: 1px solid rgba(255,255,255,0.08);
}

.formatted-text pre code {
    background: none;
    padding: 0;
}
.symbol-popup {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 8px;
    z-index: 1000;
}

.symbols-wrapper {
    position: relative;
    display: inline-block;
}

.symbol-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.symbol-tab {
    padding: 4px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
}

.symbol-tab.active {
    background: #eef2ff;
    border-color: #c7d2fe;
}

.symbol-grid {
    display: grid;
    grid-template-columns: repeat(8, 32px);
    gap: 6px;
}

.symbol-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 16px;
}

.symbol-btn:hover {
    background: #f3f4f6;
}

/* Syntax accents inside code */
.formatted-text .tok-field {
    color: #f59e0b;
    font-weight: 600;
}

.formatted-text .tok-func {
    color: #2563eb;
    font-weight: 600;
}

/* Загрузочный индикатор */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #8677c4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    color: #6b7280;
    font-size: 0.875rem;
}

/* Адаптивные стили */
@media (max-width: 768px) {
    .reference-content {
        padding: 16px;
    }
    
    .message h3 {
        font-size: 1.125rem;
    }
    
    .message p {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .reference-content {
        padding: 12px;
    }
    
    .formatted-text ul,
    .formatted-text ol {
        padding-left: 1.25em;
    }
}

/* Скрытые элементы */
#status {
    position: fixed;
    top: 10px;
    left: 10px;
    background: #1f2937;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    z-index: 9999;
}
