:root {
  --bg-color: #0f172a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --card-bg: rgba(30, 41, 59, 0.7);
  --border: rgba(255, 255, 255, 0.1);
  
  --status-up: #10b981;
  --status-down: #ef4444;
  --status-pending: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: radial-gradient(circle at top right, #1e293b, transparent 40%),
                    radial-gradient(circle at bottom left, #0f172a, transparent 40%);
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

#app-container.container {
  max-width: 1240px;
}

.hidden {
  display: none !important;
}

/* Glassmorphism */
.glass {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.glass-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

/* Typography */
h1 { font-size: 2rem; font-weight: 700; margin-bottom: 1rem; }
h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; margin-top: 2rem;}

/* Forms & Buttons */
input {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  color: white;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.3s ease;
}

input:focus {
  border-color: var(--primary);
}

button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}

button:hover { background: var(--primary-hover); transform: translateY(-1px); }

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
}
button.secondary:hover {
  background: rgba(255,255,255,0.1);
}

button.toggle-sub {
  margin-top: 1rem;
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
}
button.toggle-sub.active {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--primary);
  color: var(--primary);
}

/* Layout */
#auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.add-monitor-card form {
  display: flex;
  gap: 1rem;
}

.grid-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ---------- Monitors Toolbar (UptimeRobot-style) ---------- */
.monitors-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.toolbar-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.toolbar-title h1 {
  font-size: 1.75rem;
  margin-bottom: 0;
}

.title-dot { color: var(--status-up); }

.status-dot-small {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot-small.up { background: var(--status-up); box-shadow: 0 0 8px rgba(16, 185, 129, 0.6); }
.status-dot-small.down { background: var(--status-down); box-shadow: 0 0 8px rgba(239, 68, 68, 0.6); }
.status-dot-small.pending { background: var(--status-pending); }

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.toolbar-spacer { width: 0.25rem; }

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: none;
}

.toolbar-btn.checkbox-btn { color: var(--text-muted); }

.toolbar-btn.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: var(--primary);
  color: #93c5fd;
}

.row-checkbox {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--text-muted);
  display: inline-block;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}

.row-checkbox.checked {
  background: var(--primary);
  border-color: var(--primary);
}

.row-checkbox.checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.toolbar-search {
  width: 220px;
  margin-bottom: 0;
  padding: 0.55rem 0.9rem;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 0.85rem;
}

.dropdown { position: relative; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 170px;
  background: #182235;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  padding: 0.4rem;
  z-index: 30;
}

.dropdown-menu.left { right: auto; left: 0; }

.dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-main);
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.dropdown-item:hover { background: rgba(255, 255, 255, 0.08); transform: none; }
.dropdown-item.danger { color: var(--status-down); }
.dropdown-item.active { color: var(--primary); }

.dropdown-item.submenu-item {
  padding-left: 1.6rem;
  font-weight: 400;
  color: var(--text-muted);
}
.dropdown-item.submenu-item:hover { color: var(--text-main); }
.dropdown-item.submenu-item.current { color: var(--primary); }

.dropdown-menu .submenu-heading {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0.5rem 0.7rem 0.2rem;
}

.dropdown-menu .submenu-divider {
  height: 1px;
  background: var(--border);
  margin: 0.3rem 0;
}

/* ---------- Manage Groups panel ---------- */
.manage-groups-menu {
  min-width: 260px;
  padding: 0.6rem;
}

.add-group-form {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.add-group-form input {
  flex: 1;
  margin-bottom: 0;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
}

.add-group-form button {
  padding: 0.5rem 0.9rem;
  font-size: 1rem;
  line-height: 1;
}

.groups-manage-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-height: 260px;
  overflow-y: auto;
}

.groups-manage-empty {
  padding: 0.5rem 0.7rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.group-manage-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.3rem 0.3rem 0.7rem;
  border-radius: 6px;
}

.group-manage-row:hover { background: rgba(255, 255, 255, 0.05); }

.group-manage-name {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main);
  font-size: 0.85rem;
  padding: 0.3rem 0.4rem;
  border-radius: 5px;
  margin-bottom: 0;
  width: auto;
}

.group-manage-name:focus { border-color: var(--primary); background: rgba(0, 0, 0, 0.2); }

.group-manage-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.group-manage-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.group-manage-delete:hover { background: rgba(239, 68, 68, 0.15); color: var(--status-down); transform: none; }

/* ---------- Grouped monitor list ---------- */
.group-section { border-bottom: 1px solid var(--border); }
.group-section:last-child { border-bottom: none; }

.group-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.25rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  user-select: none;
}

.group-header:hover { background: rgba(255, 255, 255, 0.04); }

.group-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.group-section.collapsed .group-chevron { transform: rotate(-90deg); }
.group-section.collapsed .group-rows { display: none; }

.group-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.group-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.group-summary {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.group-summary .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.group-summary .dot.up { background: var(--status-up); }
.group-summary .dot.down { background: var(--status-down); }

.monitors-list .group-header .row-menu-wrap { margin-left: 0.25rem; }

.group-rows .monitor-row { padding-left: 2.75rem; }
.group-rows .monitor-row:last-child { border-bottom: none; }

/* ---------- Monitors List (rows) ---------- */
.monitors-list {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.monitors-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

.monitor-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.monitors-list .monitor-row:last-child { border-bottom: none; }

.monitor-row:hover { background: rgba(255, 255, 255, 0.03); }

.monitor-row-checkbox { flex-shrink: 0; cursor: pointer; }

.monitor-status-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.monitor-status-icon.status-up { background: rgba(16, 185, 129, 0.18); }
.monitor-status-icon.status-down { background: rgba(239, 68, 68, 0.18); }
.monitor-status-icon.status-pending { background: rgba(245, 158, 11, 0.18); }

.monitor-status-icon svg { width: 12px; height: 12px; }
.monitor-status-icon.status-up svg { fill: var(--status-up); stroke: var(--status-up); }
.monitor-status-icon.status-down svg { fill: var(--status-down); stroke: var(--status-down); }
.monitor-status-icon.status-pending svg { fill: var(--status-pending); stroke: var(--status-pending); }

.monitor-name-block {
  flex: 0 1 320px;
  min-width: 160px;
  overflow: hidden;
}

.monitor-group-tag {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}

.group-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.group-tag svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.monitor-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.monitor-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.monitor-name:hover { color: #60a5fa; }

.monitor-sub-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.type-badge {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.monitor-uptime-text.status-down { color: var(--status-down); }
.monitor-uptime-text.status-up { color: var(--text-muted); }

.monitor-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-shrink: 0;
}

.monitor-interval-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  min-width: 190px;
}

.monitor-interval {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.monitor-interval svg { width: 12px; height: 12px; }

.bar-strip {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 26px;
  width: 100%;
}

.bar {
  flex: 1;
  min-width: 2px;
  max-width: 6px;
  height: 100%;
  border-radius: 2px 2px 1px 1px;
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  cursor: pointer;
  transition: filter 0.15s;
}

.bar:hover { filter: brightness(1.35); }

.bar.up { background: var(--status-up); }
.bar.down { background: var(--status-down); }
.bar.partial { background: var(--status-pending); }

.bar::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: #0b0f19;
  border: 1px solid var(--border);
  color: white;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 20;
}

.bar:hover::after { opacity: 1; }

.uptime-pct {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.uptime-pct.good { color: var(--status-up); }
.uptime-pct.bad { color: var(--status-down); }

.row-menu-wrap { position: relative; flex-shrink: 0; }

.row-menu-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.row-menu-btn:hover { background: rgba(255, 255, 255, 0.08); transform: none; color: white; }

.monitor-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 200px;
}

.monitor-actions .flex-row {
  display: flex;
  gap: 0.5rem;
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.status-up { background: rgba(16, 185, 129, 0.2); color: var(--status-up); }
.status-down { background: rgba(239, 68, 68, 0.2); color: var(--status-down); }
.status-pending { background: rgba(245, 158, 11, 0.2); color: var(--status-pending); }

.monitor-url {
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  word-break: break-all;
}

.monitor-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s, text-shadow 0.2s;
}

.monitor-link:hover {
  color: #60a5fa; /* A nice bright blue highlight */
  text-shadow: 0 0 8px rgba(96, 165, 250, 0.4);
}

.last-checked {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Incidents Table */
.incidents-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.incidents-table th, .incidents-table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.incidents-table th {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.incidents-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.incidents-table .status-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 0.5rem;
}

.incidents-table .status-dot.ongoing { background-color: var(--status-down); }
.incidents-table .status-dot.resolved { background-color: var(--status-up); }

.incidents-table .status-text.ongoing { color: var(--status-down); font-weight: 600; }
.incidents-table .status-text.resolved { color: var(--status-up); font-weight: 600; }

.incidents-table .root-cause-badge {
  background: var(--status-down);
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: bold;
  margin-right: 0.5rem;
}
