/* Reset и базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

/* Контейнер */
.container {
    max-width: 1800px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

/* Шапка */
.header {
    background: linear-gradient(135deg, #4361ee 0%, #3a0ca3 100%);
    color: white;
    padding: 25px 40px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
}

.header h1 {
    font-size: 26px;
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.subtitle {
    font-size: 14px;
    opacity: 0.9;
    font-weight: 400;
}

/* Основная структура */
.main-wrapper {
    display: grid;
    grid-template-columns: 380px 1fr;
    flex: 1;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    min-height: 0;
}

.sidebar {
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    padding: 25px;
    overflow-y: auto;
    min-height: 0;
}

.content {
    padding: 25px;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Карточки */
.card {
    background: white;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transition: all 0.3s ease;
}

.card.collapsed {
    margin-bottom: 5px;
}

.card.collapsed .card-header {
    border-bottom: none;
}

.card-header {
    background: #f7fafc;
    padding: 18px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.card-header:hover {
    background: #edf2f7;
}

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

.card-header .header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.collapse-btn {
    background: none;
    border: none;
    color: #718096;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.collapse-btn:hover {
    color: #4361ee;
    background: rgba(67, 97, 238, 0.1);
}

.collapse-icon {
    font-size: 14px;
    transition: transform 0.3s ease;
}

.card-body {
    padding: 20px;
    transition: all 0.3s ease;
}

.card.collapsed .card-body {
    display: none;
}

/* Выбор схемы */
.schema-selector {
    margin-bottom: 20px;
}

.schema-selector label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
    font-size: 14px;
}

.form-select {
    width: 100%;
    padding: 11px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #2d3748;
    background: white;
    transition: all 0.2s;
    margin-bottom: 12px;
}

.form-select:focus {
    outline: none;
    border-color: #4361ee;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.schema-info {
    background: #f8fafc;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-label {
    font-size: 13px;
    color: #718096;
}

.info-value {
    font-size: 13px;
    font-weight: 600;
    color: #2d3748;
}

/* Детали схемы */
.schema-details {
    border-top: 1px solid #e2e8f0;
    padding-top: 20px;
    margin-top: 20px;
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.details-header h4 {
    font-size: 15px;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
}

.detail-item {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-size: 12px;
    color: #718096;
    margin-bottom: 3px;
    font-weight: 500;
}

.detail-value {
    font-size: 14px;
    color: #2d3748;
    font-weight: 500;
}

.required-fields {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.field-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.field-tag {
    background: #fed7d7;
    color: #c53030;
    padding: 5px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #fc8181;
}

/* Код блоки */
.code-block {
    background: #1a1d23;
    border-radius: 8px;
    padding: 16px;
    max-height: 900px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.code-block pre {
    margin: 0;
    padding: 0;
    background: transparent !important;
}

.code-block code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
}

/* Редактор */
.editor-wrapper {
    position: relative;
    margin-bottom: 16px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    height: 550px;
}

#json-input {
    width: 100%;
    height: 100%;
    padding: 16px;
    border: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    color: #2d3748;
    background: white;
}

#json-input:focus {
    outline: none;
}

#error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

.editor-info {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #718096;
    white-space: nowrap;
}

.editor-info span {
    font-family: 'Consolas', 'Monaco', monospace;
}

/* Кнопки */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: translateY(0);
}

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

.btn-primary {
    background: #4361ee;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #3a56d4;
}

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

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c82333;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #218838;
}

.btn-sm {
    padding: 7px 14px;
    font-size: 12px;
}

/* Группы элементов */
.editor-controls {
    margin-top: 16px;
}

.control-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.example-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.example-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #718096;
}

/* Состояния пустоты */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #a0aec0;
    text-align: center;
}

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

.empty-state p {
    font-size: 14px;
    margin: 0;
}

/* Результаты валидации */
.validation-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 16px;
    border-radius: 8px;
}

.validation-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 16px;
    border-radius: 8px;
}

.validation-success h4,
.validation-error h4 {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
}

.error-list {
    list-style: none;
    margin-top: 12px;
}

.error-list li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(220, 53, 69, 0.2);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
}

.error-list li:last-child {
    border-bottom: none;
}

.error-line-info {
    margin-top: 16px;
    padding: 12px;
    background: rgba(220, 53, 69, 0.05);
    border-radius: 6px;
    border-left: 4px solid #dc3545;
}

.error-line-info h5 {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.line-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.line-number {
    background: #dc3545;
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    font-weight: 500;
}

/* Панель управления сворачиванием */
.collapse-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.code-block::-webkit-scrollbar-track {
    background: #1e2229;
}

.code-block::-webkit-scrollbar-thumb {
    background: #4a5568;
}

.code-block::-webkit-scrollbar-thumb:hover {
    background: #718096;
}

.sidebar::-webkit-scrollbar-track,
.content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.content::-webkit-scrollbar-thumb {
    background: #cbd5e0;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.content::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Анимации */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-body {
    animation: slideDown 0.3s ease-out;
}