/* mchs-survey — стили (mobile-first, тёмно-синий + оранжевый акцент). */

:root {
    --primary: #003366;
    --primary-dark: #001f3f;
    --primary-light: #1a4d80;
    --accent: #ff6600;
    --accent-light: #ff8533;
    --danger: #cc0000;
    --success: #1a8033;
    --bg: #f4f6f8;
    --bg-card: #ffffff;
    --bg-soft: #eef2f7;
    --border: #d6dde5;
    --border-strong: #b6c2d0;
    --text: #1a2233;
    --text-secondary: #5b6470;
    --text-muted: #8a93a3;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0, 31, 63, 0.06), 0 8px 24px rgba(0, 31, 63, 0.08);
    --shadow-strong: 0 4px 16px rgba(0, 31, 63, 0.18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.survey-page {
    /* На странице анкеты — sticky footer, поэтому body во flex */
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
}

/* ============================================================ */
/* HEADER (главная + thank-you + admin)                          */
/* ============================================================ */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 18px 0;
    box-shadow: var(--shadow);
}
.header-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.logo-section { display: flex; align-items: center; gap: 14px; }
.logo {
    width: 52px; height: 52px;
    background: #fff;
    border-radius: 50%;
    border: 3px solid var(--accent);
    display: flex; align-items: center; justify-content: center;
    color: var(--primary); font-weight: 800; font-size: 13px;
    flex-shrink: 0;
}
.header h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: .3px; }
.header h2 { margin: 2px 0 0; font-size: 12px; font-weight: 400; opacity: .85; }

/* ============================================================ */
/* CONTENT WRAPPER                                                */
/* ============================================================ */
.main-content {
    max-width: 1100px;
    width: 100%;
    margin: 24px auto;
    padding: 0 16px;
}
.card,
.content-wrapper,
.thank-you-container,
.responses-container,
.login-container,
.admin-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}
h1, h2, h3 { color: var(--primary); margin-top: 0; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; margin-top: 18px; }
p { color: var(--text-secondary); margin: 0 0 12px; }

/* ============================================================ */
/* BUTTONS (общие)                                                */
/* ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 22px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 15px; font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease, background .15s ease;
    font-family: inherit;
    min-height: 48px;            /* touch-friendly */
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.14); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--bg-soft); color: var(--primary); border-color: var(--border); }
.btn-view      { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-submit    { background: var(--accent); color: #fff; }
.btn-submit:hover:not(:disabled) { background: var(--accent-light); }
.btn-report    { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-logout    { background: rgba(255,255,255,0.15); color: #fff; padding: 6px 14px; border-radius: 6px; text-decoration: none; font-size: 13px; }
.btn-block     { width: 100%; }

/* ============================================================ */
/* SURVEY WIZARD                                                  */
/* ============================================================ */

/* Progress bar (sticky сверху) */
.progress-bar {
    position: sticky; top: 0; z-index: 100;
    background: var(--primary-dark);
    color: #fff;
    height: 56px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
    overflow: hidden;
}
.progress-fill {
    position: absolute; left: 0; top: 0;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    transition: width .35s cubic-bezier(.4, 0, .2, 1);
    z-index: 1;
}
.progress-text {
    position: relative; z-index: 2;
    font-size: 13px; font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,.4);
    text-align: center;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 100%;
}

/* Состояние «загрузка / ошибка / уже отправлено» */
.state-card {
    max-width: 480px;
    margin: 60px auto;
    padding: 32px 24px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}
.state-card h2 { margin: 14px 0 8px; }
.state-icon {
    width: 64px; height: 64px;
    margin: 0 auto 12px;
    background: linear-gradient(135deg, var(--success), #2db050);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 32px; font-weight: 700;
    box-shadow: 0 6px 18px rgba(26, 128, 51, 0.3);
}

.spinner {
    width: 40px; height: 40px;
    margin: 0 auto 14px;
    border: 4px solid var(--bg-soft);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Wizard scene */
.wizard {
    flex: 1;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 16px 100px;       /* нижний отступ под sticky footer */
}

.step-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 22px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .25s ease, transform .25s ease;
}
.step-card.show { opacity: 1; transform: translateY(0); }

.step-header { margin-bottom: 22px; }
.step-tag {
    display: inline-block;
    background: var(--bg-soft);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 12px;
}
.step-card h1 { font-size: 22px; margin: 0 0 10px; }
.step-question {
    font-size: 18px;
    color: var(--text);
    margin: 0;
    font-weight: 600;
    line-height: 1.35;
}
.step-hint {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 4px 0 0;
}

/* Select подразделения */
.dept-select-wrap { margin-top: 8px; }
.dept-select {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
}
.dept-select:focus { outline: 3px solid var(--accent); outline-offset: -3px; border-color: var(--accent); }

/* Шкала 1..10 — на мобильном grid 5x2, на десктопе одна линия */
.scale-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}
.scale-btn {
    height: 56px;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all .18s ease;
    font-family: inherit;
}
.scale-btn:hover { border-color: var(--primary); color: var(--primary); }
.scale-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: scale(1.04);
    box-shadow: 0 4px 12px rgba(0, 51, 102, 0.3);
}
.scale-legend {
    display: flex; justify-content: space-between;
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 12px;
}

/* Опции single/multi — крупные карточки */
.option-list { display: flex; flex-direction: column; gap: 10px; }
.option-btn {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: all .15s ease;
    text-align: left;
    font-family: inherit;
    color: var(--text);
    width: 100%;
}
.option-btn:hover { border-color: var(--primary); background: #fafbfc; }
.option-btn.active {
    background: linear-gradient(90deg, rgba(0,51,102,.08), rgba(0,51,102,.02));
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,51,102,.12);
}
.option-key {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--bg-soft);
    color: var(--primary);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 14px;
}
.option-btn.active .option-key {
    background: var(--primary);
    color: #fff;
}
.option-label {
    flex: 1;
    font-size: 15px;
    line-height: 1.4;
}

/* Multi-варианты — чекбокс-индикатор слева */
.option-btn.multi .option-check {
    flex-shrink: 0;
    width: 22px; height: 22px;
    border: 2px solid var(--border-strong);
    border-radius: 6px;
    background: #fff;
    position: relative;
    margin-top: 2px;
    transition: all .12s ease;
}
.option-btn.multi.active .option-check {
    background: var(--accent);
    border-color: var(--accent);
}
.option-btn.multi.active .option-check::after {
    content: "✓";
    position: absolute; top: -2px; left: 3px;
    color: #fff; font-weight: 800; font-size: 16px;
}

/* Confirm-экран */
.confirm-summary {
    background: var(--bg-soft);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}
.confirm-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.confirm-row:last-child { border-bottom: none; }
.confirm-row span { color: var(--text-secondary); }
.confirm-row b { color: var(--text); text-align: right; max-width: 60%; }

/* Sticky-футер с кнопками навигации */
.wizard-footer {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 12px rgba(0,0,0,.06);
    display: flex; align-items: center; gap: 12px;
    z-index: 50;
}
.wizard-footer .btn { flex: 1; max-width: 200px; }
.wizard-footer .btn:first-child { flex: 0 0 auto; min-width: 100px; }
.wizard-footer .btn:last-child  { flex: 1; }
.step-counter {
    flex: 1;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

/* ============================================================ */
/* Старые формы / админка / прочее                                */
/* ============================================================ */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    background: #fff;
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: 2px solid var(--accent); outline-offset: -2px; border-color: var(--accent); }

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 14px;
}
.alert-success { background: #e6f4ea; color: #1a8033; }
.alert-error   { background: #fde7e7; color: #cc0000; }
.alert-info    { background: #e8f0fa; color: var(--primary); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
table th, table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
table th { background: var(--bg-soft); color: var(--text-secondary); font-weight: 600; }
table tr:hover { background: #fafbfc; }

.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.stat-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.stat-card h3 { color: rgba(255,255,255,.85); font-size: 13px; margin: 0 0 6px; }
.stat-value { font-size: 30px; font-weight: 700; }

.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0; }
.user-info { display: flex; align-items: center; gap: 14px; font-size: 13px; }

.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 12px;
}

/* ============================================================ */
/* MOBILE ADJUSTMENTS                                             */
/* ============================================================ */
@media (max-width: 640px) {
    .header { padding: 14px 0; }
    .header-content { padding: 0 14px; gap: 12px; }
    .logo { width: 44px; height: 44px; font-size: 12px; }
    .header h1 { font-size: 14px; }
    .header h2 { font-size: 11px; }

    .main-content { padding: 0 12px; margin-top: 16px; }
    .card, .content-wrapper, .login-container,
    .admin-panel, .responses-container, .thank-you-container { padding: 18px; }

    .wizard { padding: 14px 12px 110px; }
    .step-card { padding: 22px 16px; }
    .step-card h1 { font-size: 20px; }
    .step-question { font-size: 16px; }

    .scale-btn { height: 52px; font-size: 16px; }
    .option-btn { padding: 12px 12px; }
    .option-label { font-size: 14px; }

    .progress-bar { height: 48px; }
    .progress-text { font-size: 12px; }

    .wizard-footer { padding: 10px 12px; gap: 8px; }
    .wizard-footer .btn { padding: 10px 14px; font-size: 14px; min-height: 44px; }
    .wizard-footer .btn:first-child { min-width: 80px; }
    .step-counter { font-size: 11px; }

    .stats-overview { gap: 10px; }
    .stat-value { font-size: 26px; }
}

/* Очень узкие экраны — ужмём шкалу под 5 крупных */
@media (max-width: 380px) {
    .scale-grid { gap: 8px; }
    .scale-btn { height: 48px; font-size: 15px; }
}

/* Очень широкий экран — шкалу выводим в 1 ряд */
@media (min-width: 720px) {
    .scale-grid {
        grid-template-columns: repeat(10, 1fr);
        gap: 8px;
    }
    .scale-btn { height: 60px; font-size: 18px; }
}
