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

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: rgba(59, 130, 246, 0.15);
  --border: #334155;
  --border-hover: #475569;
  --gradient-start: #3b82f6;
  --gradient-end: #8b5cf6;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: 200ms ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

button {
  cursor: pointer;
  font-family: inherit;
}

input {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

/* ===== Header ===== */
.header {
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  text-decoration: none;
}

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

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  color: white;
}

.logo-text {
  font-weight: 700;
  font-size: 1.125rem;
}

.header-github {
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.header-github:hover {
  color: var(--text-primary);
  background: var(--accent-light);
}

/* ===== Main ===== */
.main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 60px 0 40px;
  animation: fadeIn 0.6s ease;
}

.hero-title {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 12px;
}

.highlight {
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 1.125rem;
  font-weight: 400;
  margin-bottom: 32px;
}

/* ===== Search ===== */
.search-form {
  max-width: 600px;
  margin: 0 auto;
}

.search-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 4px 4px 4px 18px;
  transition: all var(--transition);
}

.search-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light);
}

.search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  padding: 12px 12px;
  min-width: 0;
}

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

.search-button {
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}

.search-button:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.search-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.button-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ===== Loading ===== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 0;
  color: var(--text-secondary);
  animation: fadeIn 0.3s ease;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ===== Error ===== */
.error-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  color: #fca5a5;
  animation: fadeIn 0.3s ease;
  margin-top: 24px;
}

.error-container::before {
  content: '!';
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
  line-height: 1;
}

/* ===== Empty ===== */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
  animation: fadeIn 0.6s ease;
}

.empty-icon {
  margin-bottom: 20px;
  color: var(--border);
}

.empty-state h2 {
  color: var(--text-secondary);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.95rem;
}

/* ===== Results ===== */
.results {
  animation: fadeIn 0.5s ease;
}

.package-info {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-top: 32px;
}

.package-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.package-name-section {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.package-name {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  word-break: break-all;
}

.package-version {
  font-size: 0.875rem;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}

.package-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.badge-python {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.badge-license {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
}

.package-summary {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: border-color var(--transition);
}

.stat-card:hover {
  border-color: var(--border-hover);
}

.stat-card-highlight {
  border-color: rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.05);
}

.stat-card-highlight .stat-value {
  color: var(--accent);
}

.stat-card-full {
  grid-column: 1 / -1;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.info-value {
  font-size: 0.9rem;
  color: var(--text-secondary);
  word-break: break-all;
}

.info-link {
  color: var(--accent);
  font-size: 0.85rem;
}

.info-link:hover {
  text-decoration: underline;
}

.info-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.package-link {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.pypi-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--transition);
}

.pypi-link:hover {
  background: var(--accent);
  color: white;
}

/* ===== Chart ===== */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-top: 20px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.chart-total {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 320px;
}

/* ===== Credits ===== */
.credits {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 24px 0;
  margin-top: auto;
}

.credits-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.credits-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.credits-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.credits-separator {
  color: var(--text-muted);
}

.credits-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.credits-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.credits-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}

.credits-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* ===== Suggestions ===== */
.suggestions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.suggestion-btn {
  padding: 6px 14px;
  background: var(--accent-light);
  border: 1px solid transparent;
  border-radius: 20px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all var(--transition);
}

.suggestion-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .hero-title {
    font-size: 2.5rem;
  }

  .hero {
    padding: 40px 0 24px;
  }

  .main {
    padding: 0 16px 60px;
  }

  .package-header {
    flex-direction: column;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .credits-inner {
    flex-direction: column;
    text-align: center;
  }

  .credits-info {
    justify-content: center;
  }
}
