/**
 * ============================================
 * Kaoyan H5 — 全局样式
 * 版本: v2.0.0
 * 技术: Tailwind CSS + Custom Styles
 * ============================================
 */

/* ==================== Tailwind 基础配置 ==================== */

/* ==================== CSS 变量 ==================== */
:root {
  /* 主题色 */
  --color-primary: #667eea;
  --color-primary-dark: #5a67d8;
  --color-primary-light: #a78bfa;

  /* 渐变色 */
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-dark: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);

  /* 功能色 */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-info: #3b82f6;

  /* 标签色 */
  --color-985: #dc2626;
  --color-211: #2563eb;
  --color-double: #7c3aed;

  /* 文字色 */
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --text-light: #f3f4f6;

  /* 背景色 */
  --bg-white: #ffffff;
  --bg-gray: #f9fafb;
  --bg-gray-100: #f3f4f6;
  --bg-gray-200: #e5e7eb;
  --bg-dark: #111827;

  /* 圆角 */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* 动画 */
  --transition-fast: 150ms;
  --transition-normal: 300ms;
  --transition-slow: 500ms;

  /* 安全区域 */
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
}

/* ==================== 基础重置 ==================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-gray);
  line-height: 1.5;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul, ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-gray-200);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==================== 工具类 ==================== */

/* Flex 布局 */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

/* Grid */
.grid { display: grid; }

/* Gap */
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

/* 间距 */
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-12 { padding-top: 3rem; padding-bottom: 3rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.ml-2 { margin-left: 0.5rem; }
.mr-2 { margin-right: 0.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* 尺寸 */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* 文字 */
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.leading-tight { line-height: 1.25; }
.leading-relaxed { line-height: 1.625; }

/* 颜色 */
.text-white { color: #ffffff; }
.text-gray-500 { color: var(--text-secondary); }
.text-gray-400 { color: var(--text-muted); }
.text-red-500 { color: var(--color-error); }
.text-green-500 { color: var(--color-success); }
.text-blue-500 { color: var(--color-info); }

/* 背景 */
.bg-white { background-color: var(--bg-white); }
.bg-gray-50 { background-color: var(--bg-gray); }
.bg-gray-100 { background-color: var(--bg-gray-100); }
.bg-primary { background-color: var(--color-primary); }

/* 圆角 */
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* 阴影 */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }

/* 定位 */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-0 { top: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }
.right-0 { right: 0; }
.z-10 { z-index: 10; }
.z-50 { z-index: 50; }

/* 其他 */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.whitespace-nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }
.pointer-events-none { pointer-events: none; }
.select-none { user-select: none; }
.transition { transition: all var(--transition-normal); }
.transition-colors { transition: color var(--transition-fast), background-color var(--transition-fast); }
.transition-transform { transition: transform var(--transition-normal); }
.transform { transform: translateY(0); }
.rotate-180 { transform: rotate(180deg); }

/* ==================== 组件样式 ==================== */

/* 页面容器 */
.page-container {
  max-width: 100%;
  min-height: 100vh;
  padding-bottom: calc(80px + var(--safe-area-inset-bottom));
  background-color: var(--bg-gray);
}

.container {
  width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 768px) {
  .container {
    max-width: 640px;
  }
}

/* 卡片 */
.card {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.card-hover {
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.card-hover:active {
  transform: scale(0.98);
}

/* ==================== 头部 ==================== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--bg-gray-200);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 1rem;
}

.header-back {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-primary);
  font-size: 1rem;
  min-width: 60px;
}

.header-back svg {
  width: 24px;
  height: 24px;
}

.header-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ==================== 搜索框 ==================== */
.search-bar {
  padding: 0.75rem 1rem;
  background: var(--bg-white);
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-gray-100);
  border-radius: var(--radius-full);
  padding: 0.625rem 1rem;
}

.search-input-wrap svg {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  color: var(--text-primary);
  outline: none;
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* ==================== 标签页筛选 ==================== */
.filter-section {
  padding: 0.75rem 1rem;
  background: var(--bg-white);
  border-bottom: 1px solid var(--bg-gray-100);
}

.filter-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.filter-tabs::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: var(--bg-gray-100);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.filter-tab.active {
  color: #ffffff;
  background: var(--color-primary);
}

.filter-tab:active {
  transform: scale(0.95);
}

/* ==================== 标签 ==================== */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
}

.tag-985 {
  color: #ffffff;
  background: var(--color-985);
}

.tag-211 {
  color: #ffffff;
  background: var(--color-211);
}

.tag-double {
  color: #ffffff;
  background: var(--color-double);
}

.tag-default {
  color: var(--text-secondary);
  background: var(--bg-gray-100);
}

.tag-success {
  color: var(--color-success);
  background: rgba(16, 185, 129, 0.1);
}

.tag-warning {
  color: var(--color-warning);
  background: rgba(245, 158, 11, 0.1);
}

/* ==================== 院校卡片 ==================== */
.school-card {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.school-card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-md);
}

.school-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-gray-100);
  font-size: 1.5rem;
}

.school-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.school-logo-placeholder {
  font-size: 1.5rem;
}

.school-info {
  flex: 1;
  min-width: 0;
}

.school-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.school-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.375rem;
}

.school-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* 难度星级 */
.difficulty {
  display: flex;
  gap: 2px;
}

.difficulty svg {
  width: 12px;
  height: 12px;
}

.difficulty svg.filled {
  color: var(--color-warning);
}

.difficulty svg.empty {
  color: var(--bg-gray-200);
}

/* ==================== 底部导航 ==================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: calc(60px + var(--safe-area-inset-bottom));
  padding-bottom: var(--safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--bg-gray-200);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: color var(--transition-fast);
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

.nav-item.active {
  color: var(--color-primary);
}

.nav-item:active {
  transform: scale(0.9);
}

/* ==================== 加载状态 ==================== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-gray-200);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 0.75rem;
  font-size: 0.875rem;
}

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg, var(--bg-gray-100) 25%, var(--bg-gray-200) 50%, var(--bg-gray-100) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==================== 空状态 ==================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

/* ==================== Toast 提示 ==================== */
.toast-message {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 0.75rem 1.5rem;
  background: rgba(0, 0, 0, 0.8);
  color: #ffffff;
  font-size: 0.875rem;
  border-radius: var(--radius-full);
  z-index: 9999;
  opacity: 0;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  pointer-events: none;
  white-space: nowrap;
}

.toast-message.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-message.success {
  background: rgba(16, 185, 129, 0.95);
}

.toast-message.error {
  background: rgba(239, 68, 68, 0.95);
}

/* ==================== 按钮 ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
  cursor: pointer;
  min-height: 48px;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  color: #ffffff;
  background: var(--gradient-primary);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:active {
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
  color: var(--text-primary);
  background: var(--bg-gray-100);
}

.btn-outline {
  color: var(--color-primary);
  background: transparent;
  border: 1.5px solid var(--color-primary);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  min-height: 36px;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
  min-height: 56px;
}

/* ==================== 输入框 ==================== */
.input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--bg-white);
  border: 1.5px solid var(--bg-gray-200);
  border-radius: var(--radius-lg);
  outline: none;
  transition: border-color var(--transition-fast);
}

.input:focus {
  border-color: var(--color-primary);
}

.input::placeholder {
  color: var(--text-muted);
}

.input-error {
  border-color: var(--color-error);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.form-error {
  font-size: 0.75rem;
  color: var(--color-error);
  margin-top: 0.375rem;
}

/* ==================== 模态框 ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  margin: 1rem;
  max-width: 400px;
  width: calc(100% - 2rem);
  transform: scale(0.9);
  transition: transform var(--transition-normal);
}

.modal-overlay.show .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

/* ==================== 页面内容区 ==================== */
.page-content {
  padding-bottom: 1rem;
}

/* ==================== 渐变背景 ==================== */
.bg-gradient {
  background: var(--gradient-primary);
}

.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ==================== 分割线 ==================== */
.divider {
  height: 1px;
  background: var(--bg-gray-200);
  margin: 1rem 0;
}

/* ==================== 价格标签 ==================== */
.price {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-error);
}

.price-unit {
  font-size: 0.875rem;
  font-weight: 400;
}

/* ==================== 功能入口卡片 ==================== */
.feature-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
}

.feature-card:active {
  transform: scale(0.96);
  box-shadow: var(--shadow-md);
}

.feature-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  font-size: 1.5rem;
}

.feature-icon.school {
  background: rgba(102, 126, 234, 0.1);
  color: var(--color-primary);
}

.feature-icon.major {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.feature-icon.ai {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.feature-icon.risk {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
}

.feature-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.feature-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* ==================== 付费锁定 ==================== */
.lock-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 0%, rgba(255,255,255,0.8) 50%, rgba(255,255,255,0.95) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 1.5rem;
  border-radius: var(--radius-xl);
}

.lock-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #ffffff;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ==================== 响应式 ==================== */
@media (max-width: 374px) {
  html {
    font-size: 14px;
  }
}

@media (min-width: 768px) {
  .container {
    max-width: 640px;
    margin: 0 auto;
  }

  .page-container {
    background: var(--bg-white);
  }

  .school-card {
    padding: 1.25rem;
  }
}
