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

:root {
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --bg-color: #f8fafc;
  --text-color: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --error-color: #ef4444;
  --success-color: #22c55e;
  --card-bg: #ffffff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --transition: all 0.2s ease;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============ Header ============ */
.site-header {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  padding: 2rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.site-logo {
  max-height: 60px;
  max-width: 200px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}

.header-titles {
  text-align: left;
}

.header-content h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.header-content .title-en {
  font-size: 1rem;
  opacity: 0.85;
}

/* ============ Main Content ============ */
.main-content {
  flex: 1;
  padding: 2rem 1rem;
}

.container {
  max-width: 800px;
  margin: 0 auto;
}

/* ============ Intro Section ============ */
.intro-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  margin-bottom: 2rem;
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.intro-title {
  font-size: 1.25rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.intro-text {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.qr-section {
  flex-shrink: 0;
  text-align: center;
}

.qr-code-container {
  background: white;
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  display: inline-block;
}

.qr-code-img {
  width: 150px;
  height: 150px;
  display: block;
}

.qr-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-weight: 600;
}

.qr-url {
  font-size: 0.7rem;
  color: var(--text-muted);
  word-break: break-all;
  max-width: 180px;
}

/* ============ Form ============ */
.registration-form {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-section {
  margin-bottom: 2rem;
}

.form-section:last-of-type {
  margin-bottom: 0;
}

.section-title {
  font-size: 1.15rem;
  color: var(--primary-color);
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-light);
  margin-bottom: 0.25rem;
}

.section-title-en {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.section-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
  color: var(--text-color);
}

.form-group label .required {
  color: var(--error-color);
  margin-left: 2px;
}

.label-en {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.95rem;
  transition: var(--transition);
  background: white;
  color: var(--text-color);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control.error {
  border-color: var(--error-color);
}

select.form-control {
  cursor: pointer;
  appearance: auto;
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

/* Checkbox group */
.checkbox-group {
  display: flex;
  align-items: center;
  padding: 0.5rem 0;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-right: 0.5rem;
  cursor: pointer;
  accent-color: var(--primary-color);
}

.checkbox-group label {
  font-weight: 400;
  cursor: pointer;
  margin-bottom: 0;
}

/* ============ Form Actions ============ */
.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.btn-submit, .btn-reset {
  padding: 0.7rem 2rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
}

.btn-submit {
  background: var(--primary-color);
  color: white;
}

.btn-submit:hover {
  background: var(--primary-dark);
}

.btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-reset {
  background: #e2e8f0;
  color: var(--text-color);
}

.btn-reset:hover {
  background: #cbd5e1;
}

/* ============ Success Message ============ */
.success-message {
  text-align: center;
  background: var(--card-bg);
  padding: 3rem 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.success-icon {
  width: 64px;
  height: 64px;
  background: var(--success-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1rem;
}

.success-message h2 {
  color: var(--success-color);
  margin-bottom: 0.5rem;
}

.success-message p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* ============ Footer ============ */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  background: var(--card-bg);
}

/* ============ Responsive ============ */
@media (max-width: 640px) {
  .intro-section {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .qr-section {
    margin-top: 1rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .btn-submit, .btn-reset {
    width: 100%;
  }

  .header-content h1 {
    font-size: 1.4rem;
  }

  .registration-form {
    padding: 1.25rem;
  }
}

/* ============ Admin Styles ============ */
.admin-body {
  background: #f1f5f9;
}

.admin-header {
  background: white;
  border-bottom: 1px solid var(--border-color);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.admin-nav {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 60px;
}

.admin-nav .logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-color);
}

.admin-nav .nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-nav .nav-link {
  padding: 0.5rem 1rem;
  color: var(--text-color);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
}

.admin-nav .nav-link:hover {
  background: var(--primary-light);
  color: var(--primary-color);
}

.admin-nav .nav-link.active {
  background: var(--primary-color);
  color: white;
}

.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary-color);
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-color);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Admin panels */
.admin-panel {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.admin-panel-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-panel-header h3 {
  font-size: 1.05rem;
  color: var(--text-color);
}

.admin-panel-body {
  padding: 1.5rem;
}

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 0.75rem;
  background: #f8fafc;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.data-table tr:hover {
  background: #f8fafc;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #cbd5e1;
  transition: var(--transition);
  border-radius: 24px;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  transition: var(--transition);
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Login page */
.login-container {
  max-width: 400px;
  margin: 3rem auto;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
}

.login-container h1 {
  text-align: center;
  color: var(--primary-color);
  margin-bottom: 1.5rem;
}

.login-form-group {
  margin-bottom: 1.25rem;
}

.login-form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}

.captcha-container {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.captcha-image {
  flex-shrink: 0;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: #f0f4f8;
}

.captcha-image svg {
  display: block;
}

.captcha-refresh {
  padding: 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition);
}

.captcha-refresh:hover {
  background: #f1f5f9;
}

.btn-full {
  width: 100%;
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  z-index: 9999;
  animation: slideIn 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.toast.success { background: var(--success-color); }
.toast.error { background: var(--error-color); }
.toast.info { background: var(--primary-color); }

@keyframes slideIn {
  from { transform: translateX(120%); }
  to { transform: translateX(0); }
}

/* Modal */
.modal-overlay {
  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;
  z-index: 1000;
}

.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.1rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.pagination button {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border-color);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
}

.pagination button:hover:not(:disabled) {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.pagination button.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: var(--primary-light); color: var(--primary-dark); }

/* View toggle (for admin views) */
.view { display: none; }
.view.active { display: block; }

/* Form builder */
.form-builder-section {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: #f8fafc;
}

.form-builder-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 4px;
  background: white;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border-color);
  cursor: grab;
  transition: border 0.2s, box-shadow 0.2s;
}

.form-builder-field:active {
  cursor: grabbing;
}

.form-builder-field:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15);
}

.form-builder-field .drag-handle {
  cursor: grab;
  font-size: 1.1rem;
  color: #94a3b8;
  padding: 0 0.25rem;
  user-select: none;
}

.form-builder-field .drag-handle:hover {
  color: var(--primary-color);
}

.fields-container {
  min-height: 2rem;
}

/* Chart */
.chart-container {
  background: white;
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.chart-container h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
  color: var(--text-color);
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  height: 150px;
  padding-top: 1rem;
}

.chart-bar {
  flex: 1;
  background: var(--primary-color);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  position: relative;
  transition: var(--transition);
  cursor: pointer;
}

.chart-bar:hover {
  background: var(--primary-dark);
}

.chart-bar .bar-value {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-color);
}

.chart-bar .bar-label {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}
