/* ==========================================================
   Survey App — Master Stylesheet
   Pure CSS, mobile-first, no external dependencies
   ========================================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: #1a1a2e;
    background: #f0f2f5;
    min-height: 100vh;
}

/* --- Layout --- */
#survey-app {
    max-width: 720px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.survey-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
    padding: 2rem;
    margin-top: 1.5rem;
    animation: fadeIn 0.3s ease-out;
}

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

/* --- Progress Bar --- */
.progress-container {
    background: #e9ecef;
    border-radius: 999px;
    height: 6px;
    overflow: hidden;
    margin-top: 1rem;
}

.progress-bar {
    height: 100%;
    background: #2563eb;
    border-radius: 999px;
    transition: width 0.4s ease;
    min-width: 0;
}

.progress-text {
    font-size: 0.8rem;
    color: #6b7280;
    text-align: right;
    margin-top: 0.25rem;
}

/* --- Welcome & Thank You --- */
.welcome-page, .thankyou-page, .terminate-page {
    text-align: center;
    padding: 3rem 2rem;
}

.welcome-page h1, .thankyou-page h1, .terminate-page h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #1a1a2e;
}

.welcome-page .body-text, .thankyou-page .body-text, .terminate-page .body-text {
    font-size: 1rem;
    color: #4b5563;
    margin-bottom: 2rem;
    line-height: 1.7;
}

.welcome-page .body-text p, .thankyou-page .body-text p, .terminate-page .body-text p {
    margin-bottom: 0.75rem;
}

/* --- Privacy / DSGVO Consent --- */
.privacy-details {
    text-align: left;
    margin-bottom: 1.25rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.privacy-summary {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: #2563eb;
    background: #f9fafb;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.privacy-summary::-webkit-details-marker {
    display: none;
}

.privacy-summary::before {
    content: "\25B6";
    font-size: 0.65rem;
    transition: transform 0.2s;
}

details[open] > .privacy-summary::before {
    transform: rotate(90deg);
}

.privacy-content {
    padding: 1rem 1.25rem;
    font-size: 0.85rem;
    line-height: 1.7;
    color: #374151;
    max-height: 300px;
    overflow-y: auto;
    border-top: 1px solid #e5e7eb;
}

.privacy-content h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: #1a1a2e;
}

.privacy-content p {
    margin-bottom: 0.6rem;
}

.consent-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    text-align: left;
    padding: 0.85rem 1rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 1.25rem;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}

.consent-checkbox:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.consent-checkbox:has(input:checked) {
    border-color: #2563eb;
    background: #eff6ff;
}

.consent-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #2563eb;
    flex-shrink: 0;
    margin-top: 1px;
    cursor: pointer;
}

.consent-label {
    font-size: 0.9rem;
    color: #1a1a2e;
    line-height: 1.5;
}

.consent-error {
    font-size: 0.85rem;
    color: #dc2626;
    margin-bottom: 0.75rem;
    min-height: 1.2em;
}

.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    text-decoration: none;
    line-height: 1.4;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    gap: 1rem;
}

.btn-row--single {
    justify-content: flex-end;
}

/* --- Page Title --- */
.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: #1a1a2e;
}

.page-description {
    font-size: 0.95rem;
    color: #6b7280;
    margin-bottom: 1.5rem;
}

/* --- Question Block --- */
.question-block {
    margin-bottom: 1.75rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid #f3f4f6;
    transition: opacity 0.3s ease, max-height 0.3s ease;
}

.question-block:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.question-block.hidden {
    display: none;
}

.question-label {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: #1a1a2e;
}

.question-label .required-marker {
    color: #dc2626;
    margin-left: 0.15rem;
}

.question-description {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 0.75rem;
}

.question-error {
    font-size: 0.85rem;
    color: #dc2626;
    margin-top: 0.5rem;
    display: none;
}

.question-error.visible {
    display: block;
}

/* --- Text Inputs --- */
.input-text, .input-textarea, .input-number, .input-select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    color: #1a1a2e;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

.input-text:focus, .input-textarea:focus, .input-number:focus, .input-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-text.has-error, .input-textarea.has-error, .input-number.has-error, .input-select.has-error {
    border-color: #dc2626;
}

.input-textarea {
    resize: vertical;
    min-height: 80px;
}

.input-number-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-number {
    max-width: 160px;
}

.input-unit {
    font-size: 0.9rem;
    color: #6b7280;
}

/* --- Select / Dropdown --- */
.select-wrap {
    position: relative;
}

.select-wrap::after {
    content: "";
    position: absolute;
    right: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #6b7280;
    pointer-events: none;
}

.input-select {
    padding-right: 2.5rem;
    cursor: pointer;
}

/* --- Radio & Checkbox Options --- */
.option-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-list.horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}

.option-item:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.option-item.selected {
    border-color: #2563eb;
    background: #eff6ff;
}

.option-item input[type="radio"],
.option-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #2563eb;
    flex-shrink: 0;
    cursor: pointer;
}

.option-label {
    font-size: 0.95rem;
    color: #1a1a2e;
    cursor: pointer;
}

.horizontal .option-item {
    flex: 0 0 auto;
}

/* --- Rating Scale --- */
.rating-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rating-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #6b7280;
}

.rating-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.rating-btn {
    width: 48px;
    height: 48px;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rating-btn:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.rating-btn.selected {
    border-color: #2563eb;
    background: #2563eb;
    color: #fff;
}

/* Star rating variant */
.rating-btn.star-icon {
    border: none;
    background: none;
    font-size: 2rem;
    width: 44px;
    height: 44px;
    color: #d1d5db;
}

.rating-btn.star-icon:hover,
.rating-btn.star-icon.active {
    color: #f59e0b;
}

.rating-btn.star-icon.selected {
    background: none;
    color: #f59e0b;
}

/* --- NPS Scale --- */
.nps-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nps-buttons {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.nps-btn {
    flex: 1;
    min-width: 40px;
    height: 44px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
}

.nps-btn:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.nps-btn.selected {
    color: #fff;
}

.nps-btn.detractor.selected { background: #dc2626; border-color: #dc2626; }
.nps-btn.passive.selected   { background: #f59e0b; border-color: #f59e0b; }
.nps-btn.promoter.selected  { background: #16a34a; border-color: #16a34a; }

.nps-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #6b7280;
}

/* --- Matrix / Grid --- */
.matrix-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    table-layout: fixed;
}

.matrix-table th {
    padding: 0.6rem 0.4rem;
    text-align: center;
    font-weight: 600;
    color: #374151;
    font-size: 0.75rem;
    border-bottom: 2px solid #e5e7eb;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.matrix-table th:first-child {
    text-align: left;
    width: 35%;
}

.matrix-table td {
    padding: 0.6rem 0.4rem;
    text-align: center;
    border-bottom: 1px solid #f3f4f6;
}

.matrix-table td:first-child {
    text-align: left;
    font-weight: 500;
    color: #1a1a2e;
}

.matrix-table tr:hover {
    background: #f9fafb;
}

.matrix-table input[type="radio"],
.matrix-table input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #2563eb;
    cursor: pointer;
}

/* Matrix mobile stacked layout */
@media (max-width: 600px) {
    .matrix-table thead {
        display: none;
    }

    .matrix-table, .matrix-table tbody, .matrix-table tr, .matrix-table td {
        display: block;
    }

    .matrix-table tr {
        margin-bottom: 1rem;
        border: 1.5px solid #e5e7eb;
        border-radius: 8px;
        padding: 0.75rem;
        background: #fff;
    }

    .matrix-table td:first-child {
        font-weight: 600;
        font-size: 0.95rem;
        padding-bottom: 0.5rem;
        margin-bottom: 0.5rem;
        border-bottom: 1px solid #f3f4f6;
    }

    .matrix-table td:not(:first-child) {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.4rem 0;
        text-align: left;
    }

    .matrix-table td:not(:first-child)::before {
        content: attr(data-column-label);
        font-size: 0.85rem;
        color: #6b7280;
    }
}

/* --- Slider --- */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.slider-value-display {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #2563eb;
}

.slider-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.slider-input {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #e5e7eb;
    border-radius: 999px;
    outline: none;
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: #2563eb;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    transition: transform 0.15s;
}

.slider-input::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.slider-input::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: #2563eb;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #6b7280;
}

.slider-adjust-btns {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.25rem;
}

.slider-adjust-btn {
    width: 36px;
    height: 36px;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.slider-adjust-btn:hover {
    background: #f3f4f6;
}

/* --- Noscript --- */
.noscript-message {
    text-align: center;
    padding: 3rem 1rem;
}

.noscript-message h2 {
    margin-bottom: 1rem;
}

/* --- Loading spinner --- */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2.5px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 0.5rem;
}

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

/* --- Responsive --- */
@media (min-width: 640px) {
    #survey-app {
        padding: 2rem;
    }

    .survey-card {
        padding: 2.5rem;
    }

    .welcome-page, .thankyou-page, .terminate-page {
        padding: 4rem 3rem;
    }
}

@media (max-width: 480px) {
    .survey-card {
        padding: 1.25rem;
        border-radius: 8px;
    }

    .rating-buttons {
        gap: 0.35rem;
    }

    .rating-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .nps-buttons {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        gap: 4px;
    }

    .nps-btn {
        min-width: unset;
        height: 40px;
        font-size: 0.85rem;
    }

    .btn-row {
        flex-direction: column-reverse;
        gap: 0.75rem;
    }

    .btn-row .btn {
        width: 100%;
    }
}
