:root {
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-text: #1a1a1a;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-accent: #00e5a4;
  --color-accent-dark: #00b87a;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
}

/* Header */
.header {
  text-align: center;
  padding: 48px 24px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.header h1 {
  margin: 0 0 8px;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.intro {
  margin: 8px 0 0;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.5;
  text-align: center;
  text-wrap: balance;
}

.intro a {
  color: var(--color-accent-dark);
  text-decoration: none;
  font-weight: 500;
}

.intro a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.intro a.intro-github-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: text-bottom;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  background: var(--color-border);
  border-radius: 50%;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-decoration: none;
  transition:
    background 0.15s,
    color 0.15s;
}

.intro a.intro-github-link:hover {
  background: var(--color-accent);
  color: white;
  text-decoration: none;
}

/* Search Section */
.search-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
}

.search-section h2 {
  margin: 0 0 20px;
  font-size: 1.25rem;
  font-weight: 600;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.form-field-inline {
  min-width: 160px;
}

.query-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.query-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 229, 164, 0.15);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.multi-select {
  min-width: 180px;
}

.date-input {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
}

.date-input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.submit-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: linear-gradient(
    135deg,
    var(--color-accent),
    var(--color-accent-dark)
  );
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 0.15s,
    box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(0, 229, 164, 0.25);
  align-self: flex-end;
  height: 38px;
}

.submit-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 229, 164, 0.35);
}

.submit-button.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.submit-button i {
  font-size: 1.1rem;
}

/* Results Section */
.results-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
}

.results-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.results-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.results-count {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.table-container {
  overflow-x: auto;
}

.posts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.posts-table th,
.posts-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.posts-table th {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sortable-header {
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: color 0.15s;
}

.sortable-header:hover {
  color: var(--color-text);
}

.sortable-header i {
  margin-left: 4px;
  opacity: 0.5;
}

.posts-table tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

.date-cell {
  white-space: nowrap;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.title-cell a {
  color: var(--color-text);
  text-decoration: none;
}

.title-cell a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.type-cell {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  text-transform: capitalize;
}

.no-results {
  color: var(--color-text-muted);
  font-style: italic;
  padding: 24px;
  text-align: center;
}

/* Error Alert */
.error-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: #dc2626;
  margin-bottom: 24px;
}

.error-alert i {
  font-size: 1.25rem;
}

.error-alert span {
  flex: 1;
}

.error-dismiss {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 4px;
  opacity: 0.7;
}

.error-dismiss:hover {
  opacity: 1;
}

/* JSON Data Link */
.json-data-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: color 0.15s;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
}

.json-data-link:hover {
  color: var(--color-accent-dark);
}

.json-data-link i {
  font-size: 1.1rem;
}

/* Category Label */
.category-label {
  display: inline-block;
  padding: 2px 8px;
  border: 2px solid rgb(var(--label-color));
  border-radius: 12px;
  background: rgba(var(--label-color), 0.1);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: lowercase;
}

/* Footer */
.footer {
  text-align: center;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-top: 24px;
}

.nearform-banner {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.nearform-banner:hover {
  box-shadow: var(--shadow-md);
}

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

  .header {
    padding: 32px 16px;
  }

  .header h1 {
    font-size: 1.75rem;
  }

  .filters-row {
    flex-direction: column;
    align-items: stretch;
  }

  .form-field-inline {
    min-width: 100%;
  }

  .multi-select {
    min-width: 100%;
  }
}
