/* ======================================================
   responsive.css — адаптив для планшетов и мобильных
   ====================================================== */

/* ===== БУРГЕР-МЕНЮ (появляется с 1024px) ===== */
.nav-burger {
    display: none;               /* по умолчанию скрыт */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 5;
    flex-shrink: 0;
}

.nav-burger span {
    display: block;
    width: 26px;
    height: 3px;
    background-color: #193D50;
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

/* Когда меню открыто — превращаем три полоски в крестик */
.nav-burger.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.nav-burger.active span:nth-child(2) {
    opacity: 0;
}

.nav-burger.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* Затемнение страницы позади выезжающего меню */
.mobile-menu-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background-color: rgba(15, 30, 40, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 600;
}

.mobile-menu-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* Мобильное меню: полноэкранная (по высоте) панель, которая выезжает
   справа поверх страницы — не занимает место в потоке документа и не
   сдвигает контент под шапкой вниз. */
.mobile-menu {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    height: 100dvh;
    width: min(85vw, 380px);
    background-color: white;
    box-shadow: -8px 0 30px rgba(15, 30, 40, 0.18);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 700;
    overflow-y: auto;
}

.mobile-menu.show {
    transform: translateX(0);
}

.mobile-menu-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px;
    border-bottom: 1px solid #eef1f4;
    flex-shrink: 0;
}

.mobile-menu-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #193D50;
    font-weight: bold;
    font-size: 14px;
    line-height: 1.2;
}

.mobile-menu-close {
    position: relative;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-menu-close span {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 3px;
    background-color: #193D50;
    border-radius: 2px;
}

.mobile-menu-close span:first-child {
    transform: translate(-50%, -50%) rotate(45deg);
}

.mobile-menu-close span:last-child {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.mobile-menu-links {
    display: flex;
    flex-direction: column;
    padding: 8px 0 24px;
}

.mobile-menu a {
    position: relative;
    color: #193D50;
    text-decoration: none;
    font-size: 17px;
    padding: 14px 24px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.mobile-menu a:hover {
    background-color: #f4f7f9;
    color: #1867AA;
}

.mobile-menu a.active {
    color: #AA1818;
    font-weight: 600;
    background-color: #f8f2f2;
}

.mobile-menu-logout {
    color: #AA1818 !important;
}

.mobile-menu-divider {
    height: 1px;
    background-color: #e4e4e4;
    margin: 10px 24px;
}

/* Блокируем прокрутку страницы, пока меню открыто. position:fixed +
   width:100% (в дополнение к overflow:hidden) нужен, чтобы страница не
   прокручивалась свайпом фона на iOS Safari, где overflow:hidden на body
   сам по себе не блокирует touch-scroll. Смещение по top выставляется
   через JS (toggleMobileMenu) равным прежнему scrollY. */
body.mobile-menu-open {
    overflow: hidden;
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
}

/* ========== АДАПТИВ ========== */
@media (max-width: 1024px) {
    .nav-links,
    .nav-profile {
        display: none !important;
    }
    .nav-burger {
        display: flex !important;
        flex-shrink: 0;
    }
}

/* Логотип в шапке: на узких экранах текст должен ужиматься/скрываться,
   иначе он выталкивает бургер за пределы экрана и ломает шапку. */
@media (max-width: 1024px) {
    nav {
        flex-wrap: nowrap;
    }
    .nav-logo {
        flex-shrink: 1;
        min-width: 0;
        overflow: hidden;
    }
}

@media (max-width: 560px) {
    .nav-logo-img {
        width: 36px !important;
        height: 29px !important;
    }
    .nav-logo-text {
        font-size: 13px !important;
        max-width: 110px;
    }
}

@media (max-width: 400px) {
    .nav-logo-img {
        width: 30px !important;
        height: 24px !important;
    }
    .nav-logo-text {
        font-size: 11px !important;
        max-width: 90px;
    }
}

@media (max-width: 340px) {
    .nav-logo-img {
        width: 26px !important;
        height: 21px !important;
    }
    .nav-logo-text {
        font-size: 10px !important;
        max-width: 76px;
    }
}

/* ============== ПЛАНШЕТ (≤1200px) ============== */
@media (max-width: 1200px) {
    nav {
        padding: 22px 40px !important;
    }

    .footer-inner {
        padding: 40px 40px 24px !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 30px !important;
    }

    .footer-bottom {
        padding: 18px 40px !important;
    }

    .hero,
    .landing-section {
        padding-left: 50px !important;
        padding-right: 50px !important;
    }

    .landing-about {
        grid-template-columns: 1fr !important;
        gap: 30px !important;
    }

    .landing-news-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .lessons-wrap,
    .news-wrap,
    .news-page-wrap,
    .lesson-page-wrap,
    .lesson-form-wrap,
    .admin-wrap,
    .materials-wrap {
        padding-left: 50px !important;
        padding-right: 50px !important;
    }

    .lessons-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .lesson-form-grid {
        grid-template-columns: 1fr !important;
    }

    .admin-actions {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    input, select {
        width: 100% !important;
    }
}

/* ============== МОБИЛЬНЫЕ (≤768px) ============== */
@media (max-width: 768px) {
    nav {
        padding: 16px 20px !important;
    }

    .hero,
    .landing-section,
    .page-header-block,
    .page-header-block-compact,
    .profile-header-block {
        padding-left: 24px !important;
        padding-right: 24px !important;
    }

    .profile-header-block {
        padding-top: 36px !important;
        padding-bottom: 24px !important;
    }

    .hero {
        padding-top: 85px !important;
        padding-bottom: 50px !important;
    }

    .hero-title {
        font-size: 30px !important;
    }

    .hero-subtitle {
        font-size: 16px !important;
    }

    .hero-actions {
        flex-direction: column;
    }

    .hero-btn {
        text-align: center;
    }

    .landing-marquee-track span {
        font-size: 18px !important;
    }

    .landing-about {
        grid-template-columns: 1fr !important;
    }

    .landing-about-text h2 {
        font-size: 22px !important;
    }

    .landing-news-grid {
        grid-template-columns: 1fr !important;
    }

    .footer-inner {
        grid-template-columns: 1fr !important;
        padding: 32px 24px 20px !important;
        gap: 28px !important;
    }

    .footer-bottom {
        padding: 16px 24px !important;
    }

    .lessons-wrap,
    .news-wrap,
    .news-page-wrap,
    .lesson-page-wrap,
    .lesson-form-wrap,
    .admin-wrap,
    .materials-wrap,
    .create-ad {
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    .lessons-grid {
        grid-template-columns: 1fr !important;
    }

    .lesson-meta-row {
        gap: 20px !important;
    }

    .embed-frame-body,
    .lesson-test-card {
        padding: 18px !important;
    }

    .lesson-form-card {
        padding: 22px !important;
    }

    .lesson-form-submit {
        font-size: 16px !important;
    }

    .news-import-row {
        flex-direction: column;
    }

    .news-import-btn {
        width: 100%;
    }

    .news-gallery {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .admin-actions {
        grid-template-columns: 1fr !important;
    }

    .admin-row-card {
        flex-wrap: wrap;
    }

    .profile-header-block {
        flex-direction: column !important;
        text-align: center;
        gap: 20px !important;
    }

    /* Таблицы (рейтинг) — карточки вместо горизонтального скролла */
    .table-container {
        overflow-x: visible;
        box-shadow: none;
        border: none;
        background: transparent;
    }

    #schoolsTable,
    #schoolsTable > thead,
    #schoolsTable > tbody,
    #schoolsTable > thead > tr,
    #schoolsTable > tbody > tr,
    #schoolsTable > thead > tr > th,
    #schoolsTable > tbody > tr > td {
        display: block;
    }

    #schoolsTable {
        min-width: 0;
        border-left: none;
        border-right: none;
    }

    #schoolsTable > thead {
        display: none;
    }

    #schoolsTable > tbody > tr.main-row {
        position: relative;
        background: white;
        border: 2px solid #193D50;
        border-radius: 16px;
        margin-bottom: 14px;
        padding: 8px 40px 8px 18px;
        box-shadow: 0 3px 10px rgba(25, 61, 80, 0.06);
        transition: box-shadow 0.2s ease, transform 0.12s ease,
                    border-radius 0.2s ease, margin 0.2s ease;
    }

    #schoolsTable > tbody > tr.main-row:active {
        transform: scale(0.99);
    }

    #schoolsTable > tbody > tr.main-row.expanded {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-bottom-color: transparent;
        margin-bottom: 0;
        box-shadow: 0 3px 10px rgba(25, 61, 80, 0.12);
    }

    #schoolsTable > tbody > tr.main-row::after {
        content: '';
        position: absolute;
        top: 24px;
        right: 18px;
        width: 9px;
        height: 9px;
        border-right: 2px solid #193D50;
        border-bottom: 2px solid #193D50;
        opacity: 0.45;
        transform: rotate(45deg);
        transition: transform 0.25s ease, opacity 0.25s ease;
    }

    #schoolsTable > tbody > tr.main-row.expanded::after {
        opacity: 0.8;
        transform: rotate(-135deg);
    }

    #schoolsTable > tbody > tr.detail-row {
        margin-bottom: 14px;
    }

    #schoolsTable > tbody > tr.detail-row.expanded {
        border: 2px solid #193D50;
        border-top: none;
        border-radius: 0 0 16px 16px;
        overflow: hidden;
        box-shadow: 0 3px 10px rgba(25, 61, 80, 0.12);
    }

    #schoolsTable > tbody > tr > td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        text-align: right;
        padding: 10px 0;
        border-bottom: 1px solid #eef1f4;
    }

    #schoolsTable > tbody > tr.main-row > td:last-of-type {
        border-bottom: none;
    }

    #schoolsTable > tbody > tr > td[data-label]::before {
        content: attr(data-label);
        color: #8a97a1;
        font-size: 12px;
        font-weight: 600;
        text-align: left;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex-shrink: 0;
    }

    #schoolsTable > tbody > tr > td.school-name-cell {
        color: #193D50;
        font-size: 15px;
    }

    #schoolsTable > tbody > tr > td.detail-content {
        display: block;
        text-align: center;
        padding: 0;
        border-bottom: none;
    }

    #schoolsTable > tbody > tr > td.table-loading-state,
    #schoolsTable > tbody > tr > td.table-empty-state,
    #schoolsTable > tbody > tr > td.table-error-state {
        display: block;
        text-align: center;
    }

    .school-students-list {
        padding: 14px 16px 18px;
        overflow-x: auto;
    }

    .school-students-table th,
    .school-students-table td {
        padding: 8px 10px;
        font-size: 13px;
    }

    .pagination {
        flex-direction: column;
        gap: 14px;
        align-items: stretch !important;
    }

    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .contacts-grid {
        grid-template-columns: 1fr !important;
        gap: 30px !important;
        padding: 40px 24px !important;
    }
}

/* ======================================================
   МОДАЛЬНЫЕ ОКНА НА МОБИЛЬНЫХ: разворачиваем на весь экран
   ======================================================
   На десктопе модалки — это карточка по центру затемнённого фона.
   На узких экранах такая карточка почти не оставляет места под
   контент (PDF, инструкция, просмотр изображения), поэтому на
   мобильных содержимое растягивается на весь видимый экран —
   без полей, без скругления углов, как нативный полноэкранный лист. */
@media (max-width: 640px) {
    .pdf-modal-box {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
    }

    #pdfModal {
        padding: 0 !important;
    }

    .webhook-modal-box {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
    }

    .webhook-modal-overlay {
        padding: 0 !important;
    }

    .news-modal {
        padding: 10px !important;
    }

    .news-modal-content {
        max-width: 100% !important;
        max-height: 80vh !important;
    }

    .confirm-modal-content {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
    }

    .confirm-modal {
        align-items: flex-end !important;
    }

    /* Старые/неиспользуемые в верстке .modal / .modal-overlay классы —
       на случай, если где-то ещё подключены */
    .modal-content,
    .modal-overlay .modal-content {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
    }
}

/* ============== МАЛЕНЬКИЕ ЭКРАНЫ (≤480px) ============== */
@media (max-width: 480px) {
    .hero-title {
        font-size: 24px !important;
    }

    .landing-stat-number {
        font-size: 30px !important;
    }

    .lesson-card-body h3,
    .news-block-text {
        font-size: 16px !important;
    }
}

/* ======================================================
   ДОПОЛНИТЕЛЬНЫЙ АДАПТИВ: профиль, новости, методички и т.д.
   ====================================================== */

@media (max-width: 1200px) {
    .page-content {
        padding-left: 50px !important;
        padding-right: 50px !important;
    }
}

@media (max-width: 768px) {
    .page-content {
        padding: 24px 20px !important;
    }

    .news-grid {
        grid-template-columns: 1fr !important;
    }

    .material-row {
        flex-wrap: wrap !important;
        gap: 14px !important;
    }

    .material-actions {
        width: 100% !important;
        justify-content: flex-start !important;
        flex-wrap: wrap !important;
    }

    .profile-header-block img,
    .profile-header-block .avatar-img-lg,
    .profile-header-block .avatar-placeholder-lg {
        width: 110px !important;
        height: 110px !important;
    }
}

@media (max-width: 480px) {
    .news-grid {
        gap: 18px !important;
    }

    .material-row {
        padding: 16px !important;
    }
}

/* ======================================================
   ФОРМЫ СОЗДАНИЯ/РЕДАКТИРОВАНИЯ
   ====================================================== */
@media (max-width: 900px) {
    .form-columns {
        flex-direction: column !important;
        gap: 0 !important;
    }

    .form-columns .left-column,
    .form-columns .right-column {
        width: 100% !important;
    }
}

@media (max-width: 768px) {
    .create-ad {
        margin-left: 0 !important;
        padding: 32px 20px !important;
    }

    .create-ad input,
    .create-ad select,
    .create-ad textarea {
        width: 100% !important;
    }
}

/* ======================================================
   ВИКТОРИНА
   ====================================================== */
@media (max-width: 480px) {
    .quiz-panel-game {
        padding: 24px 18px 28px !important;
    }

    .quiz-room-code {
        font-size: 30px !important;
    }

    .quiz-question-text {
        font-size: 20px !important;
    }

    .quiz-sidebar {
        right: 18px !important;
    }
}

/* ======================================================
   АВТОРИЗАЦИЯ / РЕГИСТРАЦИЯ / ВОССТАНОВЛЕНИЕ ПАРОЛЯ
   ====================================================== */
@media (max-width: 900px) {
    body {
        flex-direction: column !important;
        height: auto !important;
        min-height: 100vh !important;
        overflow: visible !important;
    }

    .banner {
        width: 100% !important;
        height: auto !important;
        border-radius: 0 0 28px 28px !important;
        border: none !important;
        border-bottom: 3px solid #BDBDBD !important;
        padding: 28px 20px !important;
        flex-shrink: 0;
    }

    .logo {
        width: 96px !important;
        margin-bottom: 14px !important;
    }

    .banner h1 {
        font-size: 22px !important;
        margin: 6px 0 !important;
    }

    .banner p {
        font-size: 15px !important;
    }

    .reg {
        width: 100% !important;
        height: auto !important;
        padding: 32px 20px 48px !important;
        justify-content: flex-start !important;
    }

    .reg h1 {
        font-size: 28px !important;
        margin-bottom: 22px !important;
    }

    form {
        width: 100% !important;
        max-width: 480px !important;
    }
}

@media (max-width: 480px) {
    .banner {
        padding: 20px 16px !important;
    }

    .logo {
        width: 72px !important;
        margin-bottom: 10px !important;
    }

    .banner h1 {
        font-size: 19px !important;
    }

    .banner p {
        font-size: 13px !important;
    }

    .reg {
        padding: 24px 16px 40px !important;
    }

    .reg h1 {
        font-size: 23px !important;
    }

    label {
        font-size: 16px !important;
    }

    input, select {
        padding: 12px !important;
        font-size: 15px !important;
    }

    .reg-btn {
        width: 100% !important;
    }

    .radio-group {
        flex-wrap: wrap !important;
        height: auto !important;
        gap: 14px 24px !important;
    }

    .drop-area,
    .avatar-preview-img {
        width: 100% !important;
        max-width: 224px;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .photo-container {
        flex-wrap: wrap !important;
        justify-content: center !important;
    }
}

/* ======================================================
   СТРАХОВКА ОТ ГОРИЗОНТАЛЬНОЙ ПРОКРУТКИ
   ====================================================== */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
    }

    img {
        max-width: 100%;
    }
}

/* ===== Bugfix 3.3 / 3.7 / 3.8 ===== */
nav {
    gap: clamp(12px, 2vw, 32px);
}

@media (max-width: 1366px) {
    nav {
        padding-inline: clamp(16px, 2vw, 32px) !important;
        gap: clamp(8px, 1.2vw, 20px) !important;
    }
    .nav-links {
        gap: clamp(8px, 1vw, 18px) !important;
        flex-wrap: nowrap;
        min-width: 0;
    }
}

@media (max-width: 1024px) {
    body {
        overflow-x: hidden;
    }
    nav > * {
        min-width: 0;
    }
}

/* ======================================================
   ФИНАЛЬНЫЙ АДАПТИВ: профиль, ЛК и редакторы
   ====================================================== */
@media (max-width: 1100px) {
    .profile-header-block-flex {
        gap: 22px !important;
    }
    .profile-header-identity {
        gap: 32px !important;
    }
    .profile-header-actions {
        justify-content: flex-end;
    }

    .edit-account-page {
        padding-left: 32px !important;
        padding-right: 32px !important;
    }
}

@media (max-width: 900px) {
    .profile-header-block-flex {
        flex-wrap: wrap !important;
        align-items: center !important;
    }
    .profile-header-identity {
        flex: 1 1 560px;
        min-width: 0;
    }
    .profile-header-actions {
        flex: 0 0 auto;
        margin-left: auto;
    }

    .edit-account-grid {
        grid-template-columns: 1fr !important;
    }
    .edit-account-card-wide {
        grid-column: auto !important;
    }
    .edit-account-avatar-card {
        grid-template-columns: minmax(0, 1fr) 210px !important;
    }

    .news-edit-header .confirm-form {
        margin-left: auto;
    }
}

@media (max-width: 760px) {
    .profile-header-block-flex {
        flex-direction: column !important;
        align-items: stretch !important;
        text-align: left !important;
    }
    .profile-header-identity {
        width: 100%;
        flex: 0 0 auto;
        gap: 22px !important;
        text-align: left !important;
    }
    .profile-header-actions {
        width: 100%;
        margin-left: 0 !important;
        justify-content: stretch !important;
    }
    .profile-header-action-btn,
    .profile-header-action-btn-primary {
        width: 100% !important;
        flex: 1 1 100% !important;
    }

    .edit-account-page {
        padding: 26px 16px 54px !important;
    }
    .edit-account-header {
        padding: 34px 24px 42px !important;
    }
    .edit-account-topline {
        align-items: flex-start !important;
        flex-direction: column !important;
    }
    .edit-account-avatar-card {
        grid-template-columns: 1fr !important;
    }
    .edit-account-avatar-preview-wrap {
        order: -1;
    }
    .edit-account-avatar-frame {
        width: 150px;
        height: 150px;
    }
    .edit-account-actions {
        flex-direction: column-reverse !important;
    }
    .edit-account-cancel-btn,
    .edit-account-save-btn {
        width: 100% !important;
    }

    .news-edit-header {
        gap: 18px !important;
    }
    .news-edit-header .confirm-form,
    .news-edit-header .news-delete-btn {
        width: 100% !important;
    }
    .news-edit-header .news-delete-btn {
        justify-content: center;
    }

    .publish-toggle-label {
        grid-template-columns: auto minmax(0, 1fr) !important;
        align-items: start !important;
    }
    .publish-toggle-state {
        grid-column: 2 !important;
        justify-self: start !important;
        margin-top: -2px;
    }
}

@media (max-width: 520px) {
    .profile-header-block {
        padding-left: 16px !important;
        padding-right: 16px !important;
        padding-top: 30px !important;
        padding-bottom: 22px !important;
    }
    .profile-header-identity {
        gap: 14px !important;
    }
    .profile-header-block .avatar-img-lg,
    .profile-header-block .avatar-placeholder-lg {
        width: 88px !important;
        height: 88px !important;
    }
    .profile-name {
        font-size: clamp(21px, 7vw, 30px) !important;
    }

    .page-content {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .edit-account-page {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    .edit-account-card {
        padding: 18px 14px !important;
        border-radius: 16px !important;
    }
    .edit-account-header-inner {
        gap: 20px;
    }
    .edit-account-back-btn {
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
    }

    .publish-toggle-card {
        padding: 15px !important;
    }
    .publish-toggle-text strong {
        font-size: 14px;
    }
    .publish-toggle-text small {
        font-size: 11.5px;
    }
}
