/* ============================================
   NEXUS — Base Styles
   Imports, resets, breakpoints, a11y, print
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:ital,wght@0,100..900;1,100..900&display=swap');

/* Design tokens */
@import './tokens.css';

/* ============================================
   Reset / Normalize
   ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  tab-size: 4;
}

html, body, #root {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--surface-base);
  color: var(--ink-1);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
}

input, select, textarea {
  font-family: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

ul, ol {
  list-style: none;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--ink-5);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--ink-5) transparent;
}

/* ============================================
   Focus-visible styles
   ============================================ */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Inputs get an inset ring instead of outline */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Pill-shaped elements keep their shape */
.btn:focus-visible,
.seg-btn:focus-visible,
.rail-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: inherit;
}

/* ============================================
   Responsive breakpoints
   ============================================ */

/* Below 1024px: sidebar collapses (hidden) */
@media (max-width: 1024px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
}

/* Below 720px: rail collapses to bottom bar or hidden */
@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
  }
  .rail {
    display: none;
  }
  .sidebar {
    display: none;
  }
  .main {
    border-radius: 0;
  }

  /* Hero stacks vertically */
  .hero {
    grid-template-columns: 1fr;
  }

  /* Settings stacks */
  .settings-layout {
    grid-template-columns: 1fr;
  }

  /* Account stacks */
  .account-grid {
    grid-template-columns: 1fr;
  }

  /* Content padding tightens */
  .content {
    padding: var(--space-4);
  }
  .topbar {
    padding: var(--space-3) var(--space-4);
  }
}

/* ============================================
   Prefers reduced motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .site-card:hover {
    transform: none;
  }

  .modal-backdrop {
    animation: none;
  }

  .modal {
    animation: none;
  }

  .cmdk {
    animation: none;
  }
}

/* ============================================
   Monitoring
   ============================================ */
.monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.monitor-card {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.monitor-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--status-up-soft);
  color: oklch(35% 0.13 150);
  margin-bottom: 12px;
}
[data-theme="dark"] .monitor-status { color: oklch(85% 0.13 150); }
.monitor-status.down { background: var(--status-down-soft); color: oklch(45% 0.18 28); }
.monitor-status.paused { background: var(--surface-3); color: var(--ink-4); }
.monitor-status.pending { background: var(--status-warn-soft); color: oklch(45% 0.12 75); }
.monitor-actions { position: absolute; top: 14px; right: 14px; display: flex; gap: 4px; }
.monitor-name { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.monitor-url {
  font-size: 12px;
  color: var(--ink-4);
  font-family: var(--font-mono);
  margin-bottom: 14px;
  display: block;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.monitor-url:hover { color: var(--ink-3); }
.monitor-spark { display: flex; gap: 2px; align-items: flex-end; height: 28px; margin-bottom: 12px; }
.monitor-spark-bar { flex: 1; background: var(--accent); border-radius: 1.5px; min-height: 3px; }
.monitor-spark-bar.down { background: var(--status-down); }
.monitor-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); font-family: var(--font-mono); }
.monitor-meta strong { color: var(--ink-1); font-weight: 500; }

/* ============================================
   Print styles
   ============================================ */
@media print {
  /* Hide chrome */
  .rail,
  .sidebar,
  .topbar,
  .modal-backdrop,
  .cmdk,
  .alert-banner,
  .btn,
  .toggle,
  .sidebar-footer,
  .site-card-actions,
  .logs-toolbar {
    display: none !important;
  }

  /* Full width content */
  .app {
    display: block;
    padding: 0;
    height: auto;
    background: white;
  }

  .main {
    border-radius: 0;
    box-shadow: none;
    background: white;
  }

  .content {
    padding: 0;
    overflow: visible;
  }

  /* Cards print cleanly */
  .site-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .site-card:hover {
    transform: none;
    box-shadow: none;
  }

  /* Ink to pure black for printing */
  body {
    color: #000;
    background: white;
    font-size: 12pt;
  }

  /* Links show URLs */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  /* Logs viewer prints with white bg */
  .logs-viewer {
    background: white;
    color: #000;
    height: auto;
    overflow: visible;
    border: 1px solid #ccc;
  }

  .log-line-num { color: #999; }
  .log-line-time { color: #666; }
}
