/* ═══════════════════════════════════════════
   latency-monitor.css — Performance Monitor Styling
   ═══════════════════════════════════════════ */

/* Floating Button */
.latency-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1.5px solid rgba(59, 130, 246, 0.4);
  color: #3b82f6;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.latency-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 24px rgba(59, 130, 246, 0.3);
  border-color: #3b82f6;
  color: #60a5fa;
}

.latency-btn svg {
  width: 24px;
  height: 24px;
  transition: transform 0.3s ease;
}

.latency-btn:hover svg {
  transform: rotate(15deg);
}

/* Slide-out Panel */
.latency-panel {
  position: fixed;
  top: 0;
  right: -390px;
  width: 380px;
  height: 100vh;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  color: #e2e8f0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.latency-panel.open {
  right: 0;
}

/* Panel Header */
.latency-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.latency-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #60a5fa;
  margin: 0;
}

.latency-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.latency-close:hover {
  color: #f1f5f9;
}

/* Panel Body */
.latency-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.latency-summary {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 20px;
  font-size: 13px;
}

.latency-summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.latency-summary-row:last-child {
  margin-bottom: 0;
}

.latency-summary-label {
  color: #94a3b8;
}

.latency-summary-val {
  font-weight: 600;
  color: #f8fafc;
}

/* Logs List */
.latency-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.latency-item {
  background: rgba(30, 41, 59, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.latency-item:hover {
  background: rgba(30, 41, 59, 0.5);
  border-color: rgba(96, 165, 250, 0.3);
}

.latency-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.latency-item-meta {
  font-size: 12px;
  font-weight: 600;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.latency-item-method {
  font-size: 10px;
  font-family: monospace;
  padding: 2px 4px;
  border-radius: 4px;
  margin-right: 4px;
}

.latency-item-method.GET { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.latency-item-method.POST { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.latency-item-method.PUT { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.latency-item-method.DELETE { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.latency-item-method.PATCH { background: rgba(139, 92, 246, 0.2); color: #a78bfa; }

.latency-item-total {
  font-size: 13px;
  font-weight: 700;
  color: #60a5fa;
  font-family: monospace;
}

.latency-item-initiator {
  font-size: 10px;
  color: #94a3b8;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Stacked Timing Bar */
.latency-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  margin-bottom: 6px;
}

.latency-bar-seg {
  height: 100%;
  transition: width 0.3s ease;
}

/* Expanded Details */
.latency-details {
  margin-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  padding-top: 10px;
  display: none;
}

.latency-item.expanded .latency-details {
  display: block;
}

.latency-details-table {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
}

.latency-details-table td {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.latency-details-table tr:last-child td {
  border-bottom: none;
}

.latency-details-key {
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.latency-details-val {
  text-align: right;
  font-weight: 600;
  font-family: monospace;
}

/* Color Legend & Specific Segments */
.dot-fe-pre { background-color: #8b5cf6; }
.dot-net { background-color: #3b82f6; }
.dot-app { background-color: #f59e0b; }
.dot-cache { background-color: #10b981; }
.dot-db { background-color: #ef4444; }
.dot-fe-post { background-color: #06b6d4; }

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Responsive sidebar */
@media (max-width: 480px) {
  .latency-panel {
    width: 100%;
    right: -100%;
  }
}
