/* ─── Variables ─────────────────────────────────────────────────── */
:root {
  --bg:          #0a0709;
  --bg-card:     #110d10;
  --bg-card-h:   #180f16;
  --border:      rgba(255, 105, 180, 0.10);
  --border-h:    rgba(255, 105, 180, 0.28);
  --pink:        #ff69b4;
  --pink-dim:    #c4498a;
  --pink-glow:   rgba(255, 105, 180, 0.18);
  --pink-deep:   #7d1f52;
  --green:       #39ffa0;
  --green-dim:   rgba(57, 255, 160, 0.14);
  --red:         #ff4d6d;
  --red-dim:     rgba(255, 77, 109, 0.14);
  --yellow:      #ffd166;
  --yellow-dim:  rgba(255, 209, 102, 0.14);
  --text:        #f0dde8;
  --text-muted:  #7a5d70;
  --text-dim:    #3d2535;
  --mono:        'DM Mono', monospace;
  --sans:        'Syne', sans-serif;
  --radius:      14px;
  --radius-sm:   8px;
  --transition:  0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ─── Background ────────────────────────────────────────────────── */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255,105,180,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,105,180,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.bg-glow {
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 600px;
  background: radial-gradient(ellipse at center,
    rgba(255,105,180,0.08) 0%,
    rgba(125,31,82,0.04) 40%,
    transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ─── Header ────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 7, 9, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 1.5rem;
  color: var(--pink);
  filter: drop-shadow(0 0 8px var(--pink));
  animation: pulse-icon 3s ease-in-out infinite;
}

@keyframes pulse-icon {
  0%, 100% { filter: drop-shadow(0 0 6px var(--pink)); }
  50%       { filter: drop-shadow(0 0 18px var(--pink)); }
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}

.logo-dot {
  color: var(--pink);
}

.logo-badge {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--pink);
  background: rgba(255,105,180,0.12);
  border: 1px solid rgba(255,105,180,0.25);
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.12em;
  align-self: center;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: blink 1.8s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--green); }
  50%       { opacity: 0.4; box-shadow: 0 0 2px var(--green); }
}

.live-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--green);
}

.last-refresh {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ─── Stats bar ─────────────────────────────────────────────────── */
.stats-bar {
  position: relative;
  z-index: 1;
  background: rgba(17, 13, 16, 0.7);
  border-bottom: 1px solid var(--border);
}

.stats-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 0;
}

.stat-card {
  padding: 1.1rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  transition: all 0.3s ease;
}

.stat-value.online  { color: var(--green); text-shadow: 0 0 20px rgba(57,255,160,0.4); }
.stat-value.offline { color: var(--red);   text-shadow: 0 0 20px rgba(255,77,109,0.4); }

.stat-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.stat-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
  flex-shrink: 0;
}

/* ─── Main ──────────────────────────────────────────────────────── */
.main {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
  margin-bottom: 1.8rem;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.section-meta {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* ─── Grid ──────────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.2rem;
}

/* ─── Site card ─────────────────────────────────────────────────── */
.site-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition),
              box-shadow var(--transition);
  animation: card-in 0.45s cubic-bezier(0.2, 0, 0, 1) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.site-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--pink), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.site-card:hover {
  border-color: var(--border-h);
  transform: translateY(-2px);
  box-shadow: 0 12px 48px rgba(0,0,0,0.5), 0 0 0 1px var(--border-h),
              inset 0 1px 0 rgba(255,105,180,0.08);
  background: var(--bg-card-h);
}

.site-card:hover::before {
  opacity: 1;
}

/* Glow on status change */
.site-card.flash-online  { animation: flash-g 0.5s ease; }
.site-card.flash-offline { animation: flash-r 0.5s ease; }

@keyframes flash-g {
  0%  { box-shadow: 0 0 0 3px rgba(57,255,160,0.4); }
  100%{ box-shadow: none; }
}
@keyframes flash-r {
  0%  { box-shadow: 0 0 0 3px rgba(255,77,109,0.4); }
  100%{ box-shadow: none; }
}

/* ─── Card top ──────────────────────────────────────────────────── */
.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-info { flex: 1; min-width: 0; }

.card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.card-url {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Status badge ──────────────────────────────────────────────── */
.status-badge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 7px;
  border-radius: 20px;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  transition: all 0.3s ease;
}

.status-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-badge.online {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(57,255,160,0.25);
}
.status-badge.online .dot {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: blink 1.8s ease-in-out infinite;
}

.status-badge.offline {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255,77,109,0.2);
}
.status-badge.offline .dot { background: var(--red); }

.status-badge.checking {
  background: var(--pink-glow);
  color: var(--pink);
  border: 1px solid rgba(255,105,180,0.2);
}
.status-badge.checking .dot {
  background: var(--pink);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.5); opacity: 0.5; }
}

/* ─── Card metrics ──────────────────────────────────────────────── */
.card-metrics {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-value {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  transition: color 0.3s ease;
}

.metric-value.fast   { color: var(--green); }
.metric-value.medium { color: var(--yellow); }
.metric-value.slow   { color: var(--red); }
.metric-value.null   { color: var(--text-muted); }

.metric-label {
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ─── Card footer ───────────────────────────────────────────────── */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}

.card-timestamp {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--text-muted);
}

.visit-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: linear-gradient(135deg, rgba(255,105,180,0.15), rgba(196,73,138,0.1));
  border: 1px solid rgba(255,105,180,0.25);
  border-radius: var(--radius-sm);
  color: var(--pink);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.visit-btn:hover {
  background: rgba(255,105,180,0.22);
  border-color: rgba(255,105,180,0.5);
  box-shadow: 0 0 16px rgba(255,105,180,0.2);
  transform: scale(1.03);
}

.visit-btn svg {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

/* ─── Empty state ────────────────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 5rem 2rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  color: var(--text-dim);
  animation: spin 4s linear infinite;
}

@keyframes spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.empty-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.empty-sub {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* ─── Footer ────────────────────────────────────────────────────── */
.footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.footer-sep { color: var(--text-dim); }

#connStatus { color: var(--pink); }
#connStatus.connected { color: var(--green); }
#connStatus.disconnected { color: var(--red); }

/* ─── Scrollbar ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--pink-deep);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--pink-dim); }

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner { padding: 0 1rem; }
  .stats-inner  { padding: 0 1rem; overflow-x: auto; }
  .stat-card    { padding: 0.9rem 1.2rem; }
  .stat-value   { font-size: 1.3rem; }
  .main         { padding: 1.5rem 1rem 3rem; }
  .grid         { grid-template-columns: 1fr; gap: 0.9rem; }
  .last-refresh { display: none; }
  .section-meta { display: none; }
}

@media (max-width: 480px) {
  .logo-text   { font-size: 1rem; }
  .logo-badge  { display: none; }
  .stat-card   { padding: 0.8rem 1rem; }
}
