/* ═══════════════════════════════════════════════════
   Revit CSV Reader — Design System & Styles
   ═══════════════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  --bg: #0b0e14;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --surface: #12161e;
  --surface-2: #1a1f2b;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --text: #e4e8ef;
  --text-muted: #8b93a5;
  --text-dim: #5a6173;
  --accent: #6c63ff;
  --accent-light: #8b83ff;
  --accent-glow: rgba(108, 99, 255, 0.35);
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --transition: 0.25s cubic-bezier(.4, 0, .2, 1);
  --font: 'Inter', -apple-system, "Segoe UI", sans-serif;
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font-family: inherit;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface);
}

::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 999px;
}

/* ═══════════════════ NAVBAR ═══════════════════ */
#navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  background: rgba(11, 14, 20, 0.72);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--accent-light);
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 2rem;
}

.nav-links a {
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-muted);
  position: relative;
  transition: color var(--transition);
}

.nav-links a:hover {
  color: var(--text);
}

.nav-links a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  transition: width var(--transition);
}

.nav-links a:hover::after {
  width: 100%;
}

/* ═══════════════════ HERO ═══════════════════ */
#hero {
  position: relative;
  min-height: 92vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6rem 2rem 4rem;
  overflow: hidden;
}

.hero-bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 60% 50% at 50% 40%, #000 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 60% 50% at 50% 40%, #000 40%, transparent 100%);
}

.hero-glow {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  filter: blur(80px);
  pointer-events: none;
  animation: pulse-glow 6s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
  0% {
    opacity: .45;
    transform: translateX(-50%) scale(1);
  }

  100% {
    opacity: .7;
    transform: translateX(-50%) scale(1.15);
  }
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 700px;
}

.hero-badge {
  display: inline-block;
  padding: .35rem 1rem;
  margin-bottom: 1.5rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-light);
  background: rgba(108, 99, 255, 0.12);
  border: 1px solid rgba(108, 99, 255, 0.25);
  border-radius: 999px;
}

#hero h1 {
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -.03em;
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent-light), #a78bfa, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  margin-top: 1.25rem;
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 520px;
  margin-inline: auto;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  margin-top: 2.2rem;
  padding: .85rem 2rem;
  font-size: .95rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 0 24px var(--accent-glow);
  transition: transform var(--transition), box-shadow var(--transition);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 32px var(--accent-glow);
}

/* ═══════════════════ SECTIONS ═══════════════════ */
section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 5rem 2rem;
}

.section-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.section-tag {
  display: inline-block;
  padding: .3rem .85rem;
  margin-bottom: .8rem;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--green);
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.2);
  border-radius: 999px;
}

.section-header h2 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.section-header p {
  color: var(--text-muted);
  margin-top: .5rem;
  font-size: 1.02rem;
}

/* ═══════════════════ DROP ZONE ═══════════════════ */
#drop-zone {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  padding: 3.5rem 2rem;
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius);
  background: var(--bg-card);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

#drop-zone:hover,
#drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.06);
  transform: translateY(-2px);
}

#drop-zone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.upload-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(108, 99, 255, 0.1);
  margin-bottom: 1.25rem;
}

.upload-icon {
  width: 36px;
  height: 36px;
  color: var(--accent-light);
}

.drop-text {
  font-size: 1rem;
  color: var(--text);
}

.drop-text strong {
  color: var(--accent-light);
}

.drop-hint {
  display: block;
  margin-top: .5rem;
  font-size: .82rem;
  color: var(--text-dim);
}

/* File info bar */
.file-info {
  max-width: 560px;
  margin: 1.2rem auto 0;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .8rem 1.2rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: .88rem;
  color: var(--text-muted);
  animation: slide-up .3s ease;
}

.file-info svg {
  color: var(--accent-light);
  flex-shrink: 0;
}

#file-name {
  font-weight: 600;
  color: var(--text);
}

#file-size {
  margin-left: auto;
  font-size: .8rem;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  padding: .2rem .4rem;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
}

.btn-icon:hover {
  color: var(--red);
  background: rgba(248, 113, 113, 0.1);
}

/* ═══════════════════ STATS ═══════════════════ */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  transition: border-color var(--transition), transform var(--transition);
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--accent-light);
}

.stat-label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ═══════════════════ TOOLBAR ═══════════════════ */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .8rem;
  margin-bottom: 1.5rem;
}

.search-wrap {
  position: relative;
  flex: 1 1 260px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

#search-input {
  width: 100%;
  padding: .7rem .7rem .7rem 2.6rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  outline: none;
  transition: border-color var(--transition);
}

#search-input:focus {
  border-color: var(--accent);
}

#search-input::placeholder {
  color: var(--text-dim);
}

.filter-wrap {
  display: flex;
  align-items: center;
  gap: .45rem;
}

.filter-wrap label {
  font-size: .82rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.filter-wrap select {
  padding: .55rem .8rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  max-width: 220px;
}

.filter-wrap select:focus {
  border-color: var(--accent);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .6rem 1.2rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.08);
}

/* ═══════════════════ TABLE ═══════════════════ */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

#data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

#data-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

#data-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  padding: .85rem 1rem;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}

#data-table th:hover {
  color: var(--accent-light);
}

#data-table th .sort-arrow {
  margin-left: .3rem;
  font-size: .7rem;
}

#data-table td {
  padding: .72rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#data-table tbody tr {
  transition: background var(--transition);
}

#data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

#data-table tbody tr:last-child td {
  border-bottom: none;
}

/* row highlight for family column */
td.family-cell {
  color: var(--accent-light);
  font-weight: 500;
}

.no-results {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-dim);
  font-size: .95rem;
}

/* ═══════════════════ PAGINATION ═══════════════════ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.btn-page {
  padding: .55rem 1.1rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  cursor: pointer;
  transition: border-color var(--transition), opacity var(--transition);
}

.btn-page:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn-page:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#page-info {
  font-size: .85rem;
  color: var(--text-muted);
}

/* ═══════════════════ LIVE DATA PANEL ═══════════════════ */
.live-tag {
  color: var(--amber) !important;
  background: rgba(251, 191, 36, 0.12) !important;
  border-color: rgba(251, 191, 36, 0.25) !important;
  animation: live-pulse 2s ease-in-out infinite;
}

@keyframes live-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(251, 191, 36, 0);
  }

  50% {
    box-shadow: 0 0 12px 2px rgba(251, 191, 36, 0.25);
  }
}

.live-panel {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 1.8rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: slide-up .4s ease;
}

.live-panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.live-select-wrap {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex: 1;
}

.live-select-wrap label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.live-select-wrap select {
  flex: 1;
  min-width: 200px;
  padding: .55rem .8rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}

.live-select-wrap select:focus {
  border-color: var(--accent);
}

.live-controls {
  display: flex;
  align-items: center;
  gap: .8rem;
}

/* Status indicator */
.live-status {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background var(--transition);
}

.live-status.connected .status-dot {
  background: var(--green);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
  animation: dot-pulse 2s ease-in-out infinite;
}

.live-status.connected .status-text {
  color: var(--green);
}

.live-status.loading .status-dot {
  background: var(--amber);
  animation: dot-pulse 1s ease-in-out infinite;
}

.live-status.loading .status-text {
  color: var(--amber);
}

.live-status.error .status-dot {
  background: var(--red);
}

.live-status.error .status-text {
  color: var(--red);
}

.live-status.idle .status-text {
  color: var(--text-dim);
}

@keyframes dot-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .4;
  }
}

/* Auto-refresh checkbox */
.auto-refresh-label {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.auto-refresh-label input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}

/* Meta row */
.live-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 1rem;
  padding-top: .8rem;
  border-top: 1px solid var(--border);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  color: var(--text-dim);
}

.meta-item svg {
  color: var(--text-dim);
  flex-shrink: 0;
}

.meta-item strong {
  color: var(--text-muted);
  font-weight: 600;
}

/* ═══════════════════ FOOTER ═══════════════════ */
#footer {
  text-align: center;
  padding: 2.5rem 2rem;
  border-top: 1px solid var(--border);
  font-size: .82rem;
  color: var(--text-dim);
}

/* ═══════════════════ UTILITY ═══════════════════ */
.hidden {
  display: none !important;
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: slide-up .45s ease;
}

/* ═══════════════════ RESPONSIVE ═══════════════════ */
@media (max-width: 768px) {
  .nav-links {
    display: none;
  }

  #hero h1 {
    font-size: 2rem;
  }

  .hero-sub {
    font-size: .96rem;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-wrap {
    justify-content: space-between;
  }

  #data-table th,
  #data-table td {
    padding: .6rem .7rem;
    font-size: .8rem;
  }
}

@media (max-width: 480px) {
  section {
    padding: 3rem 1rem;
  }

  .stats-bar {
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
  }

  #hero {
    min-height: 80vh;
  }
}