:root {
  --bg: #0b1220;
  --card-bg: #111827;
  --input-bg: #1f2937;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --text: #f3f4f6;
  --text-dim: #9ca3af;
  --green: #22c55e;
  --red: #ef4444;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 1000px;
  padding: 40px 20px;
}

header {
  text-align: center;
  margin-bottom: 40px;
}

header h1 {
  font-size: 2.5rem;
  margin: 0;
  background: linear-gradient(to right, #60a5fa, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

header p {
  color: var(--text-dim);
  margin-top: 10px;
}

.card {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Add Section */
.add-section {
  margin-bottom: 40px;
}

.input-group {
  display: flex;
  gap: 12px;
}

input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--input-bg);
  color: white;
  font-size: 1rem;
  transition: border-color 0.2s;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  padding: 12px 24px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  transform: scale(0.98);
}

/* API List */
.api-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.api-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform 0.2s, border-color 0.2s;
}

.api-card:hover {
  transform: translateY(-4px);
  border-color: rgba(59, 130, 246, 0.3);
}

.api-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.url {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
  line-height: 1.4;
}

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

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

.status-text.online { color: var(--green); }
.status-text.online::before { background: var(--green); box-shadow: 0 0 8px var(--green); }

.status-text.offline { color: var(--red); }
.status-text.offline::before { background: var(--red); box-shadow: 0 0 8px var(--red); }

.right {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.right button {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.right .delete {
  background: transparent;
  color: var(--red);
  padding: 8px;
}

.right .delete:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Modal */
#modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
}

#modal {
  background: var(--card-bg);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  padding: 32px;
  border-radius: 24px;
  overflow-y: auto;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}

.modal-header h2 { margin: 0; font-size: 1.5rem; word-break: break-all; }
#m-url-sub { color: var(--text-dim); font-size: 0.9rem; }

.close-modal {
  background: transparent;
  font-size: 1.5rem;
  color: var(--text-dim);
  padding: 0;
  width: 40px; height: 40px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--input-bg);
  padding: 20px;
  border-radius: 12px;
  text-align: center;
}

.stat-val { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; margin-top: 4px; }

/* Grid de Status */
.history-container h3 {
  font-size: 1rem;
  margin-bottom: 16px;
  color: var(--text-dim);
}

.bars-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10px, 1fr));
  gap: 3px;
  background: #0b1220;
  padding: 12px;
  border-radius: 8px;
}

.square {
  aspect-ratio: 1;
  border-radius: 2px;
  cursor: crosshair;
}

.square.online-1 { background: #0e4429; }
.square.online-2 { background: #006d32; }
.square.online-3 { background: #26a641; }
.square.online-4 { background: #39d353; }
.square.offline { background: var(--red); }
.square.no-data { background: #161b22; }

.time-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 8px;
}

.legend {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 24px;
  flex-wrap: wrap;
}

.legend-sq { width: 10px; height: 10px; border-radius: 2px; }

/* Tooltip */
#tooltip {
  position: fixed;
  display: none;
  background: #1f2937;
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  pointer-events: none;
  z-index: 2000;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
}

.tt-time { font-weight: bold; display: block; border-bottom: 1px solid #374151; padding-bottom: 4px; margin-bottom: 4px; }
.tt-stat { display: flex; align-items: center; gap: 8px; }
.tt-dot { width: 8px; height: 8px; border-radius: 50%; }

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .input-group { flex-direction: column; }
}
