/**
 * HR计算器系统 - 移动端优先设计
 * Mobile-First UI System
 */

/* ===== 基础变量 ===== */
:root {
    /* 主题色 */
    --primary: #4F46E5;
    --primary-light: #818CF8;
    --primary-dark: #3730A3;
    
    /* 功能色 */
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
    
    /* 中性色 */
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    
    /* 间距 */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    
    /* 圆角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    /* 阴影 */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    
    /* 安全区域 */
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

/* ===== 基础重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--gray-800);
    background: var(--gray-50);
    min-height: 100vh;
    overflow-x: hidden;
    padding-bottom: var(--safe-bottom);
}

/* ===== 页面容器 ===== */
.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: white;
    padding: var(--space-4);
    padding-top: calc(var(--space-4) + var(--safe-top));
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.page-header-back {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--gray-600);
    background: var(--gray-100);
    border: none;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.15s;
}

.page-header-back:active {
    background: var(--gray-200);
    transform: scale(0.95);
}

.page-header-title {
    flex: 1;
    font-size: 17px;
    font-weight: 600;
    color: var(--gray-900);
}

.page-content {
    flex: 1;
    padding: var(--space-4);
    padding-bottom: calc(var(--space-4) + 80px);
}

/* ===== 首页网格 ===== */
.home-header {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.home-logo {
    width: 64px;
    height: 64px;
    background: rgba(255,255,255,0.2);
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: var(--space-4);
}

.home-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: var(--space-2);
}

.home-subtitle {
    font-size: 14px;
    opacity: 0.85;
}

/* 排序按钮 */
.sort-toggle-btn {
    position: absolute;
    top: var(--space-6);
    right: var(--space-4);
    background: rgba(255,255,255,0.25);
    border: none;
    color: white;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: var(--space-1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.sort-toggle-btn:active {
    transform: scale(0.95);
    background: rgba(255,255,255,0.35);
}

/* 工具网格 */
.tools-list {
    padding: var(--space-4);
}

.tool-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    background: white;
    padding: var(--space-5);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    cursor: pointer;
    transition: all 0.15s;
    -webkit-user-select: none;
    user-select: none;
}

.tool-item:active {
    transform: scale(0.98);
    background: var(--gray-50);
}

.tool-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    flex-shrink: 0;
}

.tool-info {
    flex: 1;
    min-width: 0;
}

.tool-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: var(--space-1);
}

.tool-desc {
    font-size: 13px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-arrow {
    color: var(--gray-400);
    font-size: 14px;
    flex-shrink: 0;
}

/* 拖拽手柄 */
.drag-handle {
    display: none;
    color: var(--gray-400);
    font-size: 18px;
    cursor: move;
    padding: var(--space-2);
    margin: calc(-1 * var(--space-2));
    touch-action: none;
}

/* 排序模式 */
.tools-list.sort-mode .tool-item {
    cursor: move;
}

.tools-list.sort-mode .drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tools-list.sort-mode .tool-arrow {
    display: none;
}

/* 拖拽中的状态 */
.tool-item.dragging {
    opacity: 0.5;
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    position: relative;
}

.tools-list.sort-mode .tool-item:not(.dragging) {
    transition: transform 0.2s ease;
}

/* 工具颜色 */
.tool-social .tool-icon { background: linear-gradient(135deg, #10B981, #059669); }
.tool-injury .tool-icon { background: linear-gradient(135deg, #F59E0B, #D97706); }
.tool-recruit .tool-icon { background: linear-gradient(135deg, #3B82F6, #2563EB); }
.tool-attend .tool-icon { background: linear-gradient(135deg, #8B5CF6, #7C3AED); }
.tool-compen .tool-icon { background: linear-gradient(135deg, #EF4444, #DC2626); }
.tool-fund .tool-icon { background: linear-gradient(135deg, #6B7280, #4B5563); }
.tool-doc .tool-icon { background: linear-gradient(135deg, #06B6D4, #0891B2); }
.tool-disc .tool-icon { background: linear-gradient(135deg, #EC4899, #DB2777); }
.tool-mbti .tool-icon { background: linear-gradient(135deg, #8B5CF6, #6D28D9); }

/* ===== 计算器模态框 ===== */
.calc-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
}

.calc-modal.show {
    display: block;
}

.calc-modal-bg {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    animation: fadeIn 0.2s ease;
}

.calc-modal-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 95vh;
    background: white;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.calc-modal-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

.calc-modal-handle {
    width: 36px;
    height: 4px;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
}

.calc-modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--gray-100);
    border: none;
    color: var(--gray-600);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calc-modal-title {
    flex: 1;
    font-size: 17px;
    font-weight: 600;
    color: var(--gray-900);
}

.calc-modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* ===== 表单组件 ===== */
.form-section {
    padding: var(--space-5);
    background: white;
    margin-bottom: var(--space-3);
}

.form-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.form-section-title i {
    color: var(--primary);
}

.form-group {
    margin-bottom: var(--space-5);
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: var(--space-2);
}

.form-input {
    width: 100%;
    height: 52px;
    padding: 0 var(--space-4);
    font-size: 16px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: var(--gray-50);
    color: var(--gray-900);
    transition: all 0.15s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-input::placeholder {
    color: var(--gray-400);
}

/* 带单位的输入框 */
.form-input-wrap {
    position: relative;
}

.form-input-unit {
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: var(--gray-500);
    font-weight: 500;
}

.form-input.has-unit {
    padding-right: 60px;
}

/* 选择框 */
.form-select {
    width: 100%;
    height: 52px;
    padding: 0 44px 0 var(--space-4);
    font-size: 16px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: var(--gray-50) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
    color: var(--gray-900);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.form-select:focus {
    border-color: var(--primary);
    background-color: white;
}

/* 提示信息 */
.form-hint {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

/* 信息卡片 */
.info-card {
    background: var(--gray-50);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-top: var(--space-4);
}

.info-card-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-2) 0;
    font-size: 14px;
}

.info-card-label {
    color: var(--gray-500);
}

.info-card-value {
    color: var(--primary);
    font-weight: 600;
}

/* ===== 按钮 ===== */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 52px;
    padding: 0 var(--space-6);
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s;
    -webkit-user-select: none;
    user-select: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:active {
    background: var(--primary-dark);
}

.btn-outline {
    background: white;
    color: var(--gray-700);
    border: 1.5px solid var(--gray-200);
}

.btn-outline:active {
    background: var(--gray-50);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-block {
    width: 100%;
}

/* 固定底部按钮 */
.fixed-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-4);
    padding-bottom: calc(var(--space-4) + var(--safe-bottom));
    background: white;
    border-top: 1px solid var(--gray-200);
    z-index: 100;
}

.btn-group {
    display: flex;
    gap: var(--space-3);
}

.btn-group .btn {
    flex: 1;
}

/* ===== 结果区域 ===== */
.result-panel {
    background: white;
    margin: var(--space-4);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.result-header {
    padding: var(--space-6);
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    text-align: center;
}

.result-icon {
    width: 56px;
    height: 56px;
    background: rgba(255,255,255,0.2);
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: var(--space-3);
}

.result-title {
    font-size: 18px;
    font-weight: 600;
}

.result-body {
    padding: var(--space-4);
}

/* 结果卡片 */
.result-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.result-card {
    background: var(--gray-50);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    text-align: center;
}

.result-card-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: var(--space-1);
}

.result-card-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.result-card.highlight {
    grid-column: span 2;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.result-card.highlight .result-card-label {
    color: rgba(255,255,255,0.8);
}

.result-card.highlight .result-card-value {
    color: white;
    font-size: 28px;
}

/* 结果表格 */
.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.result-table th,
.result-table td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.result-table th {
    background: var(--gray-50);
    font-weight: 500;
    color: var(--gray-500);
    font-size: 12px;
}

.result-table .text-right {
    text-align: right;
}

.result-table .row-total {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.result-table .row-total td {
    border: none;
}

/* ===== 测试页面 ===== */
.test-progress {
    padding: var(--space-4);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 10;
}

.test-progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-2);
    font-size: 13px;
    color: var(--gray-500);
}

.test-progress-bar {
    height: 4px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.test-progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

/* 题目卡片 */
.question-card {
    padding: var(--space-5);
    text-align: center;
}

.question-text {
    font-size: 16px;
    color: var(--gray-700);
    margin-bottom: var(--space-6);
    line-height: 1.6;
}

/* 选项 */
.options-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.option-btn {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    width: 100%;
    padding: var(--space-4);
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-user-select: none;
    user-select: none;
}

.option-btn:active {
    transform: scale(0.98);
}

.option-btn.selected {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.option-letter {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: white;
    border: 2px solid var(--gray-300);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-500);
    flex-shrink: 0;
}

.option-btn.selected .option-letter {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.option-text {
    flex: 1;
    font-size: 15px;
    color: var(--gray-700);
    line-height: 1.5;
}

/* 导航按钮 */
.test-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-4);
    padding-bottom: calc(var(--space-4) + var(--safe-bottom));
    background: white;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: var(--space-3);
}

.test-nav .btn {
    flex: 1;
}

.test-nav .btn:disabled {
    opacity: 0.5;
}

/* ===== 欢迎页 ===== */
.welcome-card {
    background: white;
    margin: var(--space-4);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.welcome-header {
    padding: var(--space-8) var(--space-5);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    text-align: center;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: var(--space-4);
}

.welcome-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: var(--space-2);
}

.welcome-subtitle {
    font-size: 14px;
    opacity: 0.85;
}

.welcome-body {
    padding: var(--space-5);
}

.welcome-types {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.type-item {
    padding: var(--space-4);
    background: var(--gray-50);
    border-radius: var(--radius-md);
    text-align: center;
    border-top: 3px solid var(--type-color);
}

.type-item i {
    font-size: 24px;
    color: var(--type-color);
    margin-bottom: var(--space-2);
}

.type-item h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: var(--space-1);
}

.type-item p {
    font-size: 12px;
    color: var(--gray-500);
}

.type-d { --type-color: #EF4444; }
.type-i { --type-color: #F59E0B; }
.type-s { --type-color: #10B981; }
.type-c { --type-color: #3B82F6; }

.welcome-tips {
    background: var(--gray-50);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
}

.welcome-tips h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.welcome-tips ul {
    list-style: none;
}

.welcome-tips li {
    font-size: 13px;
    color: var(--gray-600);
    padding: var(--space-2) 0;
    padding-left: 20px;
    position: relative;
}

.welcome-tips li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: bold;
}

/* ===== 分数卡片 ===== */
.score-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.score-item {
    background: white;
    padding: var(--space-4);
    border-radius: var(--radius-md);
    text-align: center;
    border: 2px solid var(--gray-200);
    position: relative;
}

.score-item.dominant {
    border-color: var(--score-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.score-item-icon {
    width: 40px;
    height: 40px;
    background: var(--score-color);
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    margin-bottom: var(--space-2);
}

.score-item-type {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}

.score-item-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--score-color);
}

.score-item-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--score-color);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

/* ===== 加载状态 ===== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
    color: var(--gray-500);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: var(--space-4);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: var(--space-8);
    color: var(--gray-500);
}

.empty-state i {
    font-size: 48px;
    color: var(--gray-300);
    margin-bottom: var(--space-4);
}

/* ===== 通用工具类 ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-muted { color: var(--gray-500); }
.font-bold { font-weight: 600; }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.hidden { display: none !important; }

/* ===== 响应式 - 平板及以上 ===== */
@media (min-width: 768px) {
    .tools-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-4);
    }
    
    .tool-item {
        margin-bottom: 0;
    }
    
    .calc-modal-container {
        max-width: 480px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: var(--radius-xl);
        bottom: var(--space-4);
        max-height: 90vh;
    }
    
    .result-cards {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .result-card.highlight {
        grid-column: span 4;
    }
}

/* ===== 打印样式 ===== */
@media print {
    .page-header,
    .fixed-bottom,
    .test-nav {
        display: none;
    }
    
    body {
        background: white;
    }
}
