/* -------------------------------------------------------------------------
   Bowls Monitor — dark theme matching bowls-manager-2
   ------------------------------------------------------------------------- */

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 0.875rem;
  background: #0f1117;
  color: #e2e8f0;
  min-height: 100vh;
}

/* -------------------------------------------------------------------------
   Header
   ------------------------------------------------------------------------- */

header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 2rem;
  height: 57px;
  background: #1a1d2e;
  border-bottom: 1px solid #2d3148;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #a5b4fc;
  white-space: nowrap;
}

nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

nav a {
  font-size: 0.8rem;
  color: #64748b;
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

nav a:hover { color: #e2e8f0; }
nav a.active { color: #a5b4fc; border-bottom-color: #4f46e5; }

/* -------------------------------------------------------------------------
   Main content
   ------------------------------------------------------------------------- */

main {
  padding: 1.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* -------------------------------------------------------------------------
   Page header row
   ------------------------------------------------------------------------- */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.page-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #e2e8f0;
}

.refresh-badge {
  display: inline-block;
  font-size: 0.7rem;
  color: #64748b;
  margin-left: 0.6rem;
}

/* -------------------------------------------------------------------------
   Table
   ------------------------------------------------------------------------- */

.table-wrap {
  background: #1a1d2e;
  border: 1px solid #2d3148;
  border-radius: 8px;
  overflow: hidden;
}

.status-table {
  width: 100%;
  border-collapse: collapse;
}

.status-table th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  padding: 0.75rem 1rem;
  text-align: left;
  background: #13151f;
  border-bottom: 1px solid #2d3148;
  white-space: nowrap;
}

.status-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #1e2130;
  vertical-align: middle;
  white-space: nowrap;
}

.server-row:last-child td { border-bottom: none; }

.server-row:hover td { background: #1e2235; }

/* Column widths */
.col-name     { font-weight: 500; }
.col-status   { min-width: 90px; }
.col-response { min-width: 80px;  color: #94a3b8; }
.col-checked  { min-width: 110px; color: #94a3b8; }
.col-uptime   { min-width: 85px; }
.col-fails    { min-width: 80px;  text-align: center; }
.col-reboot   { min-width: 120px; color: #94a3b8; }
.col-actions  { min-width: 130px; }

/* -------------------------------------------------------------------------
   Status dot (8px circle in server name cell)
   ------------------------------------------------------------------------- */

.server-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #374151;
  margin-right: 0.5rem;
  vertical-align: middle;
  flex-shrink: 0;
}

.server-dot.up      { background: #22c55e; }
.server-dot.down    { background: #ef4444; }
.server-dot.unknown { background: #374151; }
.server-dot.checking {
  background: #f59e0b;
  animation: pulse 1s infinite;
}

/* -------------------------------------------------------------------------
   Status text pill
   ------------------------------------------------------------------------- */

.status-text {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-text::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-text.up::before      { background: #22c55e; }
.status-text.down::before    { background: #ef4444; }
.status-text.unknown::before { background: #374151; }
.status-text.checking::before {
  background: #f59e0b;
  animation: pulse 1s infinite;
}

.status-text.up      { color: #4ade80; }
.status-text.down    { color: #f87171; }
.status-text.unknown { color: #4b5563; }
.status-text.checking { color: #fbbf24; }

/* -------------------------------------------------------------------------
   Consecutive failures highlight
   ------------------------------------------------------------------------- */

.fails-warn  { color: #fb923c; font-weight: 600; }
.fails-error { color: #f87171; font-weight: 600; }

/* -------------------------------------------------------------------------
   Uptime bar
   ------------------------------------------------------------------------- */

.uptime-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.uptime-pct { font-size: 0.8rem; }
.uptime-pct.good    { color: #4ade80; }
.uptime-pct.warn    { color: #fb923c; }
.uptime-pct.bad     { color: #f87171; }

/* -------------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.45rem 0.9rem;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:hover   { opacity: 0.85; }
.btn:active  { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary   { background: #4f46e5; color: #fff; }
.btn-success   { background: #16a34a; color: #fff; }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-secondary { background: #374151; color: #e2e8f0; }

.btn-sm  { font-size: 0.75rem; padding: 0.3rem 0.7rem; }
.btn-xs  { font-size: 0.7rem;  padding: 0.2rem 0.55rem; border-radius: 4px; }
.btn-full { width: 100%; margin-top: 0.5rem; padding: 0.6rem; }

/* -------------------------------------------------------------------------
   Log panel (expandable row)
   ------------------------------------------------------------------------- */

.logs-row td {
  padding: 0;
  border-bottom: 1px solid #2d3148;
}

.server-log-panel {
  background: #13151f;
  border-top: 1px solid #2d3148;
  max-height: 260px;
  overflow-y: auto;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.75rem;
}

.log-entry {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.35rem 1rem;
  border-bottom: 1px solid #1a1d2e;
  line-height: 1.4;
}

.log-entry:last-child { border-bottom: none; }

.log-ts {
  color: #4b5563;
  white-space: nowrap;
  flex-shrink: 0;
}

.log-level {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.log-lvl-info  { background: #1e2130; color: #64748b; }
.log-lvl-warn  { background: #431407; color: #fb923c; }
.log-lvl-error { background: #3b0a0a; color: #f87171; }

.log-msg { color: #cbd5e1; word-break: break-word; }

.log-loading,
.log-empty {
  padding: 0.75rem 1rem;
  color: #4b5563;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 0.8rem;
}

/* Active state for the Logs toggle button */
.btn.active {
  background: #4f46e5;
  color: #fff;
}

/* -------------------------------------------------------------------------
   Animations
   ------------------------------------------------------------------------- */

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* -------------------------------------------------------------------------
   Login page
   ------------------------------------------------------------------------- */

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #0f1117;
}

.login-card {
  background: #1a1d2e;
  border: 1px solid #2d3148;
  border-radius: 10px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
}

.login-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #a5b4fc;
  text-align: center;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  text-align: center;
  color: #64748b;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.login-error {
  background: #3b0a0a;
  border: 1px solid #7f1d1d;
  color: #fca5a5;
  font-size: 0.8rem;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: #94a3b8;
  margin-bottom: 0.3rem;
}

.field input {
  width: 100%;
  background: #0f1117;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #e2e8f0;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus { border-color: #4f46e5; }

/* -------------------------------------------------------------------------
   Logs page — server filter select + log entries
   ------------------------------------------------------------------------- */

.filter-select {
  background: #1a1d2e;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #e2e8f0;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.filter-select:focus { border-color: #4f46e5; }

.log-page-panel {
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.75rem;
}

.log-entry--page {
  border-bottom: 1px solid #1e2130;
}

.log-entry--page:last-child { border-bottom: none; }

.log-server {
  color: #64748b;
  font-size: 0.7rem;
  white-space: nowrap;
  flex-shrink: 0;
}
