/* Free API Monitor — Styles Redesign */
:root {
  --bg: #070b16;
  --surface: #0d1527;
  --surface2: #16223b;
  --text: #f3f4f6;
  --muted: #8493b2;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --green: #34d399;
  --red: #f87171;
  --orange: #fbbf24;
  --border: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(96, 165, 250, 0.4);
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 4px 30px rgba(0, 0, 0, 0.35);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 24px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
  font-weight: 500;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

button {
  background: var(--accent);
  color: #070b16;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(96, 165, 250, 0.25);
}
button:active {
  transform: translateY(0);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* PIN gate */
#pin-gate {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #0e1b35 0%, #070b16 100%);
  z-index: 1000;
}
.pin-box {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 48px;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 360px;
}
.pin-box h1 {
  font-size: 56px;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 10px rgba(96, 165, 250, 0.3));
}
.pin-box input {
  display: block;
  width: 100%;
  margin: 24px 0 16px 0;
  padding: 14px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 18px;
  text-align: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}
.pin-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}
.pin-box button {
  width: 100%;
  padding: 12px;
  font-size: 16px;
}
.pin-box #pin-error {
  color: var(--red);
  font-size: 14px;
  margin-top: 12px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 16px;
}
header h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
header .header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
}
header button {
  background: var(--surface2);
  color: var(--text);
  padding: 8px;
  width: 36px;
  height: 36px;
  font-size: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
}
header button:hover {
  transform: rotate(30deg);
  background: var(--surface2);
  border-color: var(--accent);
  box-shadow: none;
}

/* Cards Grid */
.card-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease;
}
.card:hover {
  border-color: rgba(255, 255, 255, 0.1);
}
.card-wide {
  width: 100%;
  margin-bottom: 20px;
}
.card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}
.stat-row:last-of-type {
  border-bottom: none;
}
.stat-row span:last-child {
  font-weight: 600;
}

/* Custom Switch Toggle */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  padding: 6px 0;
  color: var(--text);
  cursor: pointer;
}
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--surface2);
  border: 1px solid var(--border);
  transition: 0.2s ease;
  border-radius: 20px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: var(--muted);
  transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
}
input:checked + .slider {
  background-color: rgba(96, 165, 250, 0.2);
  border-color: var(--accent);
}
input:checked + .slider:before {
  transform: translateX(18px);
  background-color: var(--accent);
}

.save-btn {
  margin-top: 12px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 13px;
}
.save-btn:hover {
  background: var(--accent);
  color: #070b16;
  border-color: var(--accent);
}

.runtime-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  font-weight: 500;
}

/* Status indicators */
.status-indicator {
  font-weight: 800;
  font-size: 18px;
  display: block;
  margin-bottom: 6px;
}
.status-up { color: var(--green); text-shadow: 0 0 10px rgba(52, 211, 153, 0.2); }
.status-down { color: var(--red); text-shadow: 0 0 10px rgba(248, 113, 113, 0.2); }
.status-error { color: var(--orange); text-shadow: 0 0 10px rgba(251, 191, 36, 0.2); }

/* Badges */
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface2);
  display: inline-block;
}
.badge-ok {
  background: rgba(52, 211, 153, 0.1);
  color: var(--green);
  border: 1px solid rgba(52, 211, 153, 0.2);
}
.badge-fail {
  background: rgba(248, 113, 113, 0.1);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.2);
}
.badge-cool {
  background: rgba(251, 191, 36, 0.1);
  color: var(--orange);
  border: 1px solid rgba(251, 191, 36, 0.2);
}
.cooldown-row {
  background: rgba(251, 191, 36, 0.02);
}
.status-code {
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font-mono);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: rgba(255, 255, 255, 0.015);
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
tbody tr {
  transition: background-color 0.15s ease;
}
tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.015);
}
tbody tr:last-child td {
  border-bottom: none;
}
td code {
  color: var(--orange);
  font-size: 12px;
  font-family: var(--font-mono);
  background: rgba(251, 191, 36, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(251, 191, 36, 0.15);
}
.err {
  display: block;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}
.pager button {
  padding: 6px 14px;
  font-size: 12px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.pager button:hover {
  background: var(--accent);
  color: #070b16;
  border-color: var(--accent);
}

.ok-text { color: var(--green); }
.fail-text { color: var(--red); }
.warn-text { color: var(--orange); }

/* Provider pills */
.provider-flex {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.provider-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
}
.has-key {
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.05);
}
.no-key {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.05);
  color: var(--red);
}

/* Attempt pills */
.attempt {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin: 0 2px;
}

/* Bar chart progress bars */
.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
  font-size: 13px;
}
.bar-row span {
  width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-row b {
  width: 40px;
  text-align: right;
  font-family: var(--font-mono);
}
.bar {
  flex: 1;
  height: 8px;
  background: var(--surface2);
  border-radius: 100px;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #a78bfa 100%);
  border-radius: 100px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
/* Split Card Grid */
.card-split-grid {
  display: flex;
  gap: 20px;
}
.card-split-col {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.card-split-col:last-child {
  border-left: 1px solid var(--border);
  padding-left: 20px;
}
.card-split-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.health-flex {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
}

/* Responsive Grid Adjustments */
@media (max-width: 768px) {
  .card-split-grid {
    flex-direction: column;
    gap: 16px;
  }
  .card-split-col:last-child {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--border);
    padding-top: 16px;
  }
  body {
    padding: 16px;
  }
  .card-row {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
  header h1 {
    font-size: 20px;
  }
}
