/* ============================================
   DigiFpga - Global FPGA Part Database
   Main Stylesheet
   ============================================ */

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a2035;
  --bg-card-hover: #222b45;
  --bg-input: #1e2640;
  --border-color: #2a3455;
  --border-hover: #4a5580;
  --text-primary: #e8eaf0;
  --text-secondary: #9ca3b8;
  --text-muted: #6b7280;
  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --accent-secondary: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --success: #10b981;
  --warning: #f59e0b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
  --transition: 0.2s ease;
}

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

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ===== HEADER ===== */
.site-header {
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 1.5rem;
}

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

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}

.site-logo .logo-icon {
  width: 34px;
  height: 34px;
  background: var(--accent-gradient);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  color: #fff;
}

.site-logo .logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lang-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}
.lang-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

/* ===== HERO ===== */
.hero {
  background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  padding: 4rem 1.5rem 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 50% 50%, rgba(59,130,246,0.06) 0%, transparent 60%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #e8eaf0 0%, #3b82f6 50%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 650px;
  margin: 0 auto 2rem;
  line-height: 1.7;
}

/* Stats */
.stats-row {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-bottom: 2.5rem;
}

.stat-item {
  text-align: center;
}

.stat-num {
  font-size: 2.8rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* Global search */
.global-search {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

.global-search input {
  width: 100%;
  padding: 0.9rem 1.2rem 0.9rem 3rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  transition: var(--transition);
}

.global-search input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.global-search .search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ===== BRAND GRID (Home) ===== */
.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.section-desc {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.brand-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.brand-emoji {
  font-size: 2rem;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.brand-info h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.brand-info .brand-cn {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.brand-info .brand-count {
  font-size: 0.85rem;
  color: var(--accent-primary);
  font-weight: 600;
  margin-top: 0.2rem;
}

/* ===== BRAND VIEW (Detail) ===== */
.brand-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.back-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
}
.back-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.brand-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
}

.brand-header .brand-badge {
  background: var(--accent-gradient);
  color: #fff;
  padding: 0.2rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Filters */
.filters-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.filter-group select,
.filter-group input {
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  min-width: 160px;
  transition: var(--transition);
}

.filter-group select:focus,
.filter-group input:focus {
  border-color: var(--accent-primary);
}

.filter-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239ca3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}

/* Data table */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table thead {
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table th {
  padding: 0.7rem 0.8rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid rgba(42, 52, 85, 0.5);
  color: var(--text-primary);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.05);
}

.data-table .pn-cell {
  font-family: var(--font-mono);
  font-size: 0.83rem;
  color: var(--accent-primary);
  font-weight: 500;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  padding: 0.5rem 0;
  flex-wrap: wrap;
  gap: 0.5rem;
}

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

.page-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.page-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  transition: var(--transition);
}
.page-btn:hover:not(:disabled) {
  border-color: var(--accent-primary);
  background: var(--bg-card-hover);
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-num {
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 0 0.5rem;
}

.page-jump {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.page-jump input {
  width: 55px;
  padding: 0.4rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  text-align: center;
  outline: none;
}

/* Search results view */
.search-results-header {
  margin-bottom: 1rem;
}
.search-results-header h2 {
  font-size: 1.3rem;
}
.search-results-header .result-count {
  color: var(--text-secondary);
}

/* Loading */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 1rem;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.75rem;
}

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

/* No results */
.no-results {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

/* ===== FOOTER ===== */
.site-footer {
  border-top: 1px solid var(--border-color);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  html { font-size: 14px; }
  
  .hero { padding: 2.5rem 1rem 2rem; }
  .hero h1 { font-size: 1.8rem; }
  .hero p { font-size: 0.95rem; }
  
  .stats-row { gap: 2rem; }
  .stat-num { font-size: 2rem; }
  
  .brand-grid {
    grid-template-columns: 1fr;
  }
  
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-group select,
  .filter-group input {
    min-width: 100%;
  }
  
  .data-table {
    font-size: 0.82rem;
  }
  
  .data-table th,
  .data-table td {
    padding: 0.5rem 0.5rem;
  }
  
  .pagination {
    flex-direction: column;
    align-items: center;
  }
  
  .brand-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .header-inner { height: 50px; }
  .site-logo .logo-text { font-size: 1.1rem; }
  .hero h1 { font-size: 1.5rem; }
  .stats-row { flex-direction: column; gap: 1rem; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ===== SEARCH HIGHLIGHT ===== */
.highlight {
  background: rgba(59, 130, 246, 0.25);
  border-radius: 2px;
  padding: 0 2px;
}

/* Per-page selector */
.per-page-select {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.per-page-select select {
  padding: 0.35rem 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}
