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

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --star: #f59e0b;
  --liduo: #16a34a;
  --likong: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}

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

/* ========== Header ========== */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}
.logo span {
  font-weight: 400;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-left: 4px;
}
.nav { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s;
}
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link-api {
  border: 1px solid var(--primary);
  color: var(--primary);
}
.nav-link-api:hover { background: var(--primary); color: #fff; }

/* ========== Main Content ========== */
main { flex: 1; padding: 20px 0; }

.page-header {
  margin-bottom: 20px;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 16px;
}

/* ========== Filter Form ========== */
.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.filter-group input,
.filter-group select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.filter-group input:focus,
.filter-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.data-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ========== Table ========== */
.table-wrapper {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  background: #f9fafb;
  padding: 10px 12px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #f0f5ff; }
.data-table tbody tr:last-child td { border-bottom: none; }

.row-important { background: #fffbeb; }
.row-important:hover { background: #fef3c7; }

.time-col { font-family: 'SF Mono', 'Fira Code', monospace; font-weight: 500; color: var(--primary); }
.title-col { max-width: 300px; }
.num-col { font-family: 'SF Mono', 'Fira Code', monospace; text-align: right; }
.star-col { color: var(--star); font-size: 0.75rem; letter-spacing: -1px; }
.status-col { font-weight: 600; font-size: 0.8rem; }
.country-cell { white-space: nowrap; }
.liduo { color: var(--liduo); }
.likong { color: var(--likong); }

/* ========== Events ========== */
.events-list { display: flex; flex-direction: column; gap: 10px; }
.event-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--primary);
}
.event-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.8rem;
}
.event-time {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 600;
  color: var(--primary);
  background: #eff6ff;
  padding: 2px 8px;
  border-radius: 4px;
}
.event-country {
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-secondary);
}
.event-star { color: var(--star); font-size: 0.75rem; }
.event-content { font-size: 0.9rem; line-height: 1.7; }
.event-people { margin-top: 6px; font-size: 0.8rem; color: var(--text-secondary); }

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.empty-state p { color: var(--text-secondary); font-size: 1rem; }

/* ========== Error Page ========== */
.error-page {
  text-align: center;
  padding: 80px 20px;
}
.error-page h1 { font-size: 2rem; margin-bottom: 12px; color: var(--danger); }
.error-page p { color: var(--text-secondary); margin-bottom: 24px; }

/* ========== Footer ========== */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 0;
  margin-top: auto;
}
.footer p {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ========== View Toggle ========== */
.page-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.page-header-top h1 { margin: 0; }
.view-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 6px;
  padding: 3px;
}
.view-btn {
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s;
}
.view-btn:hover { color: var(--text); text-decoration: none; background: var(--surface); }
.view-btn-active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(26,115,232,0.3);
}
.view-btn-active:hover { color: #fff; background: var(--primary-dark); }

/* ========== Timeline (Month View) ========== */
.timeline {
  margin-top: 16px;
}
.timeline-group {
  position: relative;
  padding-left: 24px;
  margin-bottom: 0;
  border-left: 2px solid var(--border);
}
.timeline-group::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}
.timeline-group-today { border-left-color: var(--primary); }
.timeline-group-today::before { background: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,232,0.2); }

.timeline-date {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0 6px;
}
.timeline-date-day {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.timeline-date-weekday {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.timeline-date-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.timeline-date-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: auto;
}

.timeline-items {
  padding-bottom: 8px;
}
.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 12px;
  margin: 3px 0;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  line-height: 1.5;
}
.timeline-item-time {
  flex-shrink: 0;
  color: var(--primary);
  font-weight: 600;
  min-width: 42px;
  font-size: 0.82rem;
}
.timeline-item-country {
  flex-shrink: 0;
  background: #e0e7ff;
  color: #3730a3;
  padding: 0 6px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.8;
}
.timeline-item-content {
  flex: 1;
  color: var(--text);
}
.timeline-item-provider {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  align-self: center;
}

.event-provider {
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
}

/* ========== WebSocket Toast ========== */
.ws-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  background: #1a1a2e;
  color: #e0e0e0;
  padding: 12px 40px 12px 16px;
  border-radius: 8px;
  border-left: 4px solid var(--accent);
  font-size: 0.85rem;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  animation: wsSlideIn 0.3s ease;
  transition: opacity 0.3s ease;
  max-width: 360px;
}
.ws-toast-info { border-left-color: var(--accent); }
.ws-toast-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: #888;
  font-size: 1.1rem;
  cursor: pointer;
}
@keyframes wsSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .header-inner { flex-direction: column; height: auto; padding: 10px 0; gap: 8px; }
  .nav { flex-wrap: wrap; justify-content: center; }
  .filter-form { flex-direction: column; }
  .filter-group { width: 100%; }
  .filter-group input,
  .filter-group select { width: 100%; }
  .title-col { max-width: 160px; }
  .page-header-top { flex-direction: column; gap: 8px; align-items: flex-start; }
  .timeline-item { flex-wrap: wrap; }
  .timeline-item-time { min-width: auto; }
}
