/**
 * Cranial Sacral Questionnaire - Frontend Styles
 * 使用 Custom Auth Forms 颜色体系
 */

.csq-questionnaire-wrapper {
    max-width: 900px;
    margin: 40px auto;
    padding: 20px;
}

/* 表单头部 */
.csq-header {
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid #ae99ca;
}

.csq-title {
    font-size: 28px;
    color: #0c0c0c;
    margin: 0 0 15px 0;
    font-family: 'Work Sans', sans-serif;
    font-weight: 600;
}

.csq-description {
    font-size: 15px;
    color: #666;
    line-height: 1.8;
    margin: 0;
}

/* 章节 */
.csq-section {
    margin-bottom: 40px;
    padding: 25px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.csq-section-title {
    font-size: 20px;
    color: #0c0c0c;
    margin: 0 0 10px 0;
    font-family: 'Work Sans', sans-serif;
    font-weight: 600;
    padding-bottom: 10px;
    border-bottom: 2px solid #ae99ca;
}

.csq-section-desc {
    font-size: 14px;
    color: #999;
    margin: 0 0 20px 0;
    font-style: italic;
}

/* 表单行 */
.csq-form-row {
    margin-bottom: 25px;
}

.csq-form-row label {
    display: block;
    margin-bottom: 10px;
    font-weight: 400;
    color: #0c0c0c;
    font-family: 'Work Sans', sans-serif;
    font-size: 15px;
}

/* 问题 30 加粗 */
.csq-consent-row label {
    font-weight: 600;
}

.csq-consent-row .csq-consent-label span {
    font-weight: 600;
}

/* 输入框 */
.csq-form input[type="text"],
.csq-form input[type="number"],
.csq-form input[type="email"],
.csq-form input[type="tel"],
.csq-form textarea {
    width: 100%;
    padding: 14px 28px;
    border: 0.5px solid #dddddd;
    border-radius: 4px;
    font-size: 15px;
    font-family: 'Work Sans', sans-serif;
    transition: all 0.3s;
    box-sizing: border-box;
    background-color: #fff !important;
}

.csq-form input:focus,
.csq-form textarea:focus {
    border-color: #ae99ca;
    outline: none;
    box-shadow: 0 0 0 2px rgba(174, 153, 202, 0.2);
}

/* 只读输入框 */
.csq-readonly-input {
    background-color: #f8f9fa !important;
    cursor: not-allowed;
    color: #666;
}

.csq-edit-profile-link {
    margin-top: 8px;
    font-size: 13px;
}

.csq-edit-profile-link a {
    color: #ae99ca;
    text-decoration: none;
    transition: color 0.3s;
}

.csq-edit-profile-link a:hover {
    color: #8667b0;
    text-decoration: underline;
}

.csq-form textarea {
    resize: vertical;
    min-height: 100px;
}

/* 选择框 */
.csq-select {
    width: 100%;
    padding: 14px 40px 14px 28px;
    border: 0.5px solid #dddddd;
    border-radius: 4px;
    font-size: 15px;
    font-family: 'Work Sans', sans-serif;
    background-color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 20px center;
    background-size: 12px;
}

.csq-select:focus {
    border-color: #ae99ca;
    outline: none;
    box-shadow: 0 0 0 2px rgba(174, 153, 202, 0.2);
}

/* 单选/复选组 */
.csq-radio-group,
.csq-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}

.csq-radio-label,
.csq-checkbox-label {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    color: #0c0c0c;
    font-weight: 400;
}

.csq-radio-label:hover,
.csq-checkbox-label:hover {
    background: #f0f0f0;
    border-color: #ae99ca;
}

.csq-radio-label input,
.csq-checkbox-label input {
    margin-right: 8px;
}

/* 单选框选中颜色 - 全局紫色（强制覆盖浏览器默认） */
.csq-radio-label input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #ae99ca;
    border-radius: 50%;
    outline: none;
    position: relative;
    cursor: pointer;
    background: #fff;
    padding: 0;
    margin: 0;
}

.csq-radio-label input[type="radio"]:checked {
    background: #ae99ca;
    border-color: #ae99ca;
}

/* 复选框选中颜色 */
.csq-checkbox-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid #ae99ca;
    border-radius: 3px;
    outline: none;
    position: relative;
    cursor: pointer;
    background: #fff;
}

.csq-checkbox-label input[type="checkbox"]:checked {
    background: #ae99ca;
    border-color: #ae99ca;
}

.csq-checkbox-label input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    color: #fff;
    font-size: 12px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.csq-checkbox-group .csq-checkbox-label {
    min-width: 200px;
}

/* 同意条款 */
.csq-consent-row .csq-consent-label {
    display: flex;
    align-items: flex-start;
    font-weight: 600;
    font-size: 14px;
    color: #0c0c0c;
    line-height: 1.6;
}

.csq-consent-row input[type="checkbox"] {
    margin-top: 4px;
    margin-right: 10px;
}

/* 自动日期 */
.csq-auto-date {
    padding: 14px 28px;
    background: #f8f9fa;
    border: 0.5px solid #dddddd;
    border-radius: 4px;
    font-size: 15px;
    color: #0c0c0c;
    font-family: 'Work Sans', sans-serif;
}

.csq-hint {
    font-size: 13px;
    color: #999;
    margin-top: 8px;
}

/* 自定义弹窗 */
.csq-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
}

.csq-modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.csq-modal-title {
    font-size: 18px;
    color: #0c0c0c;
    margin: 0 0 15px 0;
    font-weight: 600;
}

.csq-modal-content {
    font-size: 14px;
    color: #666;
    line-height: 1.8;
    white-space: pre-wrap;
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.csq-modal-btn {
    display: block;
    margin: 0 auto;
    padding: 12px 40px !important;
    background: #ae99ca !important;
    color: #ffffff !important;
    border: 2px solid #ae99ca !important;
    border-radius: 8px;
    font-size: 14px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    outline: none !important;
    box-shadow: none !important;
}

.csq-modal-btn:hover {
    background: #8667b0 !important;
    border-color: #8667b0 !important;
    color: #ffffff !important;
}

.csq-modal-btn:active,
.csq-modal-btn:focus {
    background: #8667b0 !important;
    border-color: #8667b0 !important;
    color: #ffffff !important;
    outline: none !important;
    box-shadow: none !important;
}

/* 表单底部 */
.csq-form-footer {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
}

.csq-completion-message {
    font-size: 16px;
    color: #0c0c0c;
    font-weight: 600;
    margin: 0 0 10px 0;
}

.csq-check-hint {
    font-size: 14px;
    color: #666;
    margin: 0;
}

/* 提交按钮 */
.csq-form-actions {
    margin-top: 30px;
    text-align: center;
}

.csq-submit-btn {
    min-width: 200px;
    padding: 16px 40px;
    font-size: 16px;
}

/* 签名板 */
.csq-signature-wrapper {
    border: 2px solid #dddddd;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.csq-signature-canvas {
    width: 100%;
    height: 200px;
    cursor: crosshair;
    display: block;
    background: #fff;
}

.csq-signature-actions {
    padding: 12px 20px;
    background: #f8f9fa;
    border-top: 1px solid #dddddd;
}

.csq-clear-signature {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #fff;
    border: 1px solid #dddddd;
    border-radius: 6px;
    color: #666;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
}

.csq-clear-signature:hover {
    background: #f0f0f0;
    border-color: #ae99ca;
    color: #ae99ca;
}

.csq-signature-preview {
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    text-align: center;
}

.csq-signature-preview img {
    max-width: 300px;
    border: 2px solid #9ACA9E;
    border-radius: 4px;
    background: #fff;
}

/* 条件显示行 */
.csq-conditional-row {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-left: 3px solid #ae99ca;
    border-radius: 4px;
}

/* 成功卡片 - 复用 Custom Auth Forms 样式 */
#csq-success-card {
    animation: csqFadeIn 0.5s ease;
}

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

#csq-summary-content {
    max-height: 500px;
    overflow-y: auto;
}

.summary-title {
    font-size: 16px;
    color: #0c0c0c;
    margin: 0 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #ae99ca;
    font-family: 'Work Sans', sans-serif;
    font-weight: 600;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

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

.summary-label {
    color: #666;
    font-weight: 500;
    flex: 0 0 200px;
}

.summary-value {
    color: #0c0c0c;
    font-weight: 400;
    text-align: right;
    flex: 1;
}

.summary-value.warning {
    color: #E57373;
}

.summary-value.success {
    color: #9ACA9E;
}

.summary-value.signature-placeholder {
    color: #9ACA9E;
    font-style: italic;
}

/* 成功卡片头部图标 */
.success-icon svg {
    display: block;
    margin: 0 auto;
}

/* 打印样式 */
@media print {
    /* 隐藏所有非汇总内容 */
    body > *:not(#csq-success-card),
    .csq-language-switcher,
    .csq-form-actions,
    .success-actions,
    .csq-header,
    .csq-section-title,
    .csq-section-desc,
    .csq-form-footer,
    .csq-hint,
    .csq-clear-signature,
    .csq-signature-actions,
    .csq-edit-profile-link {
        display: none !important;
    }
    
    body {
        background: #fff;
    }
    
    .csq-questionnaire-wrapper {
        margin: 0;
        padding: 0;
        max-width: 100%;
    }
    
    #csq-questionnaire-form {
        display: none !important;
    }
    
    #csq-success-card {
        display: block !important;
        box-shadow: none;
        position: static;
        width: 100%;
    }
    
    .register-success-card {
        box-shadow: none;
        padding: 20px;
    }
    
    .success-header {
        margin-bottom: 20px;
    }
    
    #csq-summary-content {
        max-height: none;
        overflow: visible;
    }
    
    .summary-item {
        page-break-inside: avoid;
    }
    
    .csq-signature-preview img {
        max-width: 200px;
    }
}

/* 响应式 */
@media (max-width: 768px) {
    .csq-questionnaire-wrapper {
        padding: 15px;
    }
    
    .csq-title {
        font-size: 22px;
    }
    
    .csq-section {
        padding: 20px 15px;
    }
    
    .csq-radio-group,
    .csq-checkbox-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .csq-checkbox-group .csq-checkbox-label {
        min-width: 100%;
    }
    
    .summary-item {
        flex-direction: column;
        gap: 5px;
    }
    
    .summary-label {
        flex: none;
    }
    
    .summary-value {
        text-align: left;
    }
}
