/* ============================================================
   Научная конференция — общие стили
   Grid для каркаса, Flex внутри компонентов,
   псевдоклассы, адаптивная вёрстка.
   ============================================================ */

:root {
    --color-primary: #4f46e5;
    --color-primary-dark: #4338ca;
    --color-accent: #0ea5e9;
    --color-bg: #f1f5f9;
    --color-card: #ffffff;
    --color-text: #1e293b;
    --color-muted: #64748b;
    --color-error: #dc2626;
    --color-success: #16a34a;
    --color-border: #e2e8f0;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(30, 41, 59, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #eef2ff 0%, var(--color-bg) 50%, #ecfeff 100%);
    background-attachment: fixed;
    color: var(--color-text);
    min-height: 100vh;
    /* Flex-каркас: прижимаем футер к низу */
    display: flex;
    flex-direction: column;
}

/* ---------- Горизонтальное меню ---------- */

.site-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.menu {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;               /* горизонтальное меню на flex */
    gap: 8px;
}

.menu a {
    display: inline-block;
    padding: 16px 22px;
    color: var(--color-muted);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

/* Псевдоклассы меню */
.menu a:hover {
    color: var(--color-primary);
    background-color: rgba(79, 70, 229, 0.06);
}

.menu a:active {
    color: var(--color-primary-dark);
}

.menu a.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* ---------- Каркас страницы ---------- */

.container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 40px 20px;
    flex: 1;
}

.container--wide {
    max-width: 1100px;
}

.card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 36px;
}

h1 {
    font-size: 1.6rem;
    margin-bottom: 8px;
}

.form-subtitle {
    color: var(--color-muted);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

.required {
    color: var(--color-error);
}

/* ---------- Форма ---------- */

.form-section {
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 22px;
}

.form-section legend {
    padding: 0 10px;
    font-weight: 600;
    color: var(--color-primary);
}

/* Grid-разметка полей */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.field {
    display: flex;               /* метка + поле + ошибка в колонку */
    flex-direction: column;
    margin-bottom: 4px;
}

.field label,
.field-label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.field input,
.field select {
    padding: 12px 14px;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

/* Псевдоклассы полей ввода */
.field input:hover,
.field select:hover {
    border-color: #c7d2fe;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.field input::placeholder {
    color: #94a3b8;
}

/* Поле с ошибкой (класс ставит JS) + нативный :invalid */
.field .input--invalid,
.field input:not(:placeholder-shown):invalid {
    border-color: var(--color-error);
}

.field .input--invalid:focus {
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
}

.field-error {
    color: var(--color-error);
    font-size: 0.82rem;
    min-height: 1.1em;
    margin-top: 4px;
}

.field-hint {
    color: var(--color-muted);
    font-size: 0.8rem;
    margin-top: 4px;
}

/* ---------- Переключатель «Доклад» ---------- */

.radio-group {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.radio-pill {
    cursor: pointer;
}

.radio-pill input {
    position: absolute;
    opacity: 0;
}

.radio-pill span {
    display: inline-block;
    padding: 10px 26px;
    border: 2px solid var(--color-border);
    border-radius: 999px;
    font-weight: 600;
    color: var(--color-muted);
    transition: all 0.2s;
}

.radio-pill:hover span {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Псевдокласс :checked — стиль выбранного варианта */
.radio-pill input:checked + span {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.radio-pill input:focus-visible + span {
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
}

/* Поле темы доклада — плавное появление */
.field--topic {
    margin-top: 16px;
    animation: fadeSlideIn 0.3s ease;
}

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

/* ---------- Кнопки ---------- */

.form-actions {
    display: flex;
    gap: 14px;
    justify-content: flex-end;
}

.btn {
    display: inline-block;
    padding: 13px 32px;
    border: 2px solid var(--color-primary);
    border-radius: 10px;
    background: var(--color-primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

/* Псевдоклассы кнопок */
.btn:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.3);
}

.btn--ghost {
    background: transparent;
    color: var(--color-primary);
}

.btn--ghost:hover {
    background: rgba(79, 70, 229, 0.08);
    color: var(--color-primary-dark);
    box-shadow: none;
}

/* ---------- Страница результата ---------- */

.result-card {
    max-width: 620px;
    margin: 0 auto;
    text-align: center;
}

.result-badge {
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: var(--color-success);
    color: #fff;
    font-size: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: popIn 0.4s ease;
}

@keyframes popIn {
    0%   { transform: scale(0); }
    70%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.result-subtitle {
    color: var(--color-muted);
    margin-bottom: 24px;
}

.answer-list {
    text-align: left;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 26px;
}

.answer-row {
    display: flex;
    padding: 13px 18px;
}

/* Зебра через псевдокласс :nth-child */
.answer-row:nth-child(odd) {
    background: #f8fafc;
}

.answer-row dt {
    flex: 0 0 160px;
    font-weight: 600;
    color: var(--color-muted);
}

.answer-row dd {
    flex: 1;
}

.result-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

.result-card--error h1 {
    color: var(--color-error);
}

.error-list {
    text-align: left;
    margin: 16px auto 24px;
    max-width: 420px;
    color: var(--color-error);
    padding-left: 22px;
}

.error-list li {
    margin-bottom: 6px;
}

/* ---------- Таблица участников ---------- */

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.table-wrap {
    overflow-x: auto;            /* горизонтальный скролл на узких экранах */
}

.participants-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.93rem;
}

.participants-table th {
    background: var(--color-primary);
    color: #fff;
    padding: 12px 14px;
    text-align: left;
    white-space: nowrap;
}

.participants-table th:first-child {
    border-radius: 8px 0 0 0;
}

.participants-table th:last-child {
    border-radius: 0 8px 0 0;
}

.participants-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

/* Зебра и подсветка строки — псевдоклассы */
.participants-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.participants-table tbody tr:hover {
    background: #eef2ff;
}

.row-loading td,
.row-empty td {
    text-align: center;
    color: var(--color-muted);
    padding: 30px;
}

.table-note {
    margin-top: 14px;
    color: var(--color-muted);
    font-size: 0.85rem;
}

/* Индикатор «живого» обновления */
.live-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-left: 8px;
    border-radius: 50%;
    background: var(--color-success);
    vertical-align: middle;
}

.live-indicator--pulse {
    animation: pulse 0.6s ease;
}

@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); }
    100% { box-shadow: 0 0 0 10px rgba(22, 163, 74, 0); }
}

.report-yes {
    color: var(--color-success);
    font-weight: 600;
}

/* Цветные ярлыки секций */
.tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.tag--математика  { background: #e0e7ff; color: #4338ca; }
.tag--физика      { background: #cffafe; color: #0e7490; }
.tag--информатика { background: #dcfce7; color: #15803d; }

/* ---------- Футер ---------- */

.site-footer {
    text-align: center;
    padding: 22px;
    color: var(--color-muted);
    font-size: 0.88rem;
    border-top: 1px solid var(--color-border);
}

/* ---------- Адаптивная вёрстка ---------- */

@media (max-width: 768px) {
    .card {
        padding: 24px 18px;
    }

    /* ФИО: 3 колонки -> 1 */
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

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

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

    .menu {
        justify-content: center;
    }

    .answer-row {
        flex-direction: column;
        gap: 4px;
    }

    .answer-row dt {
        flex: none;
    }
}

@media (max-width: 560px) {
    h1 {
        font-size: 1.3rem;
    }

    .radio-group {
        flex-direction: column;
    }

    .radio-pill span {
        display: block;
        text-align: center;
    }

    /* Таблица превращается в карточки:
       каждая строка — блок, ячейки с подписями из data-label */
    .participants-table thead {
        display: none;
    }

    .participants-table,
    .participants-table tbody,
    .participants-table tr,
    .participants-table td {
        display: block;
        width: 100%;
    }

    .participants-table tr {
        border: 1px solid var(--color-border);
        border-radius: 10px;
        margin-bottom: 14px;
        padding: 8px 0;
    }

    .participants-table td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        border-bottom: none;
        padding: 7px 14px;
    }

    .participants-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-muted);
    }
}
