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

/* === Design Tokens === */
:root {
  --deep-navy: #0A0E1A;
  --navy-light: #1E293B;
  --monitor-green: #00E5A0;
  --alert-red: #FF4D6D;
  --ghost-white: #F8FAFC;
  --slate: #64748B;
  --border: #334155;
  --orange: #F59E0B;

  --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 960px;
}

/* === Base === */
html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--deep-navy);
  color: var(--ghost-white);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

a { color: var(--monitor-green); text-decoration: none; }
a:hover { opacity: 0.85; }

:focus-visible {
  outline: 2px solid var(--monitor-green);
  outline-offset: 2px;
}

/* === Auth Pages === */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
  font-weight: 700;
  color: var(--ghost-white);
  margin-bottom: 8px;
}

.auth-logo img { border-radius: 10px; }
.green { color: var(--monitor-green); }

.auth-subtitle {
  color: var(--slate);
  font-size: 14px;
  margin-bottom: 32px;
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--slate);
  margin-top: 24px;
}

/* === Forms === */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate);
  margin-bottom: 6px;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--deep-navy);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ghost-white);
  font-family: var(--font);
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--monitor-green);
  outline: none;
}

.form-group input::placeholder { color: var(--slate); opacity: 0.6; }

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--slate);
  margin-top: 4px;
}

.optional { color: var(--slate); font-weight: 400; }

.form-error {
  color: var(--alert-red);
  font-size: 13px;
  margin-bottom: 16px;
  min-height: 20px;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s, opacity 0.2s;
  min-height: 44px;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--monitor-green);
  color: var(--deep-navy);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 0 20px rgba(0, 229, 160, 0.25);
}

.btn-secondary {
  background: var(--navy-light);
  color: var(--ghost-white);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--slate); }

.btn-danger {
  background: rgba(255, 77, 109, 0.1);
  color: var(--alert-red);
  border: 1px solid rgba(255, 77, 109, 0.3);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(255, 77, 109, 0.2);
}

.btn-full { width: 100%; }

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  min-height: 36px;
}

.btn-icon {
  padding: 6px;
  min-height: 36px;
  min-width: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--slate);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { border-color: var(--slate); color: var(--ghost-white); }

/* === Topbar === */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--ghost-white);
}

.topbar-logo img { border-radius: 6px; }

.topbar-nav {
  display: flex;
  gap: 4px;
}

.topbar-link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--slate);
  transition: background 0.15s, color 0.15s;
}
.topbar-link:hover { color: var(--ghost-white); background: var(--navy-light); opacity: 1; }
.topbar-link.active { color: var(--ghost-white); background: var(--navy-light); }

.topbar-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--ghost-white);
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.topbar-mobile-nav {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 8px 24px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--deep-navy);
}
.topbar-mobile-nav.open { display: flex; }

/* === Main Content === */
.main-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px;
}

/* === Dashboard === */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.dashboard-header h1 {
  font-size: 24px;
  font-weight: 700;
}

.monitor-count {
  color: var(--slate);
  font-size: 13px;
  margin-top: 2px;
}

/* === Monitor List === */
.monitors-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.monitor-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.monitor-row:hover {
  border-color: var(--monitor-green);
  transform: translateX(2px);
}

.monitor-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.monitor-dot.up { background: var(--monitor-green); box-shadow: 0 0 8px rgba(0, 229, 160, 0.4); }
.monitor-dot.down { background: var(--alert-red); box-shadow: 0 0 8px rgba(255, 77, 109, 0.4); }
.monitor-dot.pending { background: var(--slate); }

.monitor-info {
  flex: 1;
  min-width: 0;
}

.monitor-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.monitor-url {
  font-size: 12px;
  color: var(--slate);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.monitor-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.monitor-status {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
}
.monitor-status.up { color: var(--monitor-green); background: rgba(0, 229, 160, 0.1); }
.monitor-status.down { color: var(--alert-red); background: rgba(255, 77, 109, 0.1); }
.monitor-status.pending { color: var(--slate); background: rgba(100, 116, 139, 0.15); }
.monitor-status.paused { color: var(--orange); background: rgba(245, 158, 11, 0.1); }

.monitor-response {
  font-size: 12px;
  color: var(--slate);
  font-variant-numeric: tabular-nums;
  min-width: 50px;
  text-align: right;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--slate);
}
.empty-state h3 {
  margin: 16px 0 8px;
  color: var(--ghost-white);
  font-size: 18px;
}
.empty-state p { font-size: 14px; }

/* === Detail Page === */
.detail-back {
  margin-bottom: 24px;
}
.detail-back a {
  font-size: 14px;
  color: var(--slate);
}
.detail-back a:hover { color: var(--monitor-green); }

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
  flex-wrap: wrap;
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-title-row h1 {
  font-size: 22px;
  font-weight: 700;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-status {
  font-size: 16px;
  font-weight: 700;
}

.detail-last-check {
  font-size: 13px;
  color: var(--slate);
  margin-top: 4px;
}

/* === Cards === */
.card {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

/* === Uptime Grid === */
.uptime-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.uptime-stat {
  text-align: center;
  padding: 16px 8px;
  background: var(--deep-navy);
  border-radius: var(--radius-sm);
}

.uptime-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--monitor-green);
}

.uptime-label {
  font-size: 11px;
  color: var(--slate);
  margin-top: 4px;
}

/* === Checks List === */
.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
  font-size: 13px;
}
.check-row:last-child { border-bottom: none; }

.check-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.check-dot.up { background: var(--monitor-green); }
.check-dot.down { background: var(--alert-red); }

.check-code {
  font-family: 'SF Mono', 'Consolas', monospace;
  color: var(--slate);
  min-width: 32px;
}

.check-time {
  font-family: 'SF Mono', 'Consolas', monospace;
  color: var(--slate);
  min-width: 50px;
}

.check-date {
  margin-left: auto;
  color: var(--slate);
  font-size: 12px;
}

/* === Incidents === */
.incident-row {
  padding: 12px 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
}
.incident-row:last-child { border-bottom: none; }

.incident-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.incident-icon { font-size: 14px; }
.incident-icon.resolved { color: var(--monitor-green); }
.incident-icon.ongoing { color: var(--alert-red); }

.incident-date {
  font-size: 13px;
  font-weight: 500;
}

.incident-duration {
  margin-left: auto;
  font-size: 12px;
  color: var(--slate);
}

.incident-cause {
  font-size: 12px;
  color: var(--slate);
  margin-left: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === Info Row (URL, interval) === */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
  font-size: 14px;
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--slate); }
.info-value {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
  text-align: right;
}

/* === Settings === */
.settings-grid {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
  font-size: 14px;
}
.settings-row:last-child { border-bottom: none; }
.settings-label { color: var(--slate); }

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  animation: modalIn 0.2s ease-out;
}

.modal-sm { max-width: 380px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--slate);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.modal-close:hover { color: var(--ghost-white); }

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* === Loading === */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--monitor-green);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-center {
  display: flex;
  justify-content: center;
  padding: 48px;
}

/* === Admin === */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.admin-stat-card {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.admin-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--monitor-green);
}

.admin-stat-label {
  font-size: 12px;
  color: var(--slate);
  margin-top: 4px;
}

.admin-user-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
  cursor: pointer;
  transition: background 0.1s;
}
.admin-user-row:last-child { border-bottom: none; }
.admin-user-row:hover { background: rgba(0, 229, 160, 0.03); }

.admin-user-info { flex: 1; min-width: 0; }
.admin-user-name { font-size: 14px; font-weight: 600; }
.admin-user-email { font-size: 12px; color: var(--slate); }

.admin-user-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.admin-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.admin-badge.free { color: var(--slate); background: rgba(100,116,139,0.15); }
.admin-badge.pro { color: var(--monitor-green); background: rgba(0,229,160,0.1); }
.admin-badge.business { color: var(--orange); background: rgba(245,158,11,0.1); }
.admin-badge.admin { color: var(--alert-red); background: rgba(255,77,109,0.1); }

.admin-monitor-count {
  font-size: 12px;
  color: var(--slate);
  min-width: 60px;
  text-align: right;
}

.admin-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.admin-detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-select {
  padding: 6px 12px;
  background: var(--deep-navy);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ghost-white);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
}
.admin-select:focus { border-color: var(--monitor-green); outline: none; }

/* === Responsive === */
@media (max-width: 640px) {
  .topbar-nav { display: none; }
  .topbar-menu-toggle { display: flex; }

  .dashboard-header { flex-direction: column; align-items: stretch; }
  .dashboard-header h1 { font-size: 20px; }

  .monitor-row { padding: 14px 16px; gap: 12px; }
  .monitor-meta { gap: 8px; }
  .monitor-response { display: none; }

  .uptime-grid { grid-template-columns: repeat(2, 1fr); }

  .detail-header { flex-direction: column; align-items: flex-start; }

  .main-content { padding: 24px 16px; }
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
