/* ============================================
   QTECO DASH v2 — style.css (Pi-optimised)
   CSS marquee replaces JS animation loop.
   ============================================ */

/* ---------- LIGHT ---------- */
:root {
  --font-family: 'Inter', system-ui, Arial, sans-serif;

  --bg-primary:   #eef1f6;
  --bg-secondary: #ffffff;
  --bg-soft:      #f7f8fb;

  --text-primary:   #1a1a2e;
  --text-secondary: #555770;
  --text-muted:     #8b8da3;

  --border-subtle: rgba(0, 0, 0, 0.07);
  --shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md:     0 4px 14px rgba(0, 0, 0, 0.08);

  --status-grey: #dfe3ea;
  --purple:      #ede9fe; --purple-text: #6d28d9; --purple-ring: rgba(139, 92, 246, 0.45);
  --green:       #dcfce7; --green-text:  #15803d; --green-ring:  rgba(34,  197, 94,  0.45);
  --blue:        #dbeafe; --blue-text:   #1d4ed8; --blue-ring:   rgba(59,  130, 246, 0.45);
  --orange:      #f97316;
  --red:         #fee2e2; --red-text:    #dc2626; --red-ring:    rgba(239, 68,  68,  0.45);
  --red2:        #ef4444;

  --white-op:   rgba(0, 0, 0, 0.08);
  --radius-sm:  8px;
  --radius-md:  12px;
  --transition: 0.2s ease;

  /* marquee speed — overridden by JS per render */
  --scroll-duration: 30s;
}

/* ---------- DARK ---------- */
.dark-mode {
  --bg-primary:   #0f0f14;
  --bg-secondary: #1a1a24;
  --bg-soft:      #20202c;

  --text-primary:   #e4e4ed;
  --text-secondary: #a0a0b8;
  --text-muted:     #6b6b82;

  --border-subtle: rgba(255, 255, 255, 0.07);
  --shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md:     0 4px 14px rgba(0, 0, 0, 0.4);

  --status-grey: #2c2c38;
  --purple:      #2e2350; --purple-text: #c4b5fd; --purple-ring: rgba(139, 92, 246, 0.5);
  --green:       #16331f; --green-text:  #86efac; --green-ring:  rgba(34,  197, 94,  0.4);
  --blue:        #16263f; --blue-text:   #93c5fd; --blue-ring:   rgba(59,  130, 246, 0.4);
  --orange:      #ea580c;
  --red:         #3a1620; --red-text:    #fca5a5; --red-ring:    rgba(239, 68,  68,  0.5);
  --red2:        #ef4444;

  --white-op: rgba(255, 255, 255, 0.07);
}

/* ---------- BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { overflow: hidden; }
body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  text-align: center;
  margin: 0;
  height: 100vh;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* ---------- HEADER ---------- */
.Qteco {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  position: sticky;
  height: 7vh;
  min-height: 52px;
  top: 0;
  justify-content: space-between;
  align-items: center;
  padding: 0.5% 2%;
  box-shadow: var(--shadow-sm);
  z-index: 1000;
}
.Qteco .logo img { max-height: 5.5vh; width: auto; }

/* ---------- SCROLLER ---------- */
#card-container {
  display: block;
  overflow: hidden;          /* changed from auto — CSS animation handles scroll */
  height: calc(100vh - 14vh);
  padding: 16px;
}

@keyframes marquee-bounce {
  0%   { transform: translateY(0); }
  100% { transform: translateY(calc(-1 * var(--max-scroll, 0px))); }
}
#card-container.is-scrolling .grid {
  animation: marquee-bounce var(--scroll-duration) linear infinite alternate;
  will-change: transform;
}
#card-container.scroll-paused .grid {
  animation-play-state: paused;
}

/* Respect reduced motion preference (accessibility + Pi with slow GPU) */
@media (prefers-reduced-motion: reduce) {
  #card-container.is-scrolling .grid,
  #card-container.is-scrolling .grid-clone {
    animation: none;
  }
  #card-container { overflow-y: auto; }
}

/* ---------- GRID ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 0; /* gap between original and clone handled by padding */
  padding-bottom: 24px;
}

/* ---------- CARDS ---------- */
.card {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  /* Only transition box-shadow on hover — avoids unnecessary repaints */
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card .url {
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: visible;
  display: inline-block;
  max-width: 100%;
  color: var(--text-primary);
  line-height: 1.4;
  padding-bottom: 2px;
}
.card:hover .url { text-decoration: underline; text-underline-offset: 3px; }
a { text-decoration: none; color: inherit; }

.meta {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 4px 0 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.favicon {
  width: 24px; height: 24px;
  object-fit: contain;
  border-radius: 6px;
  padding: 3px;
  margin-bottom: 6px;
  background: var(--bg-soft);
  box-shadow: var(--shadow-sm);
}

/* ---------- STATUS COLORS ---------- */
.status-0xx { background: var(--status-grey); }
.status-1xx { background: var(--purple); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--purple-ring); }
.status-1xx .url { color: var(--purple-text); }
.status-2xx { background: var(--green);  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--green-ring); }
.status-2xx .url { color: var(--green-text); }
.status-3xx { background: var(--blue);   box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--blue-ring); }
.status-3xx .url { color: var(--blue-text); }
.status-4xx { background: var(--red);    box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--red-ring); }
.status-4xx .url { color: var(--red-text); }
.status-5xx { background: var(--red);    box-shadow: var(--shadow-sm), inset 0 0 0 2px var(--red-ring); }
.status-5xx .url { color: var(--red-text); }

.card.own {
  box-shadow: var(--shadow-sm), inset 0 0 0 2px var(--purple-ring), 0 0 10px rgba(139, 92, 246, 0.18);
}

/* ---------- FLASH ANIMATIONS (status changes) ---------- */
@keyframes flash-down { 0%,100% { opacity:1; } 50% { opacity:0.3; background: var(--red); } }
@keyframes flash-up   { 0%,100% { opacity:1; } 50% { opacity:0.3; background: var(--green); } }
.flash-down { animation: flash-down 0.6s ease 3; }
.flash-up   { animation: flash-up   0.6s ease 3; }
.flash-change { animation: flash-down 0.6s ease 2; }

/* ---------- SELECTS / BUTTONS ---------- */
#filter, #theme-container {
  font-size: 0.85rem; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-secondary);
}
#status-filter, #theme-select {
  font: 600 0.8rem var(--font-family);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-soft);
  color: var(--text-primary);
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}
#status-filter option, #theme-select option { background: var(--bg-secondary); color: var(--text-primary); }

.health-pill {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; font-weight: 700;
  padding: 6px 14px; border-radius: 20px;
  background: var(--bg-soft);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
#health-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }
.health-pill.warn #health-dot { background: #5ec522; }
.health-pill.bad  #health-dot { background: #ef4444; }

#kiosk-btn {
  font-size: 1rem; line-height: 1;
  padding: 7px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-soft);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition);
}
#kiosk-btn:hover { background: var(--bg-secondary); }

/* ---------- CLOCK ---------- */
.dateTime { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; font-family: 'JetBrains Mono', monospace; }
.lastReload { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; align-self: center; }

/* ---------- FOOTER ---------- */
footer {
  font-weight: 600;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  position: fixed;
  width: 100%;
  height: 4vw;
  min-height: 44px;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  z-index: 1000;
}
.memoryBar, .diskBar {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.75rem; font-weight: 500; color: var(--text-secondary);
}
.memoryBar.na, .diskBar.na { opacity: 0.55; }
.bignum { font-weight: 700; font-variant-numeric: tabular-nums; }
.memoryBar.green  .bignum { color: #16a34a; }
.memoryBar.orange .bignum { color: #ea580c; }
.memoryBar.red    .bignum { color: #dc2626; }
.dark-mode .memoryBar.green  .bignum { color: #86efac; }
.dark-mode .memoryBar.orange .bignum { color: #fdba74; }
.dark-mode .memoryBar.red    .bignum { color: #fca5a5; }

progress {
  appearance: none; -webkit-appearance: none;
  border: none; border-radius: 10px;
  height: 8px; overflow: hidden; min-width: 60px;
}
.green  progress::-webkit-progress-value { background: linear-gradient(90deg, #22c55e, #4ade80); border-radius: 10px; }
.orange progress::-webkit-progress-value { background: linear-gradient(90deg, #f97316, #fb923c); border-radius: 10px; }
.red    progress::-webkit-progress-value { background: linear-gradient(90deg, #ef4444, #f87171); border-radius: 10px; }
.green  progress::-webkit-progress-bar,
.orange progress::-webkit-progress-bar,
.red    progress::-webkit-progress-bar { border-radius: 10px; background: var(--white-op); }
.green  progress::-moz-progress-bar { background: #22c55e; }
.orange progress::-moz-progress-bar { background: #f97316; }
.red    progress::-moz-progress-bar { background: #ef4444; }

/* ---------- TOASTS ---------- */
#toasts { position: fixed; right: 16px; bottom: 60px; display: flex; flex-direction: column; gap: 10px; z-index: 2000; }
.toast {
  min-width: 250px; padding: 12px 16px; border-radius: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
  font-size: 0.8rem; font-weight: 600; color: var(--text-primary);
  text-align: left;
  animation: toast-in 0.3s ease;
}
.toast.hide { opacity: 0; transform: translateX(20px); transition: all 0.5s; }
.toast-down { border-color: var(--red-ring); }
.toast-up   { border-color: var(--green-ring); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- ERROR BANNER ---------- */
.error-banner {
  margin: 40px auto; max-width: 500px; padding: 20px;
  border-radius: 12px; background: var(--red); color: var(--red-text);
  font-weight: 600; border: 1px solid var(--red-ring);
}

::selection { background: var(--purple-ring); color: var(--text-primary); }