/* ========================================
   政治背诵助手 - 网站版公共样式
   基于小程序 wxss 转换，适配移动端
   ======================================== */

/* CSS 变量 */
:root {
  --primary-color: #4F46E5;
  --primary-light: #EEF2FF;
  --success-color: #10B981;
  --success-light: #D1FAE5;
  --warning-color: #F59E0B;
  --warning-light: #FEF3C7;
  --danger-color: #EF4444;
  --danger-light: #FEE2E2;
  --info-color: #3B82F6;
  --info-light: #DBEAFE;
  --purple-color: #8B5CF6;
  --purple-light: #F5F3FF;
  
  --text-primary: #1F2937;
  --text-secondary: #4B5563;
  --text-tertiary: #6B7280;
  --text-muted: #9CA3AF;
  
  --bg-primary: #FFFFFF;
  --bg-secondary: #F9FAFB;
  --bg-tertiary: #F3F4F6;
  --border-color: #E5E7EB;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* 重置样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  min-height: 100vh;
}

/* 移动端基础设置 */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
}

/* 容器 */
.container {
  max-width: 100%;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

@media (min-width: 768px) {
  .container {
    max-width: 750px;
    padding: 24px;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 960px;
  }
}

/* 页面标题 */
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

/* 卡片样式 */
.card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .card {
    padding: 24px;
    margin-bottom: 24px;
  }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* 统计卡片 */
.stats-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.stats-item {
  text-align: center;
}

.stats-number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 4px;
}

.stats-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.stats-divider {
  width: 1px;
  height: 40px;
  background: var(--border-color);
}

/* 文本颜色 */
.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-danger { color: var(--danger-color); }
.text-info { color: var(--info-color); }
.text-purple { color: var(--purple-color); }
.text-muted { color: var(--text-muted); }

/* 按钮样式 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-warning {
  background: var(--warning-color);
  color: white;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-outline {
  background: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.btn-ghost {
  background: transparent;
  color: var(--text-tertiary);
}

.btn-block {
  width: 100%;
}

/* 输入框 */
.input-group {
  margin-bottom: 16px;
}

.input-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 16px;
  height: 48px;
}

.input-wrapper:focus-within {
  border-color: var(--primary-color);
}

.input-wrapper input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  color: var(--text-primary);
  outline: none;
  height: 100%;
}

.input-wrapper input::placeholder {
  color: var(--text-muted);
}

/* 列表样式 */
.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.list-item:active {
  background: var(--bg-tertiary);
}

/* 标签页 */
.tabs {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 24px;
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  font-size: 0.875rem;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s;
}

.tab-item.active {
  background: white;
  color: var(--primary-color);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* 徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary-color);
}

.badge-success {
  background: var(--success-light);
  color: var(--success-color);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning-color);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger-color);
}

/* 进度条 */
.progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary-color);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-fill.success {
  background: var(--success-color);
}

.progress-fill.warning {
  background: var(--warning-color);
}

.progress-fill.danger {
  background: var(--danger-color);
}

/* 网格布局 */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 480px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 功能入口网格 */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.feature-item {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.2s;
}

.feature-item:active {
  transform: scale(0.98);
}

.feature-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 1.75rem;
}

.feature-icon.primary {
  background: var(--primary-light);
}

.feature-icon.success {
  background: var(--success-light);
}

.feature-icon.warning {
  background: var(--warning-light);
}

.feature-icon.danger {
  background: var(--danger-light);
}

.feature-icon.info {
  background: var(--info-light);
}

.feature-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.feature-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 底部导航 */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 100;
}

.tab-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 12px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75rem;
  transition: color 0.2s;
}

.tab-bar-item.active {
  color: var(--primary-color);
}

.tab-bar-icon {
  font-size: 1.25rem;
  margin-bottom: 2px;
}

/* 为底部导航留出空间 */
.with-tab-bar {
  padding-bottom: 80px;
}

/* 弹窗 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  z-index: 1000;
  padding: 20px;
}

.modal.show {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: white;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.3s;
}

.modal.show .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 20px;
  max-height: 50vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 20px;
  color: var(--text-muted);
  text-align: center;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.empty-text {
  font-size: 1rem;
}

/* 加载动画 */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 提示条 */
.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.alert-warning {
  background: var(--warning-light);
  color: #92400E;
}

.alert-danger {
  background: var(--danger-light);
  color: #991B1B;
}

.alert-success {
  background: var(--success-light);
  color: #065F46;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

/* 工具类 */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.ml-2 { margin-left: 8px; }
.mr-2 { margin-right: 8px; }

.p-2 { padding: 8px; }
.p-4 { padding: 16px; }

.hidden { display: none !important; }
