/* ===== Base Reset & Variables ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #dcfce7;
  --error: #dc2626;
  --error-light: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --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;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --transition: 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ===== Header ===== */
.site-header {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: white;
  padding: 28px 0 24px;
  text-align: center;
}

.site-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.3;
}

.site-header .subtitle {
  font-size: 0.95rem;
  opacity: 0.92;
}

/* ===== Privacy Banner ===== */
.privacy-banner {
  background: var(--success-light);
  border-bottom: 2px solid var(--success);
  padding: 10px 0;
  text-align: center;
}

.privacy-banner-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #155e33;
  font-weight: 500;
}

.privacy-banner svg {
  flex-shrink: 0;
}

/* ===== Library Error ===== */
.lib-error {
  display: none;
  background: var(--error-light);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 20px auto;
  max-width: 960px;
  text-align: center;
}

.lib-error h3 {
  color: var(--error);
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.lib-error-detail {
  color: var(--gray-700);
  font-size: 0.9rem;
}

/* ===== Main Content ===== */
.main-content {
  padding: 32px 0 48px;
}

/* ===== Section ===== */
.section {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px 28px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

h3.section-title {
  font-size: 1.15rem;
}

.section-title .icon {
  width: 28px;
  height: 28px;
  background: var(--primary-light);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

/* ===== Upload Area ===== */
.upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--gray-50);
}

.upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-area.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.01);
}

.upload-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  color: var(--primary);
}

.upload-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.upload-hint {
  font-size: 0.85rem;
  color: var(--gray-500);
}

.upload-formats {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.format-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-600);
}

.format-badge.active {
  background: var(--primary-light);
  color: var(--primary);
}

/* ===== File Info ===== */
.file-info-bar {
  background: var(--primary-light);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 0.9rem;
  color: var(--primary-dark);
  margin-bottom: 16px;
  display: none;
}

.file-info-bar.show {
  display: block;
}

/* ===== Mapping Section ===== */
.mapping-container {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 4px;
}

.mapping-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--gray-100);
}

.mapping-row:last-child {
  border-bottom: none;
}

.mapping-label {
  flex: 1;
  font-size: 0.9rem;
  color: var(--gray-700);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mapping-select {
  flex-shrink: 0;
  min-width: 180px;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.88rem;
  background: white;
  cursor: pointer;
  transition: border-color var(--transition);
}

.mapping-select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===== Preview Table ===== */
.preview-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  white-space: nowrap;
}

.preview-table thead {
  background: var(--gray-100);
}

.preview-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  white-space: nowrap;
  border-bottom: 2px solid var(--gray-200);
}

.preview-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-table tbody tr:hover {
  background: var(--gray-50);
}

.preview-hint {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-top: 8px;
  text-align: center;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  font-family: inherit;
}

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

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

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-200);
}

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

.btn-success:hover {
  background: #15803d;
  box-shadow: var(--shadow);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-600);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* ===== Form Controls ===== */
.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-700);
  min-width: 100px;
}

.form-select,
.form-input {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
  transition: border-color var(--transition);
}

.form-select:focus,
.form-input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.form-checkbox-label {
  font-size: 0.9rem;
  color: var(--gray-700);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== Export Config ===== */
.export-config {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.export-config-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.export-config-row:last-child {
  margin-bottom: 0;
}

.split-size-row {
  display: none;
  align-items: center;
  gap: 8px;
  margin-left: 28px;
}

.split-size-row.show {
  display: flex;
}

.split-size-input {
  width: 80px;
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.88rem;
}

/* ===== Message Box ===== */
.message-box {
  display: none;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 16px;
  text-align: center;
}

.message-success {
  background: var(--success-light);
  color: #155e33;
  border: 1px solid var(--success);
}

.message-error {
  background: var(--error-light);
  color: #991b1b;
  border: 1px solid var(--error);
}

.message-info {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid var(--primary);
}

/* ===== FAQ ===== */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}

.faq-item summary {
  padding: 14px 20px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--gray-700);
  cursor: pointer;
  list-style: none;
  position: relative;
  padding-right: 44px;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: '+';
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  color: var(--gray-400);
  transition: transform var(--transition);
}

.faq-item[open] summary::after {
  content: '\2212';
}

.faq-item[open] summary {
  border-bottom: 1px solid var(--gray-200);
}

.faq-answer {
  padding: 14px 20px;
  font-size: 0.9rem;
  color: var(--gray-600);
  line-height: 1.7;
}

/* ===== Static Text Content ===== */
.static-content {
  font-size: 0.92rem;
  color: var(--gray-600);
  line-height: 1.8;
}

.static-content p {
  margin-bottom: 12px;
}

.static-content ul {
  margin-bottom: 12px;
  margin-left: 20px;
}

.static-content li {
  margin-bottom: 4px;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--gray-800);
  color: var(--gray-300);
  padding: 24px 0;
  text-align: center;
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--gray-300);
  text-decoration: none;
  transition: color var(--transition);
}

.site-footer a:hover {
  color: white;
}

.footer-links {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }

  .site-header {
    padding: 20px 0 16px;
  }

  .site-header h1 {
    font-size: 1.25rem;
  }

  .site-header .subtitle {
    font-size: 0.82rem;
  }

  .section {
    padding: 18px 16px;
  }

  .section-title {
    font-size: 1.1rem;
  }

  .upload-area {
    padding: 32px 16px;
  }

  .upload-icon {
    width: 44px;
    height: 44px;
  }

  .upload-text {
    font-size: 0.95rem;
  }

  .mapping-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 12px 8px;
  }

  .mapping-label {
    white-space: normal;
  }

  .mapping-select {
    width: 100%;
    min-width: unset;
  }

  .preview-table {
    font-size: 0.78rem;
  }

  .preview-table th,
  .preview-table td {
    padding: 6px 8px;
    max-width: 120px;
  }

  .btn {
    padding: 10px 16px;
    font-size: 0.88rem;
    width: 100%;
    justify-content: center;
  }

  .btn-group {
    flex-direction: column;
  }

  .privacy-banner-inner {
    font-size: 0.82rem;
    flex-wrap: wrap;
    gap: 4px;
  }

  .faq-item summary {
    font-size: 0.88rem;
    padding: 12px 16px;
    padding-right: 36px;
  }

  .faq-item summary::after {
    right: 16px;
  }

  .faq-answer {
    padding: 12px 16px;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .site-header h1 {
    font-size: 1.05rem;
  }

  .upload-formats {
    gap: 4px;
  }

  .format-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
  }
}

/* ===== Print ===== */
@media print {
  .upload-area,
  .btn,
  .mapping-section,
  .preview-section,
  .export-section,
  .vcf-export-section {
    display: none;
  }
}
