.body {
    background: #faf6f0;
    width: 100%;
    padding: 32px 0;
}

.survey-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.survey-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.survey-title {
    margin: 0;
    font-size: 26px;
    line-height: 1.4;
    color: #C8102E;
}

.survey-muted {
    margin: 0;
    color: #5f6b7a;
    font-size: 14px;
    line-height: 1.6;
}

/* minmax(0, ...) + min-width: 0: không để nội dung dài (tiêu đề, link) kéo cột rộng quá màn hình */
.survey-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 24px;
    align-items: flex-start;
}

.survey-layout > * {
    min-width: 0;
}

@media (max-width: 992px) {
    .survey-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }
}

.survey-list {
    max-height: 600px;
    overflow-y: auto;
    padding: 6px 0;
}

.survey-card {
    background: #ffffff;
    border: 1px solid rgba(17, 17, 17, 0.08);
    border-radius: 6px;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(17, 17, 17, 0.06);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    margin-bottom: 12px;
}

/* Hover chỉ cho máy có chuột (trên điện thoại hover bị "dính" sau khi chạm) */
@media (hover: hover) {
    .survey-card:hover {
        border-color: #C8102E;
        box-shadow: 0 12px 30px rgba(200,16,46,0.18);
        transform: translateY(-2px);
    }
}

/* Thẻ đang chọn */
.survey-card.is-active {
    border-color: #C8102E;
    box-shadow: inset 4px 0 0 #C8102E, 0 8px 24px rgba(200,16,46,0.12);
}

/* Tiêu đề tối đa 2 dòng thay vì 1 dòng nowrap (nowrap làm tràn ngang trên mobile) */
.survey-card__title {
    margin: 0;
    font-size: 17px;
    line-height: 1.5;
    color: #7a0e19;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.survey-empty,
.survey-detail {
    background: #ffffff;
    border: 1px solid rgba(17, 17, 17, 0.08);
    border-radius: 6px;
    padding: 18px;
    box-shadow: 0 8px 24px rgba(17, 17, 17, 0.06);
}

.survey-empty__title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 6px;
    color: #7a0e19;
}

.survey-detail.hidden {
    display: none;
}

.survey-detail__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

#survey-title {
    margin: 0;
    font-size: 20px;
    line-height: 1.5;
    color: #7a0e19;
    word-break: break-word;
}

#survey-desc {
    margin: 0 0 12px;
    color: #303030;
    line-height: 1.6;
    font-size: 14px;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.survey-questions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.survey-respondent {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(17, 17, 17, 0.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.survey-respondent__title {
    font-weight: 700;
    color: #7a0e19;
}

.survey-respondent__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
    gap: 12px 16px;
}

.question label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #7a0e19;
    word-break: break-word;
}

.question input,
.question select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid rgba(17, 17, 17, 0.12);
    background: #fdf4f4;
    font-size: 14px;
    color: #202733;
}

.question input[type="file"] {
    padding: 8px;
    background: #ffffff;
}

.question input:focus,
.question select:focus {
    outline: none;
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200,16,46,0.12);
}

.question.has-error label,
.question.has-error .option-item span {
    color: #c0392b;
}

.question input.has-error,
.question select.has-error {
    border-color: #c0392b;
    background: #fff7f6;
}

.field-error {
    margin-top: 4px;
    color: #c0392b;
    font-size: 13px;
    min-height: 18px;
}

.required-mark {
    color: #c0392b;
}

.file-hint {
    margin-top: 6px;
    font-size: 13px;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    margin-top: 12px;
}

.actions-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.option-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* label.option-item cũng trúng rule ".question label" (block, đậm, đỏ) -> trả lại kiểu của đáp án */
.question .option-item {
    display: flex;
    align-items: flex-start;
    margin: 0;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: #202733;
    word-break: break-word;
    cursor: pointer;
}

/* khoảng cách ô chọn - chữ dùng margin (iOS < 14.5 không hỗ trợ gap trong flex) */
.question .option-item input {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin: 2px 10px 0 0;
    padding: 0;
    accent-color: #C8102E;
    cursor: pointer;
}

.survey-btn {
    background: #C8102E!important;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.survey-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(200,16,46,0.24);
}

.survey-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.survey-status {
    font-size: 14px;
    color: #5f6b7a;
}

.survey-status.is-success {
    color: #1b8c54;
}

.survey-status.is-error {
    color: #c0392b;
}

.submit-hint {
    font-size: 13px;
    color: #c0392b;
}

.hidden {
    display: none !important;
}

/* ===================== TABLET / MOBILE ===================== */
/* Danh sách cuộc thăm dò thành 1 hàng thẻ vuốt ngang -> phần trả lời hiện ngay bên dưới,
   không bị cả danh sách dài đẩy xuống. */
@media (max-width: 992px) {
    .survey-list {
        position: relative;          /* JS tính vị trí thẻ đang chọn để cuộn tới */
        display: flex;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 4px 2px 12px;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
    }

    .survey-card {
        flex: 0 0 78%;               /* thẻ sau ló ra một phần -> biết là vuốt được */
        max-width: 320px;
        margin: 0 10px 0 0;          /* margin thay gap: chạy cả iOS cũ */
        padding: 12px 14px;
        scroll-snap-align: start;
    }

    .survey-card__title {
        font-size: 15px;
    }

    /* iPhone/iPad tự phóng to trang khi chạm vào ô có chữ < 16px */
    .question input:not([type="radio"]):not([type="checkbox"]):not([type="file"]),
    .question select {
        font-size: 16px;
    }
}

@media (max-width: 767.98px) {
    .body {
        padding: 16px 0 24px;
    }

    .survey-section {
        gap: 12px;
    }

    .survey-title {
        font-size: 22px;
    }

    .survey-empty,
    .survey-detail {
        padding: 14px;
    }

    #survey-title {
        font-size: 18px;
    }

    .question .option-item {
        font-size: 15px;
    }

    .survey-respondent__grid {
        gap: 4px;
    }

    .actions,
    .actions-row {
        align-items: stretch;
        width: 100%;
    }

    .actions-row {
        flex-direction: column;
        gap: 8px;
    }

    .survey-btn {
        width: 100%;
        padding: 12px 18px;
        font-size: 16px;
    }
}

/* ===================== RIÊNG iOS SAFARI (iPhone, iPad) ===================== */
/* -webkit-touch-callout chỉ iOS Safari hỗ trợ -> khối này không ảnh hưởng Android / máy tính */
@supports (-webkit-touch-callout: none) {
    /* bỏ viền bóng, bo góc mặc định của iOS để ô nhập giống thiết kế (không đụng radio/checkbox/file) */
    .question input[type="text"],
    .question input[type="email"],
    .question input[type="tel"],
    .question input[type="number"],
    .question input[type="date"],
    .question input:not([type]) {
        -webkit-appearance: none;
        appearance: none;
    }

    /* ô ngày sinh khi trống bị co thấp + chữ căn giữa trên iOS */
    .question input[type="date"] {
        display: block;
        min-height: 46px;
        line-height: 1.4;
    }

    .question input[type="date"]::-webkit-date-and-time-value {
        margin: 0;
        text-align: left;
    }

    /* select: bỏ kiểu xám mặc định (thấp hơn ô nhập), tự vẽ mũi tên */
    .question select {
        -webkit-appearance: none;
        appearance: none;
        min-height: 46px;
        padding-right: 36px;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%237a0e19' stroke-width='1.6'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 12px 8px;
    }
}
