:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #eef2ff;
  --accent: #f59e0b;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(
      circle at 20% 20%,
      rgba(99, 102, 241, 0.08) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 10%,
      rgba(245, 158, 11, 0.06) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 50% 90%,
      rgba(99, 102, 241, 0.05) 0%,
      transparent 50%
    );
  background-attachment: fixed;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

/* Header */
.app-header {
  text-align: center;
  margin-bottom: 2.5rem;
  animation: fadeInDown 0.6s ease-out;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.logo svg {
  width: 2rem;
  height: 2rem;
  color: var(--primary);
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 400;
}

/* Search Container */
.search-container {
  flex: 1;
  animation: fadeInUp 0.6s ease-out 0.1s both;
}

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

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1.25rem;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s;
  z-index: 1;
}

.search {
  width: 100%;
  padding: 1.1rem 3.5rem 1.1rem 3.25rem;
  font-size: 1.05rem;
  font-family: inherit;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  outline: none;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.search::placeholder {
  color: var(--text-muted);
}

.search:hover {
  border-color: #cbd5e1;
}

.search:focus {
  border-color: var(--primary);
  box-shadow:
    0 0 0 4px rgba(99, 102, 241, 0.15),
    var(--shadow-md);
}

.search:focus + .search-icon,
.search-wrapper:focus-within .search-icon {
  color: var(--primary);
}

.clear-btn {
  position: absolute;
  right: 0.75rem;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.clear-btn:hover {
  background: #f1f5f9;
  color: var(--text);
}

.clear-btn svg {
  width: 1rem;
  height: 1rem;
}

/* Status Bar */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 1.5rem;
  margin-bottom: 0.75rem;
  padding: 0 0.25rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.result-count {
  font-weight: 500;
}

.loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
}

.loading-indicator[hidden] {
  display: none;
}

.spinner {
  width: 0.875rem;
  height: 0.875rem;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.error-message {
  color: #dc2626;
  font-weight: 500;
}

/* Suggestions */
.suggestions {
  list-style: none;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  animation: slideIn 0.3s ease-out both;
}

.result-item:last-child {
  border-bottom: none;
}

.result-item:hover,
.result-item:focus {
  background: var(--primary-light);
  outline: none;
}

.result-item:focus {
  box-shadow: inset 0 0 0 2px var(--primary);
}

.result-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.name {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.state-code {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  width: fit-content;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.population {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  flex-shrink: 0;
}

.population-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.population-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.hl {
  background: linear-gradient(120deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  padding: 0 0.15em;
  border-radius: 3px;
  font-weight: 600;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 3rem;
  height: 3rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  opacity: 0.5;
}

.empty-state p {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.empty-state span {
  font-size: 0.85rem;
}

.empty-state.error svg {
  color: #dc2626;
  opacity: 0.7;
}

.empty-state.error p {
  color: #dc2626;
}

/* Footer */
.app-footer {
  text-align: center;
  padding-top: 2rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.app-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.app-footer a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.developer-info {
  margin-top: 0.5rem;
}

/* Animations */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Stagger animation for result items */
.result-item:nth-child(1) {
  animation-delay: 0s;
}
.result-item:nth-child(2) {
  animation-delay: 0.03s;
}
.result-item:nth-child(3) {
  animation-delay: 0.06s;
}
.result-item:nth-child(4) {
  animation-delay: 0.09s;
}
.result-item:nth-child(5) {
  animation-delay: 0.12s;
}
.result-item:nth-child(6) {
  animation-delay: 0.15s;
}
.result-item:nth-child(7) {
  animation-delay: 0.18s;
}
.result-item:nth-child(8) {
  animation-delay: 0.21s;
}
.result-item:nth-child(9) {
  animation-delay: 0.24s;
}
.result-item:nth-child(10) {
  animation-delay: 0.27s;
}

/* Responsive */
@media (max-width: 480px) {
  .app {
    padding: 1.5rem 1rem;
  }

  .logo {
    font-size: 1.5rem;
  }

  .search {
    font-size: 0.95rem;
    padding: 0.95rem 3rem 0.95rem 2.75rem;
  }

  .result-item {
    padding: 0.85rem 1rem;
  }

  .name {
    font-size: 0.9rem;
  }

  .population-value {
    font-size: 0.85rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
