/* ============================
   扶老助老 · 全新设计系统
   ============================ */

/* ---- CSS Variables ---- */
:root {
  /* Brand */
  --primary: #2D8B7B;
  --primary-dark: #1F6B5E;
  --primary-light: #E8F5F1;
  --primary-glow: rgba(45, 139, 123, 0.15);

  /* Role colors */
  --elder: #E8915A;
  --elder-light: #FFF0E8;
  --elder-dark: #C9753F;
  --volunteer: #4CAF7C;
  --volunteer-light: #E8F9F0;
  --volunteer-dark: #3A8F64;
  --admin: #5B9BD5;
  --admin-light: #E8F1FA;
  --admin-dark: #3F7DB5;

  /* Neutral */
  --bg: #FAF8F5;
  --bg-card: #FFFFFF;
  --text-primary: #2D3436;
  --text-secondary: #636E72;
  --text-muted: #B2BEC3;
  --border: #E8E6E3;
  --shadow: 0 2px 12px rgba(45, 52, 54, 0.06);
  --shadow-hover: 0 8px 24px rgba(45, 52, 54, 0.10);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-full: 9999px;

  /* Typography */
  --font: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;

  /* Transitions */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg: #1A1D21;
  --bg-card: #2A2D32;
  --text-primary: #E8E8E8;
  --text-secondary: #A0A4A8;
  --text-muted: #6B6F73;
  --border: #3A3D42;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.3);
  --primary-light: #1F3B35;
  --elder-light: #3D2B1A;
  --volunteer-light: #1A3B28;
  --admin-light: #1A2B3D;
}

/* ---- Reset ---- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ---- Layout ---- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.container-narrow {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px;
}

.page-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  position: relative;
}

/* ---- Back Button ---- */
.back-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--primary);
  border: 2px solid var(--border);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.back-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: scale(1.05);
}

/* ---- Page Header ---- */
.page-header {
  position: relative;
  text-align: center;
  padding: 40px 20px 30px;
}
.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.page-header p {
  color: var(--text-secondary);
  font-size: 16px;
  margin-top: 8px;
}

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-hover);
}
.card-hover:hover {
  transform: translateY(-4px);
}

.role-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  flex: 1;
}
.role-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
}
.role-card .icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  transition: var(--transition);
}
.role-card:hover .icon { transform: scale(1.1); }
.role-card h3 { font-size: 22px; font-weight: 700; }
.role-card p { font-size: 15px; color: var(--text-secondary); line-height: 1.7; }

.role-card.elder { border-color: var(--elder); }
.role-card.elder:hover { background: var(--elder-light); border-color: var(--elder-dark); }
.role-card.elder .icon { background: var(--elder-light); color: var(--elder); }

.role-card.volunteer { border-color: var(--volunteer); }
.role-card.volunteer:hover { background: var(--volunteer-light); border-color: var(--volunteer-dark); }
.role-card.volunteer .icon { background: var(--volunteer-light); color: var(--volunteer); }

.role-card.admin { border-color: var(--admin); }
.role-card.admin:hover { background: var(--admin-light); border-color: var(--admin-dark); }
.role-card.admin .icon { background: var(--admin-light); color: var(--admin); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  min-height: 48px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-elder { background: var(--elder); color: #fff; }
.btn-elder:hover { background: var(--elder-dark); }

.btn-volunteer { background: var(--volunteer); color: #fff; }
.btn-volunteer:hover { background: var(--volunteer-dark); }

.btn-admin { background: var(--admin); color: #fff; }
.btn-admin:hover { background: var(--admin-dark); }

.btn-outline {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text-primary);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-block { width: 100%; }
.btn-lg { padding: 18px 32px; font-size: 18px; }
.btn-sm { padding: 10px 20px; font-size: 14px; min-height: 40px; }

/* ---- Forms ---- */
.form-group {
  margin-bottom: 24px;
}
.form-group label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.form-group label .required {
  color: #E74C3C;
  margin-left: 2px;
}

.input-wrap {
  display: flex;
  gap: 12px;
  align-items: center;
}

input, select, textarea {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: var(--font);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  min-height: 48px;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}
input::placeholder { color: var(--text-muted); }

.input-with-voice {
  display: flex;
  gap: 10px;
}
.input-with-voice input { flex: 1; }

.voice-btn-sm {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-card);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.voice-btn-sm:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.voice-btn-sm.recording {
  border-color: #E74C3C;
  background: #FDE8E8;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(231, 76, 60, 0); }
}

/* ---- Captcha Row ---- */
.captcha-row {
  display: flex;
  gap: 10px;
}
.captcha-row input { flex: 1; }
.captcha-btn {
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  background: var(--admin);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  min-height: 48px;
}
.captcha-btn:hover { opacity: 0.9; }
.captcha-btn:disabled { background: var(--text-muted); cursor: not-allowed; }

/* ---- Voice Button (large, for home page) ---- */
.voice-btn-lg {
  background: var(--bg-card);
  border: 2px solid var(--primary);
  color: var(--primary);
  padding: 14px 32px;
  border-radius: var(--radius-full);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
  box-shadow: var(--shadow);
}
.voice-btn-lg:hover {
  background: var(--primary);
  color: #fff;
}
.voice-btn-lg.recording {
  border-color: #E74C3C;
  color: #E74C3C;
  animation: pulse 1s infinite;
}
.voice-btn-lg.recognizing {
  border-color: var(--volunteer);
  color: var(--volunteer);
}

/* ---- Voice Status ---- */
.voice-status {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  min-height: 24px;
  margin-top: 8px;
}
.voice-status.recording { color: #E74C3C; }
.voice-status.success { color: var(--volunteer); }
.voice-status.error { color: #E74C3C; }

/* ---- Tags / Badges ---- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
}
.tag-elder { background: var(--elder-light); color: var(--elder); }
.tag-volunteer { background: var(--volunteer-light); color: var(--volunteer); }
.tag-admin { background: var(--admin-light); color: var(--admin); }
.tag-warning { background: #FFF3E0; color: #E65100; }
.tag-success { background: #E8F5E9; color: #2E7D32; }
.tag-danger { background: #FDE8E8; color: #C62828; }

/* ---- Toast / Alert ---- */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  font-size: 15px;
  z-index: 9999;
  opacity: 0;
  transition: all 0.4s ease;
  max-width: 90vw;
  text-align: center;
  border-left: 4px solid var(--primary);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error { border-left-color: #E74C3C; }
.toast.success { border-left-color: var(--volunteer); }

/* ---- Theme Toggle ---- */
.theme-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.theme-btn:hover {
  transform: rotate(30deg);
  border-color: var(--primary);
  color: var(--primary);
}

/* ---- Navbar (volunteer dashboard) ---- */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-list {
  display: flex;
  justify-content: center;
  gap: 8px;
  list-style: none;
  max-width: 800px;
  margin: 0 auto;
  padding: 12px 0;
  overflow-x: auto;
}
.nav-item a {
  display: block;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 15px;
  white-space: nowrap;
  transition: var(--transition);
}
.nav-item a:hover, .nav-item a.active {
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}

/* ---- Shimmer loading ---- */
.shimmer {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Animations ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.animate-in {
  animation: fadeInUp 0.6s ease forwards;
}
.animate-in-d1 { animation-delay: 0.1s; }
.animate-in-d2 { animation-delay: 0.2s; }
.animate-in-d3 { animation-delay: 0.3s; }
.animate-in-d4 { animation-delay: 0.4s; }
.animate-in-d5 { animation-delay: 0.5s; }

/* ---- Section Title ---- */
.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}
.section-title .accent {
  color: var(--primary);
}

/* ---- Stat Items ---- */
.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.stat-item:last-child { border-bottom: none; }
.stat-label { color: var(--text-secondary); font-size: 15px; }
.stat-value { font-weight: 700; color: var(--primary); font-size: 18px; }

/* ---- Grid Helpers ---- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .page-header h1 { font-size: 24px; }
  .back-btn, .theme-btn { width: 44px; height: 44px; font-size: 18px; }
  .role-card { padding: 24px 16px; }
  .role-card h3 { font-size: 20px; }
  .nav-list { justify-content: flex-start; gap: 4px; }
  .nav-item a { padding: 8px 14px; font-size: 14px; }
}

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .btn-lg { padding: 16px 24px; font-size: 16px; }
  input, select { padding: 12px 14px; font-size: 15px; }
  .form-group { margin-bottom: 20px; }
}
