/* ===== Макет редактора: кнопки слева, документ справа ===== */
.main-content {
    display: flex;
    height: calc(100vh - 100px); /* минус высота заголовка */
}

/* Левая панель с кнопками и формами */
.sidebar {
    width: 300px;
    background-color: #ecf0f1;
    padding: 20px;
    border-right: 1px solid #ddd;
    overflow-y: auto;
}

.sidebar h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

.sidebar section {
    margin-bottom: 30px;
}

/* Правая часть с документом */
.editor-area {
    flex: 1;
    padding: 20px;
    overflow: auto;
    background-color: #fafafa;
}

/* Чтобы documentViewer занимал всю доступную ширину справа */
#documentViewer {
    position: relative;
    border: 2px dashed #ddd;
    border-radius: 10px;
    min-height: 500px;
    background-color: #fff;
    padding: 10px;
}

/* Панель свойств поля */
#fieldProperties {
    background-color: #fff;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #ddd;
    margin-top: 10px;
}

#fieldProperties h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2c3e50;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
}

#fieldProperties label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #2c3e50;
}

#fieldProperties textarea {
    width: 100%;
    min-height: 80px;
    margin-bottom: 10px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-family: inherit;
    resize: vertical;
}

#fieldProperties textarea:focus {
    border-color: #3498db;
    outline: none;
}

/* ========== Общие базовые стили ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background-color: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* Заголовок */
.header {
    background-color: #2c3e50;
    color: white;
    padding: 20px;
    border-bottom: 3px solid #3498db;
}

.header h1 {
    margin-bottom: 15px;
    font-size: 2rem;
}

/* Кнопки */
.btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

.btn:hover:not(:disabled) {
    background-color: #2980b9;
}

.btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

.btn-large {
    padding: 15px 30px;
    font-size: 16px;
}

.btn-danger {
    background-color: #e74c3c;
}

.btn-danger:hover {
    background-color: #c0392b;
}

/* Инпуты и селекты */
.input, .select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    width: 100%;
}

.select {
    min-width: 200px;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #2c3e50;
}

.form-group .input,
.form-group .select {
    width: 100%;
}

/* ========== Область редактора (editor.js) ========== */
.document-page {
    position: relative;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
    background-color: white;
    display: inline-block;
}

.document-page img {
    width: 100%;
    height: auto;
    display: block;
    position: relative;
    z-index: 0;
}

/* Поля для редактора */
.field {
    position: absolute;
    border: 2px solid #3498db;
    background-color: rgba(52, 152, 219, 0.1);
    cursor: move;
    padding: 2px;
    border-radius: 3px;
    min-width: 50px;
    min-height: 20px;
    z-index: 10;
    touch-action: none;
    user-select: none;
    box-sizing: border-box;
}

.field:hover {
    border-color: #2980b9;
    background-color: rgba(52, 152, 219, 0.2);
}

.field.selected {
    border: 2px solid #e74c3c !important;
    background-color: rgba(231, 76, 60, 0.1);
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.3);
}

/* Визуальные индикаторы для изменения размера */
.field::after {
    content: '';
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 12px;
    height: 12px;
    background-color: #3498db;
    border: 2px solid white;
    border-radius: 50%;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 20;
    pointer-events: none;
}

.field:hover::after,
.field.selected::after {
    opacity: 1;
    pointer-events: auto;
}

.field.selected::after {
    background-color: #e74c3c;
}

/* Дополнительные ручки для resize */
.field::before {
    content: '';
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 12px 12px;
    border-color: transparent transparent #3498db transparent;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 19;
    pointer-events: none;
}

.field:hover::before,
.field.selected::before {
    opacity: 0.5;
}

/* Состояние изменения размера */
.field.resizing {
    border-color: #f39c12 !important;
    background-color: rgba(243, 156, 18, 0.2) !important;
    box-shadow: 0 0 15px rgba(243, 156, 18, 0.5) !important;
}

.field input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    font-size: 14px;
    padding: 2px 5px;
    pointer-events: none; /* чтобы не мешало перетаскиванию */
}

.field input:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.9);
    pointer-events: auto;
}

/* ========== Поля для студентов (student.js) ========== */
.student-field-wrapper {
    position: absolute;
    z-index: 20;
    pointer-events: auto;
    overflow: hidden;
    display: block;
}

.student-field {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    border: 1px solid #3498db;
    background: rgba(255,255,255,0.95);
    font-size: 14px;
    color: #2c3e50;
    border-radius: 3px;
    outline: none;
    padding: 4px 6px;
    line-height: 1.3;
    -webkit-appearance: none;
    touch-action: manipulation; /* уменьшает неожиданные blur на мобильных */
}

.student-field:focus {
    border-color: #1e90ff;
    background: rgba(255,255,255,1);
    box-shadow: 0 0 6px rgba(30,144,255,0.25);
}

/* ========== Формы студента ========== */
.student-form {
    max-width: 500px;
    margin: 50px auto;
    padding: 30px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.student-form h2 {
    margin-bottom: 30px;
    text-align: center;
    color: #2c3e50;
}

/* ========== Тестовая область ========== */
.test-area {
    padding: 20px;
}

.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #ecf0f1;
    border-radius: 5px;
    margin-bottom: 20px;
}

.student-info {
    font-weight: bold;
    color: #2c3e50;
}

.progress {
    color: #7f8c8d;
}

/* Навигация по страницам */
.page-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #ecf0f1;
    border-radius: 5px;
}

.page-navigation .btn {
    min-width: 100px;
}

/* Управление тестом */
.test-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
    align-items: center;
}

.test-controls .btn {
    min-width: 200px;
}

/* ========== Результаты теста ========== */
.results {
    max-width: 800px;
    margin: 50px auto;
    padding: 30px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.results h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #2c3e50;
}

.score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
    padding: 30px;
    background-color: #ecf0f1;
    border-radius: 10px;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: #3498db;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    font-weight: bold;
}

.score-details {
    text-align: left;
}

.score-details p {
    margin-bottom: 10px;
    font-size: 16px;
}

/* Разбор ответов */
.answer-review {
    margin-top: 30px;
}

.answer-review h3 {
    margin-bottom: 20px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

/* ========== Модальное окно ========== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 20px;
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
    text-align: center;
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 15px;
    top: 10px;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

/* Placeholder стили */
.placeholder {
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.efficiency-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.efficiency-badge.good {
    background: #d4edda;
    color: #155724;
}

.efficiency-badge.neutral {
    background: #fff3cd;
    color: #856404;
}

.efficiency-badge.poor {
    background: #f8d7da;
    color: #721c24;
}

/* ===== МОБИЛЬНАЯ ВЕРСИЯ ДЛЯ СТУДЕНТОВ ===== */
@media (max-width: 768px) {
    .container {
        max-width: 100%;
        margin: 0;
        box-shadow: none;
        min-height: 100vh;
    }

    .header {
        padding: 15px;
        text-align: center;
    }

    .header h1 {
        font-size: 1.5rem;
        margin-bottom: 10px;
    }

    .student-form {
        max-width: 100%;
        margin: 20px 15px;
        padding: 20px;
        border-radius: 0;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .student-form h2 {
        font-size: 1.3rem;
        margin-bottom: 20px;
    }

    .input, .select {
        font-size: 16px;
        padding: 12px;
        height: auto;
    }

    .test-area {
        padding: 10px 5px;
    }

    .test-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 10px;
    }

    .page-navigation {
        justify-content: space-between;
        margin-bottom: 15px;
    }

    .page-navigation .btn {
        min-width: 80px;
        padding: 8px 12px;
    }

    .student-field {
        font-size: 14px !important;
        padding: 0 4px !important;
        min-height: 18px !important;
        border-width: 1px !important;
        line-height: 1 !important;
    }

    .student-field-wrapper {
        max-width: 200px !important;
        max-height: 40px !important;
        min-width: 25px !important;
        min-height: 18px !important;
    }

    .results {
        max-width: 100%;
        margin: 20px 15px;
        padding: 20px;
        border-radius: 0;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .results h2 {
        font-size: 1.3rem;
    }

    .score {
        flex-direction: column;
        gap: 20px;
        padding: 20px;
    }

    .score-circle {
        width: 100px;
        height: 100px;
        font-size: 20px;
    }

    .modal-content {
        width: 90%;
        margin: 20% auto;
        padding: 20px;
    }
}

/* ===== Для очень маленьких экранов ===== */
@media (max-width: 480px) {
    .header {
        padding: 10px;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .student-form,
    .results {
        margin: 10px;
        padding: 15px;
    }

    .score-circle {
        width: 80px;
        height: 80px;
        font-size: 18px;
    }

    .test-header {
        font-size: 0.9rem;
    }
}
