/* Стили для страницы создания комплексного урока */

/* Превью всех страниц PDF урока (как на странице рабочих листов) */
.worksheet-pdf-pages-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: flex-start;
    align-items: flex-start;
}
.worksheet-pdf-page-preview {
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 700px;
    object-fit: contain;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    background: #fff;
}

/* Двухколоночный макет: форма слева, инструкция справа */
.lesson-container {
    display: grid;
    grid-template-columns: minmax(800px, 1200px) 320px;
    gap: 2rem;
    width: 100%;
    max-width: calc(1200px + 320px + 2rem);
    margin: 0 auto 2rem auto;
    padding: 0 1rem;
    align-items: start;
    box-sizing: border-box;
}

/* Переопределяем ограничения Bootstrap container для правильного центрирования */
main.container {
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
}

main.container > .lesson-container {
    margin-left: auto;
    margin-right: auto;
}

.lesson-content {
    flex: 1;
}

.instructions-sidebar {
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
}

.instructions-card {
    background: white;
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 120px);
}

.instruction-section {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
}

.instruction-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.instruction-section h4 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--dark, #1e293b);
    margin: 0 0 0.75rem 0;
}

.instruction-section ol,
.instruction-section ul {
    padding-left: 1.5rem;
    margin: 0;
}

.instruction-section li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.instruction-section p {
    line-height: 1.6;
    color: var(--gray-700, #374151);
}

.instruction-section .alert-link {
    color: var(--primary, #4361ee);
    text-decoration: underline;
}

.instruction-section .alert-link:hover {
    color: var(--primary-dark, #2d4cdd);
}

/* Адаптивность для мобильных */
@media (max-width: 1400px) {
    .lesson-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        max-width: 100%;
        padding: 0 0.5rem;
    }
    
    .instructions-sidebar {
        position: static;
        max-height: none;
    }
    
    .instructions-card {
        max-height: none;
    }
}

.task-checkbox-card {
    position: relative;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    padding: 1rem;
    transition: all 0.3s ease;
    background: white;
    cursor: pointer;
    height: 100%;
}

.task-checkbox-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Только главный чекбокс выбора типа задания (не чекбоксы внутри .task-options) */
.task-checkbox-card > input[type="checkbox"] {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    z-index: 10;
}

.task-checkbox-card > input[type="checkbox"]:checked + .task-label {
    color: var(--primary);
}

.task-checkbox-card:has(> input[type="checkbox"]:checked) {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.05) 0%, rgba(58, 12, 163, 0.05) 100%);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.15);
}

.task-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    padding-top: 0.5rem;
    transition: all 0.3s ease;
}

.task-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    transition: transform 0.3s ease;
}

.task-checkbox-card:hover .task-icon {
    transform: scale(1.1);
}

.task-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    color: var(--dark);
}

.task-desc {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.task-options {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
    display: none;
    animation: slideDown 0.3s ease;
}

.task-checkbox-card:has(> input[type="checkbox"]:checked) .task-options {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.task-options .form-select,
.task-options .form-control {
    font-size: 0.875rem;
}

/* Адаптивность */
@media (max-width: 768px) {
    .lesson-container {
        padding: 0 0.25rem;
    }

    .lesson-page .lead br {
        display: none;
    }

    .lesson-content .card-body {
        padding: 1rem !important;
    }

    .task-checkbox-card {
        margin-bottom: 1rem;
    }
    
    .task-icon {
        font-size: 2rem;
    }
    
    .task-name {
        font-size: 1rem;
    }

    .lesson-actions {
        align-items: stretch !important;
    }

    .lesson-actions .btn,
    .lesson-actions form,
    .lesson-actions form .btn {
        width: 100%;
        margin: 0 !important;
    }

    .result-section {
        padding-top: 1rem;
        padding-bottom: 1rem;
        max-height: none;
    }

    .result-wrapper .result-actions {
        padding: 0.75rem 1rem;
    }

    .result-actions .btn {
        width: 100%;
    }

    .sudoku-grid td {
        width: auto !important;
        height: auto !important;
        min-width: 32px;
        min-height: 32px;
        font-size: 0.75rem !important;
        padding: 0.25rem !important;
    }

    .sudoku-4x4 td {
        min-width: 52px;
        min-height: 52px;
        font-size: 0.9rem !important;
    }

    .sudoku-6x6 td {
        min-width: 40px;
        min-height: 40px;
        font-size: 0.8rem !important;
    }
}

/* Анимация загрузки */
.btn-loading {
    position: relative;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

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

/* Улучшенный дизайн формы */
#lessonForm .form-label {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

#lessonForm .form-control-lg {
    border-radius: var(--radius-md);
    border: 2px solid var(--gray-300);
    transition: all 0.3s ease;
}

#lessonForm .form-control-lg:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(67, 97, 238, 0.25);
}

#words {
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Информационный блок */
.alert-info {
    border-left: 4px solid var(--primary);
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.05) 0%, rgba(58, 12, 163, 0.05) 100%);
    border-radius: var(--radius-md);
}

.alert-info ol {
    padding-left: 1.5rem;
}

.alert-info li {
    margin-bottom: 0.5rem;
}

/* Выделение выбранных заданий */
.task-checkbox-card:has(> input[type="checkbox"]:checked) .task-name {
    color: var(--primary);
    font-weight: 700;
}

/* Плавные переходы */
.task-checkbox-card,
.task-label,
.task-icon {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Обертка для результатов и кнопок */
.result-wrapper {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
}

/* Стили для превью заданий - только прокручиваемая область */
.result-section {
    scroll-margin-top: 2rem;
    padding-top: 2rem;
    padding-bottom: 2rem;
    border-top: 2px solid var(--gray-200);
    border-bottom: none;
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 1;
}

/* Кнопки действий - полностью отделены от result-section, всегда видны вне прокрутки */
.result-wrapper .result-actions {
    background: white;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: 1rem 2rem;
    border: 1px solid rgba(67, 97, 238, 0.1);
    border-top: 1px solid rgba(67, 97, 238, 0.2);
    margin-top: 0;
    flex-shrink: 0;
    position: relative;
    z-index: 0;
}

/* Стилизация скроллбара для result-section */
.result-section::-webkit-scrollbar {
    width: 8px;
}

.result-section::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.result-section::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.result-section::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Убираем закругления у всех элементов внутри worksheet-card в секции результатов */
/* Внешняя карточка остается закругленной, но внутренние элементы - нет */

/* Убираем закругления у самой карточки в секции результатов */
#result-section .worksheet-card,
.result-section .worksheet-card {
    border-radius: 0 !important;
}

.result-section .worksheet-card .list-group-item {
    border-radius: 0 !important;
}

.result-section .worksheet-card .list-group-item:first-child {
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
}

.result-section .worksheet-card .list-group-item:last-child {
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.result-section .worksheet-card .table {
    border-radius: 0 !important;
}

.result-section .worksheet-card .table td,
.result-section .worksheet-card .table th {
    border-radius: 0 !important;
}

.result-section .worksheet-card .table thead tr:first-child th:first-child {
    border-top-left-radius: 0 !important;
}

.result-section .worksheet-card .table thead tr:first-child th:last-child {
    border-top-right-radius: 0 !important;
}

.result-section .worksheet-card .table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 0 !important;
}

.result-section .worksheet-card .table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 0 !important;
}

.bingo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.bingo-card {
    border: 2px solid var(--primary);
    border-radius: 0;
    padding: 1rem;
}

.bingo-card table {
    margin-bottom: 0;
    border-radius: 0 !important;
}

.bingo-card table td,
.bingo-card table th {
    border-radius: 0 !important;
}

.dobble-cards img {
    border-radius: 0;
    box-shadow: var(--shadow-md);
}

.sudoku-grid {
    border-radius: 0 !important;
}

.sudoku-grid.sudoku-4x4 {
    max-width: 400px;
    margin: 0 auto;
}

.sudoku-grid.sudoku-6x6 {
    max-width: 500px;
    margin: 0 auto;
}

.sudoku-grid.sudoku-9x9 {
    max-width: 600px;
    margin: 0 auto;
}

.sudoku-4x4 .sudoku-cell {
    width: 80px;
    height: 80px;
    font-size: 16px;
    font-weight: bold;
}

.sudoku-6x6 .sudoku-cell {
    width: 60px;
    height: 60px;
    font-size: 14px;
    font-weight: bold;
}

.sudoku-9x9 .sudoku-cell {
    width: 50px;
    height: 50px;
    font-size: 12px;
    font-weight: bold;
}

.sudoku-grid td {
    border: 2px solid var(--gray-400);
    border-radius: 0 !important;
}

.sudoku-grid td.filled {
    background-color: var(--gray-100);
}

.sudoku-grid td.empty {
    background-color: white;
}

/* Кнопки действий с результатами */
.result-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.result-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px; /* Единая высота для всех кнопок */
    padding: 0.625rem 1.5rem;
    white-space: nowrap;
    font-weight: 600;
    border-radius: var(--radius-full, 50px);
}

.result-actions .btn-outline-primary {
    border: 2px solid var(--primary, #4361ee);
    color: var(--primary, #4361ee);
    background: transparent;
    transition: all 0.3s ease;
}

.result-actions .btn-outline-primary:hover {
    background: var(--primary, #4361ee);
    color: white;
    border-color: var(--primary, #4361ee);
}

/* Рамка фокуса для всей обертки, включая кнопки - без разделения */
.result-wrapper:focus-within {
    outline: 2px solid var(--primary, #0d6efd);
    outline-offset: 2px;
    border-radius: var(--radius-lg);
}

/* Убираем отдельную рамку у result-section, чтобы не было разделения */
.result-section:focus {
    outline: none;
}

@media (max-width: 420px) {
    .sudoku-grid td {
        min-width: 28px;
        min-height: 28px;
        font-size: 0.7rem !important;
    }

    .sudoku-4x4 td {
        min-width: 46px;
        min-height: 46px;
    }

    .sudoku-6x6 td {
        min-width: 34px;
        min-height: 34px;
    }
}
