/* ========================================
   调研问卷系统 - 响应式样式
   支持手机端 + PC端
   ======================================== */

/* CSS变量 */
:root {
    --primary: #4F46E5;
    --primary-light: #818CF8;
    --primary-dark: #3730A3;
    --primary-bg: #EEF2FF;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --text: #1F2937;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;
    --bg: #F9FAFB;
    --bg-white: #FFFFFF;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --max-width: 800px;
}

/* 全局样式 */
*, *::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", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* 头部导航 */
.header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    cursor: pointer;
}

.user-area {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.user-nickname {
    font-size: 0.9rem;
    color: var(--text);
}

/* 主体 */
.main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 24px 16px;
    min-height: calc(100vh - 56px);
}

/* 英雄区 */
.hero {
    text-align: center;
    padding: 48px 16px 32px;
}

.hero h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
}

.hero p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* 卡片 */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 24px;
    margin-bottom: 16px;
}

.login-card {
    max-width: 420px;
    margin: 40px auto;
    text-align: center;
}

.survey-card {
    max-width: 640px;
    margin: 16px auto;
}

.card h2 {
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: var(--text);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* 区域标题 */
.section {
    margin-top: 32px;
}

.section h2 {
    font-size: 1.15rem;
    margin-bottom: 12px;
    color: var(--text);
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-outline {
    background: var(--bg-white);
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary-bg);
}

.btn-text {
    background: none;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-text:hover {
    color: var(--primary);
}

.btn-sm {
    padding: 6px 16px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1.05rem;
}

.btn-block {
    width: 100%;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #DC2626;
}

/* 表单 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.required {
    color: var(--danger);
}

.input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--bg-white);
    transition: border-color 0.2s;
    outline: none;
    font-family: inherit;
}

.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.input::placeholder {
    color: var(--text-light);
}

.textarea {
    resize: vertical;
    min-height: 80px;
}

/* 单选按钮组 */
.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.radio-group-vertical {
    flex-direction: column;
    gap: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    user-select: none;
}

.radio-label:hover {
    border-color: var(--primary-light);
    background: var(--primary-bg);
}

.radio-label input[type="radio"] {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
}

.radio-label:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
}

.form-actions {
    margin-top: 24px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* 问卷列表 */
.survey-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.survey-item {
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    transition: box-shadow 0.2s;
}

.survey-item:hover {
    box-shadow: var(--shadow-md);
}

.survey-item-info {
    flex: 1;
    min-width: 0;
}

.survey-item-info h3 {
    font-size: 1rem;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.survey-item-info .meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.survey-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-active {
    background: #D1FAE5;
    color: #065F46;
}

.badge-inactive {
    background: #FEE2E2;
    color: #991B1B;
}

/* 微信扫码 */
.wechat-login {
    margin: 24px 0;
}

.qrcode-container {
    width: 200px;
    height: 200px;
    margin: 0 auto 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #fff;
}

.qrcode-container canvas,
.qrcode-container img {
    width: 180px;
    height: 180px;
}

.qrcode-placeholder {
    text-align: center;
    color: var(--text-secondary);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hint {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* 开发模式 */
.dev-login {
    margin-top: 24px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.dev-toggle {
    cursor: pointer;
    color: var(--text-light);
    font-size: 0.85rem;
}

.dev-form {
    margin-top: 12px;
    display: flex;
    gap: 8px;
}

.dev-form .input {
    flex: 1;
}

/* 表格 */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table th {
    background: var(--primary-bg);
    font-weight: 600;
    color: var(--text);
    position: sticky;
    top: 0;
}

.data-table tr:hover td {
    background: var(--bg);
}

/* 结果页 */
.result-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.result-header h2 {
    margin-bottom: 0;
}

.result-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.result-stats {
    margin-bottom: 16px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* 状态页 */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-light);
    font-size: 0.95rem;
}

.success-state {
    text-align: center;
    padding: 32px 16px;
}

.success-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.success-state h3 {
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: var(--success);
}

.success-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* Toast提示 */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* 响应式设计 */

/* 手机端适配 (宽度 < 640px) */
@media (max-width: 640px) {
    .hero h1 {
        font-size: 1.5rem;
    }

    .hero {
        padding: 32px 16px 24px;
    }

    .card {
        padding: 20px 16px;
        border-radius: var(--radius-sm);
    }

    .main {
        padding: 16px 12px;
    }

    .survey-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .survey-item-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .radio-group {
        flex-direction: column;
    }

    .radio-label {
        width: 100%;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px 6px;
    }

    .header-inner {
        padding: 0 12px;
    }

    .btn-lg {
        padding: 12px 24px;
    }
}

/* 平板端适配 (640px - 1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
    .main {
        padding: 24px 24px;
    }
}

/* PC端适配 (宽度 > 1024px) */
@media (min-width: 1025px) {
    .hero h1 {
        font-size: 2.2rem;
    }

    .card {
        padding: 32px;
    }

    .survey-item {
        padding: 20px;
    }
}
