/* Zed.dev Design System & Dark Theme for LivePing */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-main: #0c0d10;
  --bg-sidebar: #121318;
  --bg-card: #181920;
  --bg-card-hover: #1f2029;
  --bg-elevated: #242632;
  --bg-input: #15161d;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-focus: #6366f1;

  --text-primary: #f4f4f6;
  --text-secondary: #9da1b2;
  --text-muted: #65697a;

  --zed-accent: #6366f1;
  --zed-accent-hover: #4f46e5;
  --zed-accent-subtle: rgba(99, 102, 241, 0.15);

  --status-up: #10b981;
  --status-up-subtle: rgba(16, 185, 129, 0.15);
  --status-down: #f43f5e;
  --status-down-subtle: rgba(244, 63, 94, 0.15);
  --status-pending: #f59e0b;
  --status-pending-subtle: rgba(245, 158, 11, 0.15);
  --status-maintenance: #38bdf8;
  --status-maintenance-subtle: rgba(56, 189, 248, 0.15);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
  --shadow-modal: 0 20px 40px -10px rgba(0, 0, 0, 0.75);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  height: 100vh;
}

/* App Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 380px;
  min-width: 340px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #6366f1, #10b981);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.brand-icon svg {
  width: 16px;
  height: 16px;
  fill: #ffffff;
}

.brand-text {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-badge {
  font-size: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--zed-accent);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 600;
  text-transform: uppercase;
}

.sidebar-controls {
  padding: 14px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 12px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 8px 36px 8px 34px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--zed-accent-subtle);
}

.search-kbd {
  position: absolute;
  right: 10px;
  font-size: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}

/* Filter Tabs */
.filter-tabs {
  display: flex;
  background: var(--bg-card);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.filter-tab {
  flex: 1;
  text-align: center;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
  user-select: none;
}

.filter-tab.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.filter-tab:hover:not(.active) {
  color: var(--text-secondary);
}

/* Monitor List in Sidebar */
.monitor-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.monitor-item {
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.15s ease;
}

.monitor-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-subtle);
}

.monitor-item.active {
  background: var(--bg-card);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-card);
}

.monitor-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.monitor-item-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  position: relative;
}

.status-dot.up {
  background-color: var(--status-up);
  box-shadow: 0 0 8px var(--status-up);
}

.status-dot.down {
  background-color: var(--status-down);
  box-shadow: 0 0 8px var(--status-down);
}

.status-dot.pending {
  background-color: var(--status-pending);
}

.status-dot.maintenance {
  background-color: var(--status-maintenance);
}

.status-dot.paused {
  background-color: var(--text-muted);
}

.monitor-item-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* Micro Heartbeat Preview Bars */
.beat-mini-bar {
  display: flex;
  gap: 2px;
  align-items: center;
  height: 12px;
  overflow: hidden;
}

.beat-mini-pill {
  width: 4px;
  height: 100%;
  border-radius: 1px;
  background-color: var(--border-subtle);
  transition: height 0.15s ease;
}

.beat-mini-pill.up { background-color: var(--status-up); }
.beat-mini-pill.down { background-color: var(--status-down); }
.beat-mini-pill.pending { background-color: var(--status-pending); }
.beat-mini-pill.maintenance { background-color: var(--status-maintenance); }

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-main);
  overflow-y: auto;
}

.top-navbar {
  padding: 12px 28px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(18, 19, 24, 0.7);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.nav-breadcrumbs .current {
  color: var(--text-primary);
  font-weight: 600;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  text-decoration: none;
  font-family: var(--font-sans);
}

.btn-primary {
  background: var(--zed-accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--zed-accent-hover);
  box-shadow: 0 0 15px var(--zed-accent-subtle);
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: var(--status-down-subtle);
  border-color: rgba(244, 63, 94, 0.3);
  color: var(--status-down);
}

.btn-danger:hover {
  background: var(--status-down);
  color: #ffffff;
}

.btn-icon {
  padding: 7px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* Detail View */
.content-body {
  padding: 28px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

/* Header Banner of Monitor Detail */
.monitor-hero {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
}

.monitor-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--status-up);
}

.monitor-hero.down::before {
  background: var(--status-down);
}

.hero-info h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-subtitle {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font-mono);
}

.hero-tag {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-secondary);
}

.hero-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero-status-pill.up {
  background: var(--status-up-subtle);
  color: var(--status-up);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.hero-status-pill.down {
  background: var(--status-down-subtle);
  color: var(--status-down);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.hero-status-pill.pending {
  background: var(--status-pending-subtle);
  color: var(--status-pending);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.hero-status-pill.paused {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

/* Stat Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.stat-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.stat-footer {
  font-size: 11px;
  color: var(--text-muted);
}

/* Heartbeat Bar Section (Iconic Uptime Kuma 60-beats) */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}

/* Interactive Timeline Bar */
.heartbeat-timeline {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  height: 48px;
  padding: 6px 0;
  position: relative;
}

.heartbeat-bar {
  flex: 1;
  height: 100%;
  border-radius: var(--radius-sm);
  background: var(--border-subtle);
  transition: transform 0.15s ease, opacity 0.15s ease;
  position: relative;
  cursor: pointer;
}

.heartbeat-bar:hover {
  transform: scaleY(1.15);
  opacity: 0.9;
  z-index: 5;
}

.heartbeat-bar.up {
  background: var(--status-up);
}

.heartbeat-bar.down {
  background: var(--status-down);
}

.heartbeat-bar.pending {
  background: var(--status-pending);
}

.heartbeat-bar.maintenance {
  background: var(--status-maintenance);
}

.timeline-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Latency Canvas Graph */
.chart-container {
  height: 220px;
  width: 100%;
  position: relative;
}

canvas#pingChart {
  width: 100%;
  height: 100%;
}

/* Tooltip Popup */
.bar-tooltip {
  position: absolute;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 11px;
  pointer-events: none;
  z-index: 100;
  box-shadow: var(--shadow-modal);
  white-space: nowrap;
  display: none;
  flex-direction: column;
  gap: 4px;
}

/* SSL & Cert Card */
.cert-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-top: 14px;
}

.cert-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cert-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--status-up-subtle);
  color: var(--status-up);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cert-days {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
  color: var(--status-up);
}

/* Event Logs Table */
.logs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.logs-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.logs-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-sans);
}

.logs-table tr:hover td {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.logs-table .status-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-sidebar);
}

/* Form Groups */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--zed-accent);
  box-shadow: 0 0 0 2px var(--zed-accent-subtle);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.form-help {
  font-size: 11px;
  color: var(--text-muted);
}

/* Pulse Animation for Live sync */
@keyframes livePulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--status-up);
  font-family: var(--font-mono);
}

.live-dot {
  width: 7px;
  height: 7px;
  background: var(--status-up);
  border-radius: var(--radius-full);
  animation: livePulse 2s infinite ease-in-out;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}


/* Bottom-Left Action Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  max-width: 380px;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-left: 3px solid var(--zed-accent);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-modal);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.4;
  min-width: 260px;
  animation: toastSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-item.success {
  border-left-color: var(--status-up);
}

.toast-item.error {
  border-left-color: var(--status-down);
}

.toast-item.warning {
  border-left-color: var(--status-pending);
}

.toast-item.info {
  border-left-color: var(--zed-accent);
}

.toast-icon {
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-item.success .toast-icon { color: var(--status-up); }
.toast-item.error .toast-icon { color: var(--status-down); }
.toast-item.warning .toast-icon { color: var(--status-pending); }
.toast-item.info .toast-icon { color: var(--zed-accent); }

.toast-body {
  flex: 1;
  word-break: break-word;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

.toast-close:hover {
  color: var(--text-primary);
}

.toast-item.closing {
  opacity: 0;
  transform: translateX(-18px);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
