/* === Base — Фирменный стиль Ассоциации МЖС === */
:root {
    --primary: #275d9f;
    --primary-light: #7da0cc;
    --primary-dark: #1a4170;
    --accent: #7da0cc;
    --bg: #F2F5F9;
    --card-bg: #FFFFFF;
    --text: #2C3E50;
    --text-secondary: #6C7A8A;
    --border: #D6DDE6;
    --success: #27AE60;
    --error: #E74C3C;
    --warning: #F39C12;
}

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

body {
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* === Survey Page Header === */
.page-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 25px 20px 20px;
    text-align: center;
}

.page-header .header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin-bottom: 10px;
}

.page-header .logo {
    height: 56px;
    width: auto;
    border-radius: 6px;
    background: white;
    padding: 4px;
}

.page-header .org-name {
    font-size: 0.85em;
    opacity: 0.9;
    font-weight: 400;
    text-align: left;
    max-width: 420px;
    line-height: 1.4;
}

.page-header h1 {
    font-size: 1.7em;
    font-weight: 700;
    margin-bottom: 6px;
}

.page-header .subtitle {
    font-size: 0.95em;
    opacity: 0.85;
    max-width: 700px;
    margin: 0 auto;
}

.page-header .badges {
    margin-top: 14px;
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.page-header .badge {
    background: rgba(255,255,255,0.18);
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.82em;
    border: 1px solid rgba(255,255,255,0.25);
}

.survey-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* === SurveyJS Theme Overrides === */
.sd-root-modern {
    --sd-base-unit: 8px;
}

.sd-body {
    background: var(--card-bg) !important;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 30px !important;
}

.sd-title.sd-page__title {
    color: var(--primary) !important;
    font-size: 1.4em !important;
    font-weight: 600 !important;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.sd-panel__title {
    color: var(--primary-dark) !important;
    font-size: 1.1em !important;
    font-weight: 600 !important;
    background: #EDF2F8;
    padding: 10px 15px !important;
    border-radius: 8px;
    margin-bottom: 15px !important;
}

.sd-question__title {
    color: var(--text) !important;
    font-weight: 500 !important;
}

.sd-input {
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    padding: 10px 12px !important;
    transition: border-color 0.2s;
}

.sd-input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(39,93,159,0.15) !important;
}

.sd-btn.sd-navigation__complete-btn,
.sd-btn.sd-navigation__next-btn {
    background: var(--primary) !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 12px 30px !important;
    font-size: 1em !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: background 0.2s;
}

.sd-btn.sd-navigation__complete-btn:hover,
.sd-btn.sd-navigation__next-btn:hover {
    background: var(--primary-light) !important;
}

.sd-btn.sd-navigation__prev-btn {
    background: transparent !important;
    color: var(--primary) !important;
    border: 2px solid var(--primary) !important;
    border-radius: 8px !important;
    padding: 10px 24px !important;
    font-weight: 600 !important;
    cursor: pointer;
}

/* SurveyJS renders its own title/description block that repeats the page
   header word for word. With the progress bar gone the two white blocks sat
   flush against each other and read as one broken card. */
.sd-title.sd-container-modern__title {
    display: none !important;
}

/* Let the question card use the full shell width — it defaults to a 70px
   side margin, which left a visible step against the blocks above. */
.sd-body.sd-body--static {
    margin: 0 !important;
    max-width: none !important;
}

/* Status line — what replaced the progress bar.
   Sticky: pages run long (131 questions), so the step indicator has to stay
   in view once the page heading has scrolled away. */
.survey-status {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 18px;
    margin-bottom: 16px;
    background: var(--card-bg);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    /* Second shadow paints the 16px gap below in the page background colour —
       without it the scrolling page heading shows through between the pinned
       status line and the card. */
    box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 16px 0 0 var(--bg);
}

.survey-status[hidden] { display: none; }

.survey-status__step {
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.survey-status__page {
    color: var(--text-secondary);
    font-size: 0.95em;
}

/* Expression (calculated) fields */
.sd-question--expression .sd-question__content {
    background: #EDF2F8;
    border: 1px dashed var(--primary);
    border-radius: 8px;
    padding: 12px 15px;
    font-weight: 600;
    font-size: 1.1em;
    color: var(--primary-dark);
}

/* Intro block */
.survey-intro {
    background: linear-gradient(135deg, #EDF2F8 0%, #E3EAF3 100%);
    border-left: 4px solid var(--primary);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    line-height: 1.7;
}

.survey-intro p { margin-bottom: 10px; }
.survey-intro p:last-child { margin-bottom: 0; }

.hint-text {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.95em;
    margin-bottom: 10px;
}

.submit-note {
    background: #EDF2F8;
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    margin-top: 10px;
}

/* === Footer === */
.page-footer {
    background: var(--primary-dark);
    color: rgba(255,255,255,0.85);
    text-align: center;
    padding: 20px;
    font-size: 0.85em;
    margin-top: 30px;
}

.page-footer a {
    color: var(--accent);
    text-decoration: none;
}

.page-footer a:hover {
    text-decoration: underline;
}

.footer-contacts {
    margin-top: 8px;
    font-size: 0.95em;
}

/* === Dashboard Styles === */
.dashboard-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.dashboard-header h1 { font-size: 1.5em; }

.dashboard-header .actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 8px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #93b3d6; }
.btn-outline { background: transparent; color: white; border: 2px solid white; }
.btn-outline:hover { background: rgba(255,255,255,0.15); }

.dashboard-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* KPI cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.kpi-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    text-align: center;
    border-top: 3px solid var(--primary);
}

.kpi-card .kpi-value {
    font-size: 2em;
    font-weight: 700;
    color: var(--primary);
}

.kpi-card .kpi-label {
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-top: 4px;
}

/* Chart grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.chart-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.chart-card h3 {
    color: var(--primary);
    font-size: 1.1em;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.chart-card canvas {
    max-height: 350px;
}

/* Responses table */
.table-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow-x: auto;
}

.table-card h3 {
    color: var(--primary);
    font-size: 1.1em;
    margin-bottom: 15px;
}

/* Horizontal scroll container: keeps the rightmost columns reachable
   instead of clipping them at the card edge. */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.responses-table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    font-size: 0.9em;
}

.responses-table th {
    background: var(--primary);
    color: white;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.responses-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.responses-table tr:hover { background: #F0F4FA; }

.responses-table tr:nth-child(even) { background: #F8FAFC; }
.responses-table tr:nth-child(even):hover { background: #EDF2F8; }

.btn-delete {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85em;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-delete:hover {
    background: #E74C3C;
    border-color: #E74C3C;
    color: white;
}

.last-updated {
    align-self: center;
    font-size: 0.85em;
    opacity: 0.75;
    white-space: nowrap;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state h3 { margin-bottom: 10px; color: var(--text); }

.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9em;
}

/* Responsive */
@media (max-width: 768px) {
    .page-header h1 { font-size: 1.3em; }
    .page-header .header-top { flex-direction: column; gap: 10px; }
    .page-header .org-name { text-align: center; }
    .survey-container { padding: 10px; }
    .sd-body { padding: 15px !important; }
    .charts-grid { grid-template-columns: 1fr; }
    .dashboard-header { padding: 15px; }
}
