/**
 * 问卷调查系统 - 用户端样式
 * 设计原则：移动端优先、按钮大、输入框高、扫码访问友好
 */

/* ==================== 基础重置 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 16px; /* 移动端基准字号，避免 iOS 自动缩放 */
    color: #333;
    background: #f5f7fa;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

/* ==================== 首页头部 ==================== */
.site-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 40px 20px 60px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.site-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 30px 30px;
    opacity: 0.5;
}

.site-logo {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.site-logo .logo-icon {
    font-size: 40px;
    margin-right: 10px;
    vertical-align: middle;
}

.site-slogan {
    font-size: 15px;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ==================== 主容器 ==================== */
.container {
    max-width: 1000px;
    margin: -40px auto 40px;
    padding: 0 20px;
    position: relative;
    z-index: 2;
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin: 24px 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: #667eea;
    border-radius: 2px;
}

/* ==================== 问卷卡片列表 ==================== */
.survey-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.survey-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    transition: all 0.3s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    border: 1px solid #f0f0f0;
}

.survey-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);
    border-color: #667eea;
}

.survey-card-cover {
    height: 140px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    color: rgba(255, 255, 255, 0.9);
    position: relative;
}

.survey-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.survey-card-cover .status-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
}

.survey-card-cover .status-badge.ended {
    background: #ffeaea;
    color: #ff4d4f;
}

.survey-card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.survey-card-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.4;
    /* 两行省略 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.survey-card-desc {
    font-size: 13px;
    color: #888;
    line-height: 1.5;
    margin-bottom: 12px;
    /* 两行省略 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.survey-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #999;
    padding-top: 12px;
    border-top: 1px solid #f5f5f5;
}

.survey-card-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.survey-card-meta .enter-btn {
    background: #667eea;
    color: #fff;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.2s;
}

.survey-card:hover .enter-btn {
    background: #764ba2;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #999;
}

.empty-state .empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state .empty-text {
    font-size: 16px;
    margin-bottom: 8px;
}

.empty-state .empty-desc {
    font-size: 13px;
    color: #bbb;
}

/* ==================== 站点底部 ==================== */
.site-footer {
    text-align: center;
    padding: 30px 20px;
    color: #999;
    font-size: 13px;
    line-height: 1.8;
}

.site-footer .icp a {
    color: #999;
}

.site-footer .icp a:hover {
    color: #667eea;
}

/* ==================== 问卷填写页 ==================== */
.form-page {
    min-height: 100vh;
    padding: 20px;
}

.form-page-container {
    max-width: 700px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.form-page-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 28px 24px;
    text-align: center;
}

.form-page-header .form-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
}

.form-page-header .form-desc {
    font-size: 14px;
    opacity: 0.9;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
}

.form-page-body {
    padding: 24px;
}

.form-page-footer {
    padding: 20px 24px 32px;
    background: #fff;
    border-top: 1px solid #f5f5f5;
}

/* 提交按钮 - 大且醒目 */
.btn-submit {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    -webkit-appearance: none;
    appearance: none;
}

.btn-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-submit:active {
    transform: translateY(0);
}

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

/* 保存草稿按钮 */
.btn-draft {
    width: 100%;
    padding: 12px;
    background: #f5f5f5;
    color: #666;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.btn-draft:hover {
    background: #eee;
}

/* ==================== 表单字段样式（覆盖 form-renderer 内联样式） ==================== */
.sf-form-title {
    display: none !important; /* 隐藏 renderer 内部标题，使用页面顶部样式 */
}

.sf-form-desc {
    display: none !important;
}

.sf-field-wrapper {
    margin-bottom: 22px !important;
}

.sf-label {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #333 !important;
    margin-bottom: 10px !important;
}

.sf-input,
.sf-textarea,
.sf-select {
    height: 48px;
    font-size: 16px !important; /* iOS 防缩放 */
    padding: 12px 14px !important;
    border: 1.5px solid #e0e0e0 !important;
    border-radius: 8px !important;
    background: #fafbfc !important;
    transition: all 0.2s !important;
}

.sf-input:focus,
.sf-textarea:focus,
.sf-select:focus {
    border-color: #667eea !important;
    background: #fff !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
}

.sf-textarea {
    height: auto !important;
    min-height: 100px !important;
    padding: 12px 14px !important;
}

.sf-options {
    gap: 4px !important;
}

.sf-option {
    padding: 12px 14px !important;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fafbfc;
    transition: all 0.2s;
}

.sf-option:hover {
    border-color: #667eea;
    background: #fff;
}

.sf-option input {
    width: 20px !important;
    height: 20px !important;
    margin-right: 12px !important;
}

.sf-option:has(input:checked) {
    border-color: #667eea;
    background: #f0f4ff;
}

.sf-divider {
    height: 2px !important;
    background: #f0f0f0 !important;
    margin: 16px 0 !important;
}

.sf-paragraph {
    background: #fff8e6 !important;
    color: #8a6d3b !important;
    padding: 14px !important;
    border-radius: 8px !important;
    border-left: 4px solid #faad14 !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
}

/* ==================== 校验错误提示 ==================== */
.field-error {
    color: #ff4d4f;
    font-size: 13px;
    margin-top: 6px;
    padding-left: 4px;
}

.sf-field-wrapper.has-error .sf-input,
.sf-field-wrapper.has-error .sf-textarea,
.sf-field-wrapper.has-error .sf-select {
    border-color: #ff4d4f !important;
    background: #fff5f5 !important;
}

.sf-field-wrapper.has-error .sf-option {
    border-color: #ff4d4f;
}

/* ==================== 状态提示页 ==================== */
.status-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.status-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 30px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.status-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 40px;
}

.status-icon.success {
    background: #f0fff4;
    color: #52c41a;
}

.status-icon.error {
    background: #fff5f5;
    color: #ff4d4f;
}

.status-icon.warning {
    background: #fffbe6;
    color: #faad14;
}

.status-title {
    font-size: 22px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}

.status-message {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 24px;
}

.status-actions {
    display: flex;
    gap: 12px;
}

.status-actions .btn {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-size: 15px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.status-actions .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.status-actions .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.status-actions .btn-default {
    background: #f5f5f5;
    color: #333;
}

/* ==================== Toast 消息 ==================== */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: calc(100% - 40px);
    max-width: 400px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.3s ease;
    text-align: center;
}

.toast.success { background: #52c41a; }
.toast.error { background: #ff4d4f; }
.toast.warning { background: #faad14; }
.toast.info { background: #1890ff; }

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

/* ==================== Loading 遮罩 ==================== */
.loading-mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.loading-mask.show {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f0f0f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .site-header {
        padding: 30px 16px 50px;
    }

    .site-logo {
        font-size: 26px;
    }

    .site-logo .logo-icon {
        font-size: 32px;
    }

    .site-slogan {
        font-size: 14px;
    }

    .container {
        padding: 0 16px;
        margin-top: -30px;
    }

    .survey-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .form-page {
        padding: 12px;
    }

    .form-page-header {
        padding: 24px 20px;
    }

    .form-page-header .form-title {
        font-size: 20px;
    }

    .form-page-header .form-desc {
        font-size: 13px;
    }

    .form-page-body {
        padding: 20px 16px;
    }

    .form-page-footer {
        padding: 16px 16px 24px;
    }

    .btn-submit {
        font-size: 16px;
        padding: 14px;
    }

    .status-card {
        padding: 32px 24px;
    }

    .status-title {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .survey-card-cover {
        height: 120px;
        font-size: 44px;
    }

    .sf-input,
    .sf-textarea,
    .sf-select {
        height: 50px;
        font-size: 16px !important;
    }
}
