/* Survey Admin Page Styles */

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    border-left: 4px solid var(--primary-color, #003256);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-card label {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color, #003256);
}

/* PRA Notice */
.pra-notice {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
}

.pra-notice summary {
    cursor: pointer;
    font-weight: 600;
    color: #795548;
}

.pra-notice-content {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: #5d4037;
    line-height: 1.6;
}

.pra-notice-content p {
    margin-bottom: 0.5rem;
}

/* Tab bar */
.survey-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #ddd;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.survey-tab {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #666;
    white-space: nowrap;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
}

.survey-tab:hover {
    color: var(--primary-color, #003256);
    background: rgba(0,50,86,0.04);
}

.survey-tab:focus-visible {
    outline: 2px solid var(--primary-color, #003256);
    outline-offset: -2px;
}

.survey-tab.active {
    color: var(--primary-color, #003256);
    border-bottom-color: var(--primary-color, #003256);
    font-weight: 600;
}

/* Tab panels */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Panel header */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.panel-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Filter select */
.filter-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
    min-height: 44px;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-badge--draft { background: #e3f2fd; color: #1565c0; }
.status-badge--active { background: #e8f5e9; color: #2e7d32; }
.status-badge--closed { background: #fce4ec; color: #c62828; }
.status-badge--archived { background: #f5f5f5; color: #757575; }

.row-archived { opacity: 0.6; }

.show-archived-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: #555;
    cursor: pointer;
}

.mode-badge {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.85rem;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.data-table td.empty-state {
    text-align: center;
    padding: 2rem;
    color: #888;
}

.data-table .action-buttons {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

/* Empty state */
.empty-state-message {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #888;
}

.empty-state-message h2 {
    margin-bottom: 0.5rem;
    color: #666;
}

/* Status message area */
.status-message {
    min-height: 0;
    transition: all 0.3s;
}

.status-message.visible {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.status-message.success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.status-message.error { background: #fce4ec; color: #c62828; border: 1px solid #f8bbd0; }
.status-message.info { background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }

/* Modal sizing */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-content.modal-lg {
    max-width: 800px;
}

.modal-content.modal-sm {
    max-width: 450px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #eee;
}

.modal-progress {
    padding: 0.75rem 1.5rem;
    background: #e3f2fd;
    color: #1565c0;
    font-size: 0.9rem;
    border-radius: 0 0 12px 12px;
}

/* Form styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
    min-height: 44px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: 2px solid var(--primary-color, #003256);
    outline-offset: 1px;
    border-color: var(--primary-color, #003256);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-help {
    font-size: 0.8rem;
    color: #777;
    margin-top: 0.25rem;
}

.form-warning {
    font-size: 0.85rem;
    color: #c62828;
    background: #fce4ec;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    margin-top: 0.25rem;
}

.required-indicator {
    color: #c62828;
}

.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.35rem;
    cursor: pointer;
    font-weight: normal;
    min-height: 44px;
}

.checkbox-label input,
.radio-label input {
    min-width: 18px;
    min-height: 18px;
}

/* Mode info toggle */
.mode-info {
    margin-left: 1.4rem;
    margin-top: 0;
}

/* Type-specific option panels */
.type-options {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.type-options legend {
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0 0.5rem;
}

/* Dynamic list (MC choices, matrix rows) */
.dynamic-list .dynamic-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.dynamic-list .dynamic-row input[type="text"] {
    flex: 1;
}

.dynamic-list .dynamic-row input[type="number"] {
    width: 80px;
}

.dynamic-list .dynamic-row .remove-row-btn {
    background: none;
    border: none;
    color: #c62828;
    font-size: 1.2rem;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dynamic-list .dynamic-row .move-btn {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    min-width: 32px;
    min-height: 32px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Radio group horizontal */
.radio-group {
    display: flex;
    gap: 1rem;
}

/* Likert labels/values inline layout */
#likertLabels .likert-row,
#likertValues .likert-row,
#matrixColumns .likert-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.35rem;
}

#likertLabels .likert-row label,
#likertValues .likert-row label,
#matrixColumns .likert-row label {
    min-width: 2rem;
    font-size: 0.85rem;
    margin-bottom: 0;
}

#likertLabels .likert-row input,
#likertValues .likert-row input,
#matrixColumns .likert-row input {
    flex: 1;
    min-height: 36px;
}

/* Quill editor in modals */
.modal-body .ql-container {
    min-height: 100px;
    font-size: 0.9rem;
}

.modal-body .ql-toolbar {
    border-radius: 6px 6px 0 0;
}

.modal-body .ql-container {
    border-radius: 0 0 6px 6px;
}

/* Section cards in Questions tab */
.section-card {
    background: white;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e0e0e0;
}

.section-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    gap: 0.5rem;
}

.section-card-header h3 {
    margin: 0;
    font-size: 1rem;
    flex: 1;
}

.section-card-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.section-card-body {
    padding: 1rem;
}

.section-card-body.collapsed {
    display: none;
}

/* Question row within section */
.question-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
    min-height: 44px;
}

.question-row:last-child {
    border-bottom: none;
}

.question-type-badge {
    background: #e3f2fd;
    color: #1565c0;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.question-text-preview {
    flex: 1;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.question-required-indicator {
    color: #c62828;
    font-weight: bold;
}

.question-actions {
    display: flex;
    gap: 0.25rem;
}

/* Warning banner */
.warning-banner {
    background: #fff3e0;
    border: 1px solid #ffe0b2;
    color: #e65100;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Preview styles */
.preview-banner {
    background: #e3f2fd;
    border: 2px dashed #1565c0;
    color: #1565c0;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 600;
}

.preview-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.preview-description {
    margin-bottom: 1.5rem;
    color: #555;
}

.preview-progress {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #666;
}

.preview-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

/* Settings form */
.settings-form {
    max-width: 600px;
}

.settings-form fieldset {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.settings-form legend {
    font-weight: 600;
    padding: 0 0.5rem;
}

/* Loading overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.9);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top-color: var(--primary-color, #003256);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Survey question cards (shared with survey-take.html) */
.survey-question-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.survey-question-text {
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.survey-question-text p {
    margin: 0;
}

/* Likert horizontal layout */
.survey-likert-group {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
}

.survey-likert-group.horizontal {
    justify-content: space-between;
}

.survey-likert-group.vertical .survey-likert-option {
    width: 100%;
}

.survey-likert-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0.5rem;
    flex: 1;
    min-width: 60px;
}

.survey-likert-option label {
    font-size: 0.8rem;
    color: #555;
    margin-top: 0.25rem;
    cursor: pointer;
}

.survey-likert-option input[type="radio"] {
    min-width: 20px;
    min-height: 20px;
}

/* Matrix table */
.survey-matrix-table {
    width: 100%;
    border-collapse: collapse;
}

.survey-matrix-table th,
.survey-matrix-table td {
    padding: 0.5rem;
    text-align: center;
    border: 1px solid #e0e0e0;
}

.survey-matrix-table th[scope="row"] {
    text-align: left;
    font-weight: normal;
    min-width: 200px;
}

.survey-matrix-table thead th {
    background: #f8f9fa;
    font-size: 0.8rem;
}

.survey-matrix-table input[type="radio"] {
    min-width: 18px;
    min-height: 18px;
}

/* Character counter */
.char-counter {
    text-align: right;
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.25rem;
}

/* MC radio/checkbox groups */
.survey-mc-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    min-height: 44px;
    cursor: pointer;
}

.survey-mc-group input {
    min-width: 18px;
    min-height: 18px;
}

.survey-mc-other-input {
    margin-left: 1.8rem;
    margin-top: 0.25rem;
}

.survey-mc-other-input input[type="text"] {
    width: 100%;
    max-width: 300px;
    padding: 0.4rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Progress bar */
.survey-progress-bar {
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.survey-progress-fill {
    height: 100%;
    background: var(--primary-color, #003256);
    transition: width 0.3s;
    border-radius: 3px;
}

/* Responsive stacked matrix */
@media (max-width: 600px) {
    .survey-matrix-table {
        display: block;
    }

    .survey-matrix-table thead {
        display: none;
    }

    .survey-matrix-table tbody,
    .survey-matrix-table tr,
    .survey-matrix-table td,
    .survey-matrix-table th[scope="row"] {
        display: block;
        width: 100%;
    }

    .survey-matrix-table tr {
        border: 1px solid #e0e0e0;
        margin-bottom: 0.75rem;
        border-radius: 6px;
        padding: 0.5rem;
    }

    .survey-matrix-table th[scope="row"] {
        font-weight: 600;
        border: none;
        padding-bottom: 0.25rem;
    }

    .survey-matrix-table td {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        border: none;
        text-align: left;
        padding: 0.35rem 0.5rem;
    }

    .survey-matrix-table td::before {
        content: attr(data-label);
        font-size: 0.85rem;
        color: #555;
        min-width: 120px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* =============================================================================
   Distribution Tab
   ============================================================================= */

/* Action buttons row */
.dist-scheduling-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 6px;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.dist-timing-fieldset {
    margin-top: 1rem;
}

.dist-timing-fieldset label[for="distScheduleDatetime"] {
    display: block;
    margin: 0.5rem 0 0.25rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.dist-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 1.5rem 0;
}

/* Completion rate color coding */
.rate-green { color: #2e7d32; font-weight: 600; }
.rate-amber { color: #e65100; font-weight: 600; }
.rate-red { color: #c62828; font-weight: 600; }

/* Status badges for invitations */
.dist-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: capitalize;
}

.dist-badge--sent { background: #fff3e0; color: #e65100; }
.dist-badge--completed { background: #e8f5e9; color: #2e7d32; }

/* Division breakdown table */
.dist-division-table {
    margin-bottom: 1rem;
}

/* Division checkbox grid in modal */
.dist-division-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0;
}

/* Select/Deselect toggle row */
.dist-select-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Modal notices */
.dist-modal-notice {
    margin-top: 1rem;
    padding: 0.5rem 0.75rem;
    background: #e3f2fd;
    border-radius: 4px;
    color: #1565c0;
}

/* Custom employee selector */
.dist-custom-filters {
    margin-bottom: 0.75rem;
}

.dist-custom-search input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
    min-height: 44px;
    margin-bottom: 0.5rem;
}

.dist-custom-search input:focus {
    outline: 2px solid var(--primary-color, #003256);
    outline-offset: 1px;
    border-color: var(--primary-color, #003256);
}

.dist-custom-filter-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dist-custom-filter-row .filter-select {
    flex: 1;
    min-width: 120px;
}

.dist-custom-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dist-selected-count {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color, #003256);
}

.dist-employee-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fafafa;
}

.dist-employee-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
    min-height: 44px;
}

.dist-employee-item:last-child {
    border-bottom: none;
}

.dist-employee-item:hover {
    background: #f0f4f8;
}

.dist-employee-item input[type="checkbox"] {
    min-width: 18px;
    min-height: 18px;
    flex-shrink: 0;
}

.dist-employee-item label {
    flex: 1;
    cursor: pointer;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.9rem;
    margin: 0;
}

.dist-employee-name {
    font-weight: 500;
    min-width: 140px;
}

.dist-employee-email {
    color: #666;
    font-size: 0.85rem;
}

.dist-employee-meta {
    color: #888;
    font-size: 0.8rem;
    margin-left: auto;
    white-space: nowrap;
}

.dist-employee-empty {
    padding: 1.5rem;
    text-align: center;
    color: #888;
}

.dist-employee-loading {
    padding: 1.5rem;
    text-align: center;
    color: #888;
}

@media (max-width: 600px) {
    .dist-custom-filter-row {
        flex-direction: column;
    }

    .dist-employee-item label {
        flex-wrap: wrap;
    }

    .dist-employee-meta {
        margin-left: 0;
        width: 100%;
    }
}

/* =============================================================================
   Results Tab
   ============================================================================= */

/* Response summary */
.results-response-summary {
    display: inline-block;
    margin-left: 0.75rem;
    font-size: 0.9rem;
    color: #555;
}

/* View toggle */
.results-view-toggle {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.25rem 0.75rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin: 0;
}

.results-view-toggle legend {
    padding: 0;
}

.results-view-radio {
    margin-bottom: 0;
    min-height: auto;
    font-size: 0.9rem;
}

/* Section heading */
.results-section {
    margin-bottom: 2rem;
}

.results-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e0e0e0;
}

/* Individual question result */
.results-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.results-question-text {
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    line-height: 1.5;
    font-weight: 500;
}

.results-question-text p {
    margin: 0;
}

/* Stacked bar (Likert, Yes/No) */
.results-stacked-bar {
    display: flex;
    height: 32px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    background: #f0f0f0;
}

.results-bar-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2px;
    transition: opacity 0.2s;
    position: relative;
}

.results-bar-segment:hover,
.results-bar-segment:focus-visible {
    opacity: 0.85;
    outline: 2px solid var(--primary-color, #003256);
    outline-offset: -2px;
}

.results-bar-segment-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    white-space: nowrap;
    overflow: hidden;
}

/* Likert color scale — 5-point */
.likert-seg-1-of-5 { background: #c62828; }
.likert-seg-2-of-5 { background: #ef6c00; }
.likert-seg-3-of-5 { background: #f9a825; }
.likert-seg-4-of-5 { background: #7cb342; }
.likert-seg-5-of-5 { background: #2e7d32; }

/* Likert color scale — 3-point */
.likert-seg-1-of-3 { background: #c62828; }
.likert-seg-2-of-3 { background: #f9a825; }
.likert-seg-3-of-3 { background: #2e7d32; }

/* Likert color scale — 7-point */
.likert-seg-1-of-7 { background: #b71c1c; }
.likert-seg-2-of-7 { background: #d84315; }
.likert-seg-3-of-7 { background: #ef6c00; }
.likert-seg-4-of-7 { background: #f9a825; }
.likert-seg-5-of-7 { background: #9ccc65; }
.likert-seg-6-of-7 { background: #43a047; }
.likert-seg-7-of-7 { background: #1b5e20; }

/* Yes/No segments */
.yesno-seg-yes { background: #2e7d32; }
.yesno-seg-no { background: #9e9e9e; }

/* Stats line (mean, stdDev) */
.results-stats {
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 0.25rem;
}

.results-mean {
    font-weight: 600;
}

.results-stddev {
    color: #777;
    font-size: 0.85rem;
}

/* Response count */
.results-count {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 0.25rem;
}

/* Toggle link for data tables and free text */
.results-toggle-link {
    font-size: 0.85rem;
    color: var(--primary-color, #003256);
    text-decoration: underline;
    cursor: pointer;
    display: inline-block;
    margin-top: 0.25rem;
}

.results-toggle-link:focus-visible {
    outline: 2px solid var(--primary-color, #003256);
    outline-offset: 2px;
}

/* Inline data table */
.results-data-table {
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

/* Horizontal bar chart (MC, multi-select) */
.results-bar-chart {
    margin-bottom: 0.5rem;
}

.results-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    min-height: 28px;
}

.results-bar-label {
    min-width: 120px;
    max-width: 200px;
    font-size: 0.85rem;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
}

.results-bar-track {
    flex: 1;
    height: 22px;
    background: #f0f0f0;
    border-radius: 3px;
    overflow: hidden;
}

.results-bar-fill {
    height: 100%;
    background: var(--primary-color, #003256);
    border-radius: 3px;
    min-width: 2px;
    transition: width 0.3s;
}

.results-bar-value {
    font-size: 0.8rem;
    color: #555;
    min-width: 70px;
    flex-shrink: 0;
}

/* Other responses */
.results-other {
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.results-other ul {
    margin: 0.25rem 0 0 1.5rem;
    padding: 0;
}

.results-other li {
    margin-bottom: 0.2rem;
}

/* Free text response list */
.results-free-text-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 0.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.results-free-text-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.results-free-text-item:last-child {
    border-bottom: none;
}

/* Matrix results table */
.results-matrix-wrapper {
    overflow-x: auto;
    margin-bottom: 0.5rem;
}

.results-matrix-table th[scope="row"] {
    text-align: left;
    font-weight: normal;
    min-width: 200px;
}

.results-matrix-table td {
    text-align: center;
    min-width: 60px;
}

/* Suppressed results */
.results-suppressed-notice {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    color: #666;
    font-style: italic;
    margin-bottom: 0.5rem;
}

.results-suppressed-card {
    background: #f5f5f5;
    border: 1px dashed #bdbdbd;
    border-radius: 8px;
    padding: 1.5rem;
    color: #666;
    margin-bottom: 1rem;
}

.results-suppressed-card h4 {
    margin: 0 0 0.5rem 0;
    color: #555;
}

.results-suppressed-count {
    font-size: 0.85rem;
    color: #999;
    margin-top: 0.5rem;
}

/* Division selector */
.results-division-selector {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.results-division-selector label {
    font-weight: 500;
    font-size: 0.9rem;
}

#divisionResultsContent:focus {
    outline: none;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .results-bar-label {
        min-width: 80px;
        max-width: 120px;
    }

    .results-view-toggle {
        flex-direction: column;
        gap: 0.25rem;
    }

    .results-bar-row {
        flex-wrap: wrap;
    }
}

/* =============================================================================
   Trend Comparison
   ============================================================================= */

/* Comparison header bar */
.comparison-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #1565c0;
    font-weight: 500;
}

/* Delta indicators */
.delta {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.delta--up {
    color: #2e7d32;
}

.delta--down {
    color: #c62828;
}

.delta--neutral {
    color: #757575;
}

/* Previous period stacked bar (faded version) */
.results-stacked-bar--previous {
    height: 22px;
    margin-bottom: 0.5rem;
}

/* Bar label for current/previous period */
.results-comparison-bar-label {
    font-size: 0.75rem;
    color: #777;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 0.15rem;
    font-weight: 600;
}

/* Ghost bar behind current for MC/multi-select */
.results-bar-track {
    position: relative;
}

.results-bar-fill--previous {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--primary-color, #003256);
    opacity: 0.2;
    border-radius: 3px;
    z-index: 0;
}

.results-bar-fill {
    position: relative;
    z-index: 1;
}

/* Previous percentage annotation */
.results-bar-prev-pct {
    color: #999;
    font-size: 0.75rem;
    font-style: italic;
}

/* Comparison note for free text */
.results-comparison-note {
    font-size: 0.85rem;
    color: #888;
    font-style: italic;
    margin-bottom: 0.5rem;
}

/* Compare survey picker modal */
.compare-survey-option {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    text-align: left;
    margin-bottom: 0.5rem;
    min-height: 44px;
    transition: background 0.15s, border-color 0.15s;
}

.compare-survey-option:hover {
    background: #f0f4f8;
    border-color: var(--primary-color, #003256);
}

.compare-survey-option:focus-visible {
    outline: 2px solid var(--primary-color, #003256);
    outline-offset: 2px;
}

.compare-survey-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
}

.compare-survey-meta {
    font-size: 0.8rem;
    color: #777;
}

/* =============================================================================
   Cross-Tab Analysis
   ============================================================================= */

/* Controls row */
.crosstab-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.crosstab-controls label {
    font-weight: 500;
    font-size: 0.9rem;
}

/* Wrapper for horizontal scroll on wide tables */
.crosstab-wrapper {
    overflow-x: auto;
    margin-bottom: 1.5rem;
    -webkit-overflow-scrolling: touch;
}

/* Table */
.crosstab-table {
    width: 100%;
    min-width: 500px;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.crosstab-table thead th {
    background: #f5f7fa;
    font-weight: 600;
    padding: 0.65rem 0.75rem;
    text-align: center;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
    font-size: 0.85rem;
    color: #333;
}

.crosstab-table thead th:first-child {
    text-align: left;
}

.crosstab-table tbody th {
    text-align: left;
    font-weight: 600;
    padding: 0.65rem 0.75rem;
    background: #f9fafb;
    border-right: 1px solid #dee2e6;
    white-space: nowrap;
    font-size: 0.85rem;
    color: #333;
}

.crosstab-table tfoot th {
    text-align: left;
    font-weight: 700;
    padding: 0.65rem 0.75rem;
    background: #f0f2f5;
    border-right: 1px solid #dee2e6;
    border-top: 2px solid #dee2e6;
    font-size: 0.85rem;
}

/* Cells */
.crosstab-cell {
    text-align: center;
    padding: 0.5rem 0.6rem;
    border: 1px solid #e9ecef;
    vertical-align: middle;
    min-width: 80px;
}

.crosstab-score {
    display: block;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.3;
}

.crosstab-count {
    display: block;
    font-size: 0.7rem;
    color: #888;
    font-weight: 400;
}

/* Heatmap color classes */
.cell-score-high {
    background-color: #c8e6c9;
    color: #1b5e20;
}

.cell-score-mid {
    background-color: #fff9c4;
    color: #6d5e00;
}

.cell-score-low {
    background-color: #ffcdd2;
    color: #b71c1c;
}

/* Total row/column emphasis */
.crosstab-total-col {
    background-color: #eef1f5;
    font-weight: 600;
    border-left: 2px solid #dee2e6;
}

.crosstab-total-row {
    background-color: #eef1f5;
    font-weight: 600;
    border-top: 2px solid #dee2e6;
}

/* Suppressed cell */
.crosstab-cell--suppressed {
    background: repeating-linear-gradient(
        45deg,
        #f5f5f5,
        #f5f5f5 4px,
        #e8e8e8 4px,
        #e8e8e8 8px
    );
    color: #999;
}

.crosstab-suppressed-label {
    font-size: 0.85rem;
    font-style: italic;
    color: #999;
}

/* Empty cell */
.crosstab-cell--empty {
    color: #ccc;
    background: #fafafa;
}

/* Heatmap cells that are also totals keep their heatmap color but bolder border */
.crosstab-total-col.cell-score-high,
.crosstab-total-col.cell-score-mid,
.crosstab-total-col.cell-score-low,
.crosstab-total-row.cell-score-high,
.crosstab-total-row.cell-score-mid,
.crosstab-total-row.cell-score-low {
    font-weight: 700;
}

/* Cross-tab dimension selectors inline */
#crossTabSelectors {
    display: inline;
    margin-left: 0.5rem;
}

#crossTabSelectors label {
    font-weight: 500;
    font-size: 0.85rem;
    margin-left: 0.5rem;
}

#crossTabSelectors .filter-select {
    min-width: 100px;
}

/* Responsive: stack controls on small screens */
@media (max-width: 600px) {
    .crosstab-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    #crossTabSelectors {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
        margin-left: 0;
        margin-top: 0.5rem;
    }
}

/* Results sub-tabs (Summary / Respondents) */
.results-sub-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 1rem;
}

.results-sub-tab {
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: #666;
    min-height: 40px;
    min-width: 44px;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.results-sub-tab:hover {
    color: var(--primary-color, #003256);
    background: rgba(0,50,86,0.04);
}

.results-sub-tab:focus-visible {
    outline: 2px solid var(--primary-color, #003256);
    outline-offset: -2px;
}

.results-sub-tab.active {
    color: var(--primary-color, #003256);
    border-bottom-color: var(--primary-color, #003256);
    font-weight: 600;
}

/* Respondents tab */
.respondents-filters {
    margin-bottom: 1rem;
}

.respondents-summary-bar {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.respondents-filter-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
    min-height: 44px;
    min-width: 200px;
}

.filter-input:focus {
    outline: 2px solid var(--primary-color, #003256);
    outline-offset: 1px;
    border-color: var(--primary-color, #003256);
}

.sortable-col {
    cursor: pointer;
    user-select: none;
}

.sortable-col:hover {
    background: #eef;
}

.sortable-col:focus-visible {
    outline: 2px solid var(--primary-color, #003256);
    outline-offset: -2px;
}

.sortable-col[aria-sort="ascending"]::after {
    content: " \25B2";
    font-size: 0.7rem;
}

.sortable-col[aria-sort="descending"]::after {
    content: " \25BC";
    font-size: 0.7rem;
}

/* Respondent detail modal */
.respondent-detail-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.respondent-detail-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 1.5rem;
    font-size: 0.9rem;
}

.respondent-detail-section {
    margin-bottom: 1.5rem;
}

.respondent-detail-section h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid #e0e0e0;
    color: var(--primary-color, #003256);
}

.respondent-detail-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.respondent-detail-item:last-child {
    border-bottom: none;
}

.respondent-detail-question {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.respondent-detail-type {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 0.35rem;
}

.respondent-detail-answer {
    font-size: 0.9rem;
    color: #333;
}

.respondent-detail-answer--empty {
    color: #aaa;
    font-style: italic;
}

.respondent-detail-answer--text {
    white-space: pre-wrap;
    background: #f9f9f9;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border: 1px solid #eee;
}

.respondent-matrix-table {
    margin-top: 0.25rem;
    font-size: 0.85rem;
}

.respondent-matrix-table th,
.respondent-matrix-table td {
    padding: 0.4rem 0.75rem;
}

@media (max-width: 600px) {
    .respondent-detail-info {
        grid-template-columns: 1fr;
    }

    .respondents-filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-input {
        min-width: auto;
    }
}

/* Display Conditions Editor */
#conditionSettings {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

#conditionSettings > legend {
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0 0.5rem;
}

.condition-rule-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.condition-rule-row select {
    min-width: 120px;
}

.condition-rule-row .condition-source-select {
    flex: 1;
    min-width: 180px;
}

.condition-rule-row .condition-operator-select {
    min-width: 140px;
}

.condition-rule-row .condition-value-input,
.condition-rule-row .condition-value-select {
    min-width: 140px;
    flex: 0 1 180px;
}

.condition-rule-row .condition-remove-btn {
    background: none;
    border: none;
    color: #c62828;
    font-size: 1.2rem;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.condition-rule-row .condition-remove-btn:focus-visible {
    outline: 2px solid var(--primary-color, #003256);
    outline-offset: 1px;
}

.condition-not-found {
    color: #c62828;
    font-style: italic;
    font-size: 0.85rem;
}

.question-condition-badge {
    color: #666;
    font-size: 0.85rem;
    margin-left: 0.25rem;
}

#conditionRulesContainer {
    margin-top: 0.75rem;
}

/* =========================================================================
   PIPING INSERT UI
   ========================================================================= */
.piping-insert-container {
    position: relative;
    margin-top: 0.5rem;
}

.piping-dropdown {
    position: absolute;
    z-index: 100;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 240px;
    overflow-y: auto;
    width: 100%;
    min-width: 300px;
}

.piping-dropdown-option {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.85rem;
    line-height: 1.4;
    display: block;
}

.piping-dropdown-option:hover,
.piping-dropdown-option:focus-visible {
    background: #e8f0fe;
}

.piping-dropdown-option:focus-visible {
    outline: 2px solid var(--primary-color, #003256);
    outline-offset: -2px;
}

.piping-dropdown-option .piping-option-section {
    color: #666;
    font-size: 0.8rem;
}

.piping-dropdown-empty {
    padding: 0.75rem;
    color: #666;
    font-style: italic;
    font-size: 0.85rem;
}

.question-piping-badge {
    color: #1565c0;
    font-size: 0.85rem;
    margin-left: 0.25rem;
}

.piping-resolved {
    font-weight: 600;
    color: #1565c0;
}

.piping-placeholder {
    font-style: italic;
    color: #666;
    background: #f5f5f5;
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

/* Skills Assessment — Creation Type Selector */
.creation-type-selector {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Skills Assessment Badge */
.status-badge--skills {
    background: #ede7f6;
    color: #5e35b1;
}

/* Competency Picker */
.skills-assessment-picker {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.75rem;
    background: #fafafa;
}

.skills-assessment-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.competency-picker-list {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fff;
    padding: 0.5rem;
}

.competency-group-fieldset {
    border: none;
    padding: 0;
    margin: 0 0 0.5rem 0;
}

.competency-group-fieldset > legend {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.competency-checkbox-item {
    padding: 0.3rem 0.25rem;
    border-bottom: 1px solid #f0f0f0;
}

.competency-checkbox-item:last-child {
    border-bottom: none;
}

.competency-checkbox-item label {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    cursor: pointer;
    min-height: 28px;
}

.competency-checkbox-item input[type="checkbox"] {
    margin-top: 0.15rem;
    min-width: 16px;
    min-height: 16px;
}

.competency-item-name {
    font-weight: 500;
}

.competency-item-desc {
    color: #666;
    font-size: 0.85rem;
}

/* Question row competency badge */
.question-competency-badge {
    display: inline-block;
    font-size: 0.75rem;
    color: #5e35b1;
    background: #ede7f6;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    margin-left: 0.25rem;
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

/* Competency link info in question editor */
.competency-link-info {
    font-size: 0.85rem;
    color: #5e35b1;
    background: #ede7f6;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    font-weight: 500;
}

/* ==========================================================================
   Competency Summary Panel (skills assessment results)
   ========================================================================== */
.competency-summary-panel {
    background: #faf9fc;
    border: 1px solid #e0dce8;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.competency-summary-panel h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 1rem 0;
}

.competency-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.competency-summary-table th {
    text-align: left;
    font-weight: 600;
    color: #555;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid #ddd;
    white-space: nowrap;
}

.competency-summary-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.competency-summary-table tbody tr:hover {
    background: #f3f0f8;
}

.competency-summary-section-header td {
    font-weight: 600;
    color: #5e35b1;
    background: #ede7f6;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Proficiency level badges */
.proficiency-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    white-space: nowrap;
}

.proficiency-badge--basic {
    background: #fbe9e7;
    color: #bf360c;
}

.proficiency-badge--intermediate {
    background: #fff8e1;
    color: #f57f17;
}

.proficiency-badge--advanced {
    background: #e8f5e9;
    color: #2e7d32;
}

.proficiency-badge--expert {
    background: #e0f2f1;
    color: #00695c;
}

/* Competency name badge in results item */
.results-competency-name {
    display: inline-block;
    font-size: 0.75rem;
    color: #5e35b1;
    background: #ede7f6;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    margin-right: 0.5rem;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}
