/* NetPulse Sentinel - Premium Dark-Tech Design System */

:root {
  --bg-base: #0a0e17;
  --bg-surface: #111827;
  --bg-card: #162032;
  --bg-card-hover: #1b283f;
  --bg-input: #1a2538;
  --border-color: #223048;
  --border-light: #2d3f5e;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --cyan: #06b6d4;
  --cyan-dim: rgba(6, 182, 212, 0.15);
  --purple: #8b5cf6;
  --purple-dim: rgba(139, 92, 246, 0.15);
  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --yellow: #f59e0b;
  --yellow-dim: rgba(245, 158, 11, 0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.15);

  --sidebar-width: 250px;
  --header-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.35);
  --transition: 0.18s ease-in-out;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* App Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition), width var(--transition);
}

.brand {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--cyan-dim), var(--purple-dim));
  border: 1px solid var(--cyan);
  border-radius: var(--radius-sm);
  color: var(--cyan);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
}

.brand-subtitle {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--cyan);
  font-weight: 600;
  display: block;
}

.nav-links {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item:hover {
  color: #fff;
  background-color: var(--bg-card);
  border-color: var(--border-color);
}

.nav-item.active {
  color: #fff;
  background-color: var(--bg-card);
  border-color: var(--cyan);
  box-shadow: inset 3px 0 0 var(--cyan);
}

.nav-badge {
  margin-left: auto;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 12px;
  background-color: var(--cyan-dim);
  color: var(--cyan);
  font-weight: 600;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--purple-dim);
  border: 1px solid var(--purple);
  color: var(--purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--text-dim);
}

/* Main Content Area */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.pulse-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.pulse-dot.running {
  background-color: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: pulse-ring 1.5s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Content Container */
.content-container {
  padding: 24px 28px 40px;
  flex: 1;
}

/* Tab Panes */
.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

/* Metric Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), border-color var(--transition);
}

.metric-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
}
.metric-card.accent-cyan::before { background: var(--cyan); }
.metric-card.accent-green::before { background: var(--green); }
.metric-card.accent-red::before { background: var(--red); }
.metric-card.accent-purple::before { background: var(--purple); }

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-value {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.metric-footer {
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Card Component */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

/* Action Bars / Controls */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.action-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Inputs & Form Controls */
.input-field, .select-field {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--transition);
}

.input-field:focus, .select-field:focus {
  border-color: var(--cyan);
}

.input-field::placeholder {
  color: var(--text-dim);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

.search-box input {
  padding-left: 34px;
  min-width: 220px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn-primary {
  background-color: var(--cyan);
  color: #0b1120;
}
.btn-primary:hover {
  background-color: #0891b2;
}

.btn-accent {
  background-color: var(--purple);
  color: #fff;
}
.btn-accent:hover {
  background-color: #7c3aed;
}

.btn-secondary {
  background-color: var(--bg-input);
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  border-color: var(--border-light);
  background-color: var(--bg-card-hover);
}

.btn-danger {
  background-color: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}
.btn-danger:hover {
  background-color: var(--red);
  color: #fff;
}

.btn-sm {
  padding: 4px 9px;
  font-size: 12px;
}

.btn-icon {
  padding: 6px;
  border-radius: var(--radius-sm);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Data Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  padding: 12px 14px;
  background-color: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.data-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.badge-ok {
  background-color: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-connect_error, .badge-target_error {
  background-color: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-auth_failed {
  background-color: var(--purple-dim);
  color: var(--purple);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.badge-timeout {
  background-color: var(--yellow-dim);
  color: var(--yellow);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-tls_error {
  background-color: rgba(249, 115, 22, 0.15);
  color: #f97316;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.badge-ssrf_blocked {
  background-color: rgba(225, 29, 72, 0.15);
  color: #f43f5e;
  border: 1px solid rgba(225, 29, 72, 0.3);
}

.badge-unchecked {
  background-color: rgba(156, 163, 175, 0.15);
  color: #9ca3af;
  border: 1px solid rgba(156, 163, 175, 0.3);
}

.badge-http_status {
  background-color: var(--blue-dim);
  color: var(--blue);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  font-size: 13px;
  color: var(--text-muted);
}

.page-buttons {
  display: flex;
  gap: 6px;
}

/* Free Fire Diagnostics UI */
.diagnostic-banner {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(139, 92, 246, 0.1));
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin-bottom: 24px;
}

.diagnostic-banner-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.diagnostic-banner-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.diagnostic-disclaimer {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background-color: rgba(239, 68, 68, 0.08);
  border-left: 3px solid var(--red);
  font-size: 12px;
  color: #fca5a5;
  line-height: 1.5;
}

.diag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.diag-metric-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.diag-metric-box .label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.diag-metric-box .value {
  font-size: 22px;
  font-weight: 700;
  color: var(--cyan);
  margin-top: 4px;
}

.grade-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.grade-A { background: var(--green-dim); color: var(--green); border: 1px solid var(--green); }
.grade-B { background: var(--cyan-dim); color: var(--cyan); border: 1px solid var(--cyan); }
.grade-C { background: var(--yellow-dim); color: var(--yellow); border: 1px solid var(--yellow); }
.grade-D { background: var(--red-dim); color: var(--red); border: 1px solid var(--red); }
.grade-F { background: var(--red-dim); color: #fff; border: 1px solid var(--red); }

/* Optimization Checklist */
.checklist-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
}

.checklist-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--cyan-dim);
  color: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.checklist-content h4 {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.checklist-content p {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: modal-enter 0.2s ease-out;
}

@keyframes modal-enter {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
}
.modal-close:hover {
  color: #fff;
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background-color: rgba(0, 0, 0, 0.15);
}

/* Form Groups */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-help {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.toast {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.25s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.toast-success { border-left: 4px solid var(--green); }
.toast.toast-error { border-left: 4px solid var(--red); }
.toast.toast-warning { border-left: 4px solid var(--yellow); }
.toast.toast-info { border-left: 4px solid var(--cyan); }

.toast-message {
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.4;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--border-color) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  width: 80%;
}
.skeleton-row {
  height: 38px;
  margin-bottom: 10px;
}

/* Empty States */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
}
.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.empty-state p {
  font-size: 13.5px;
}

/* Mobile Responsiveness */
@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .content-container {
    padding: 16px;
  }
  .top-header {
    padding: 0 16px;
  }
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .action-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box input {
    min-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
