/* Общие стили, которые могут понадобиться для пустых страниц */
body {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    background: #f5f7fa;
    color: #323130;
    font-size: 14px;
    line-height: 1.4;
}

.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: .25rem;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

/* Стили для чекбоксов множественного выбора */
.financing-type-checkboxes,
.form-of-study-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.financing-type-checkbox-item,
.form-of-study-checkbox-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background-color: #fff;
    transition: all 0.2s ease;
    cursor: pointer;
}

.financing-type-checkbox-item:hover,
.form-of-study-checkbox-item:hover {
    border-color: #0078d4;
    background-color: #f8f9fa;
}

.financing-type-checkbox-item input[type="checkbox"],
.form-of-study-checkbox-item input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.financing-type-label,
.form-of-study-label {
    cursor: pointer;
    font-weight: 500;
    color: #323130;
    flex: 1;
}

.financing-type-checkbox-item input[type="checkbox"]:checked + .financing-type-label,
.form-of-study-checkbox-item input[type="checkbox"]:checked + .form-of-study-label {
    color: #0078d4;
    font-weight: 600;
}

.financing-type-checkbox-item input[type="checkbox"]:checked,
.form-of-study-checkbox-item input[type="checkbox"]:checked {
    accent-color: #0078d4;
}

/* Стили для ошибок */
.error-message {
    color: #d13438;
    font-size: 12px;
    margin-top: 5px;
}

.has-error .field-wrapper {
    border-color: #d13438;
}

/* Стили для лейблов */
.form-label {
    font-weight: 600;
    color: #323130;
    margin-bottom: 8px;
    display: block;
}

/* ============================================================
   Мобильная адаптивность — общие правила
   ============================================================ */

/* Таблицы, которые шире экрана, прокручиваются горизонтально внутри обёртки */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-scroll > table { min-width: 600px; }

/* На мобилке — чуть крупнее базовый шрифт, чтобы не было zoom-баттла на iOS */
@media (max-width: 767px) {
    body { font-size: 15px; }
    /* iOS не зумит при фокусе, если input >=16px */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="search"],
    input[type="url"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px;
    }
    /* Любые таблицы без обёртки — делаем прокручиваемыми */
    table { max-width: 100%; }
    /* Таблицы в узком экране — не распирать мин-ширину */
    .table-scroll > table { min-width: 100%; }
    /* Перенос слов в ячейках, чтобы длинные значения не ломали таблицу */
    table th, table td { word-break: break-word; overflow-wrap: anywhere; }
    /* Изображения не вылетают за экран */
    img { max-width: 100%; height: auto; }
    /* Touch-friendly минимум для ссылок в навигациях и всех интерактивных кнопок */
    .nav-link, .btn, button.btn, a.btn, button[type="submit"], button[type="button"] {
        min-height: 44px;
    }
    /* Убираем горизонтальный overflow у body */
    html, body { overflow-x: hidden; }
    /* iframe внутри контентных обёрток не должен занимать весь экран — дать скролл естественный */
    iframe.responsive-iframe, .settings-frame-container iframe {
        height: auto !important;
        min-height: 70vh;
    }
    /* Сетка-с-сайдбаром на мобилке в один столбец (глобальный fallback) */
    .page-with-sidebar { grid-template-columns: 1fr !important; }
    /* Блочные карточки с min-height: 80vh на мобилке — сбросить */
    .min-h-80vh, .stats-section, .card-80vh { min-height: auto !important; }
}

/* На узких (<=480px) — ещё агрессивнее */
@media (max-width: 480px) {
    /* Таблицы полностью без мин-ширины, перенос слов */
    .table-scroll > table { min-width: auto; }
    /* position: fixed элементы, которые выезжают — делаем статичными */
    .timer-container,
    .floating-fixed-timer {
        position: static !important;
        width: 100% !important;
        margin-bottom: 12px;
        min-width: auto !important;
        right: auto !important;
        top: auto !important;
    }
}

/* Отключаем залипающий ховер на touch-устройствах */
@media (hover: none) {
    a:hover, button:hover, .btn:hover,
    .settings-card:hover, .nav-link:hover,
    .avp-option:hover, .card:hover { opacity: 1; transform: none !important; }
}

/* ========================================================================
   Performance / smoothness tweaks
   ======================================================================== */

/* Отключаем hover-анимации на touch-устройствах везде */
@media (hover: none), (pointer: coarse) {
    *:hover {
        transform: none !important;
    }
    .card:hover,
    .info-card:hover,
    .program-card:hover,
    .service-button:hover,
    .form-card:hover,
    .settings-card:hover,
    .settings-panel:hover,
    .info-panel-button:hover,
    .applicant-card:hover,
    .template-card:hover {
        box-shadow: none !important;
        transform: none !important;
    }
}

/* Уважение reduce-motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* GPU-hint для часто анимируемых (уменьшает jank) */
.card,
.info-card,
.program-card,
.template-card,
.settings-card,
.form-card,
.service-button {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Убираем всплывающие перерисовки при скролле (iframe/внутренние скроллы) */
html {
    scroll-behavior: smooth;
}

/* Предотвращаем сдвиг макета от scrollbar */
html {
    scrollbar-gutter: stable;
}

/* На смартфонах отключаем тяжёлые box-shadow в hover */
@media (max-width: 767px) {
    .card:hover, .info-card:hover, .program-card:hover {
        box-shadow: none !important;
    }
}
