/* CSS Variables */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

/* Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* Header */
.header {
  background: var(--primary);
  color: white;
  padding: 1.5rem 1rem;
  text-align: center;
}

.header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.subtitle {
  font-size: 0.875rem;
  opacity: 0.9;
}

/* Container */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* Tab Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

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

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

textarea, input[type="text"] {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s;
}

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

.search-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Select Input */
.select-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--card-bg);
  cursor: pointer;
  transition: border-color 0.2s;
}

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

/* Search Results */
.results-list {
  list-style: none;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.result-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.result-item-name {
  font-weight: 500;
}

.result-item-code {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
  background: #f1f5f9;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.result-item-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.level-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: #e2e8f0;
  color: var(--text-muted);
}

.level-badge.province {
  background: #dbeafe;
  color: #1e40af;
}

.level-badge.ward {
  background: #f3e8ff;
  color: #7c3aed;
}

.score-bar {
  width: 40px;
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  background: var(--success);
}

/* States */
.hidden {
  display: none !important;
}

.loading-indicator {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.error-card {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 1rem;
  border-radius: var(--radius);
  margin-top: 1rem;
}

/* Footer */
.footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

.footer code {
  background: #e2e8f0;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.footer a {
  color: var(--primary);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 480px) {
  .header h1 {
    font-size: 1.25rem;
  }

  .container {
    padding: 1rem;
  }

  .result-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}
