/* =====================================================================
   NodeWatch · Device Console — shared stylesheet
   Clean, responsive theme used by index.html and search.html
   ===================================================================== */

/* ---- Design tokens ---------------------------------------------------- */
:root {
  color-scheme: dark;
  --bg:        #0d1117;   /* page background          */
  --surface:   #161b22;   /* card / panel background  */
  --surface-2: #1c232c;   /* nested fields            */
  --border:    #2a323d;   /* hairline borders         */
  --border-2:  #394250;   /* focus / hover borders    */

  --text:      #e6edf3;   /* primary text             */
  --text-dim:  #9aa7b4;   /* secondary text           */
  --text-mute: #5f6b78;   /* hints / placeholders     */

  --accent:    #2dd4bf;   /* teal accent              */
  --accent-dk: #14b8a6;
  --accent-fg: #04201c;   /* text on accent           */

  --online:    #22c55e;   /* status: online           */
  --online-bg: rgba(34, 197, 94, 0.12);
  --offline:   #ef4444;   /* status: offline          */
  --offline-bg:rgba(239, 68, 68, 0.12);

  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 16px 48px rgba(0, 0, 0, 0.45);

  --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;
}

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

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(45, 212, 191, 0.07), transparent 70%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* ---- Brand mark ------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-dk));
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(45, 212, 191, 0.35);
  flex-shrink: 0;
}
.brand-mark span {
  width: 11px; height: 11px;
  background: var(--accent-fg);
  border-radius: 3px;
  transform: rotate(45deg);
}
.brand-name { font-weight: 600; letter-spacing: 0.2px; font-size: 15px; }
.brand-name b { color: var(--accent); font-weight: 600; }

/* =====================================================================
   LOGIN PAGE
   ===================================================================== */
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 32px 30px;
}

.login-card .brand { justify-content: center; margin-bottom: 22px; }

.login-head { text-align: center; margin-bottom: 26px; }
.login-head h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.2px; }
.login-head p  { color: var(--text-dim); font-size: 13.5px; margin-top: 5px; }

/* ---- Form primitives (shared) ---------------------------------------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 7px;
  font-weight: 500;
}

.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  padding: 12px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--text-mute); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dk));
  color: var(--accent-fg);
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s, transform 0.05s, opacity 0.15s;
}
.btn:hover  { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; filter: none; }

.btn-ghost {
  width: auto;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-weight: 500;
  padding: 8px 14px;
  font-size: 13px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-2); filter: none; }

/* ---- Inline button spinner ------------------------------------------- */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(4, 32, 28, 0.35);
  border-top-color: var(--accent-fg);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Messages --------------------------------------------------------- */
.message {
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 16px;
  display: none;            /* toggled to flex by JS */
  align-items: flex-start;
  gap: 8px;
  line-height: 1.45;
}
.message.show { display: flex; }
.message.error {
  background: var(--offline-bg);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.message.info {
  background: rgba(45, 212, 191, 0.08);
  border: 1px solid rgba(45, 212, 191, 0.3);
  color: #7fe3d6;
}

.login-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 18px;
}
.login-hint code {
  font-family: var(--mono);
  color: var(--text-dim);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
}

/* =====================================================================
   SEARCH PAGE
   ===================================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 17, 23, 0.8);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
.page-head p  { color: var(--text-dim); font-size: 14px; margin-top: 5px; }

/* ---- Search form ------------------------------------------------------ */
.search-form {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.search-form .input { flex: 1; }
.search-form .btn { width: auto; padding: 12px 22px; white-space: nowrap; }

@media (max-width: 520px) {
  .search-form { flex-direction: column; }
  .search-form .btn { width: 100%; }
}

/* ---- Loading state ---------------------------------------------------- */
.loading {
  display: none;                /* toggled by JS */
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 14px;
  padding: 32px 0;
}
.loading.show { display: flex; }
.loading .spinner {
  border-color: rgba(45, 212, 191, 0.25);
  border-top-color: var(--accent);
  width: 20px; height: 20px;
}

/* ---- Device result card ---------------------------------------------- */
.device-card {
  display: none;                /* toggled by JS */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-top: 24px;
}
.device-card.show { display: block; }

.device-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.device-card-head h2 { font-size: 18px; font-weight: 600; }
.device-card-head .sub { color: var(--text-mute); font-size: 12.5px; margin-top: 2px; }

/* ---- Field table ------------------------------------------------------ */
.device-table { width: 100%; border-collapse: collapse; }
.device-table tr { border-bottom: 1px solid var(--border); }
.device-table tr:last-child { border-bottom: none; }
.device-table th,
.device-table td { text-align: left; padding: 15px 24px; font-size: 14px; vertical-align: middle; }
.device-table th {
  color: var(--text-dim);
  font-weight: 500;
  width: 42%;
  font-size: 13px;
}
.device-table td { color: var(--text); font-family: var(--mono); font-size: 13.5px; }

/* ---- Status badge ----------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  text-transform: capitalize;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; }
.badge.online  { background: var(--online-bg);  color: var(--online); }
.badge.online .dot  { background: var(--online); box-shadow: 0 0 8px var(--online); }
.badge.offline { background: var(--offline-bg); color: var(--offline); }
.badge.offline .dot { background: var(--offline); }

/* ---- Empty / hint state ---------------------------------------------- */
.search-hint {
  color: var(--text-mute);
  font-size: 12.5px;
  font-family: var(--mono);
}

/* =====================================================================
   LOGS PAGE SPECIFIC STYLES
   ===================================================================== */
.logs-container {
  display: none;                /* toggled by JS */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-top: 24px;
}
.logs-container.show { display: block; }

.logs-table-wrapper {
  overflow-x: auto;
}

.logs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  text-align: left;
}

.logs-table th {
  background: var(--surface-2);
  color: var(--text-dim);
  font-weight: 600;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.logs-table td {
  color: var(--text);
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
  vertical-align: middle;
}

.logs-table tbody tr:last-child td {
  border-bottom: none;
}

.logs-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.015);
}

.logs-table .mono {
  font-family: var(--mono);
  color: var(--text-dim);
  font-size: 12.5px;
}

.logs-table .badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.logs-table .endpoint-badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 2px 6px;
  border-radius: 4px;
}

.logs-table .value-badge {
  background: rgba(45, 212, 191, 0.08);
  border: 1px solid rgba(45, 212, 191, 0.2);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 2px 6px;
  border-radius: 4px;
}

.logs-table .date-time {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: nowrap;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
  flex-wrap: wrap;
  gap: 16px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-controls .btn-page {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
}

.pagination-controls .btn-page:hover:not(:disabled) {
  border-color: var(--border-2);
  color: var(--text);
}

.pagination-controls .btn-page:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.limit-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s;
}

.select-input:focus {
  border-color: var(--accent);
}

