/**
 * DownDetector Professional v4.1 — Bootstrap 5 Dark Theme
 * Overrides Bootstrap tokens e define componentes customizados.
 */

/* ─── Paleta de cores da marca ───────────────────────────── */
:root,
[data-bs-theme="dark"] {
  --dd-primary:       #2563eb;
  --dd-sidebar-width: 270px;
  --dd-sidebar-bg:    #0f172a;
  --dd-surface:       #1e293b;
  --dd-surface-2:     #334155;
  --dd-border:        #334155;

  /* Sobrescreve tokens Bootstrap */
  --bs-body-bg:           #1e293b;
  --bs-body-color:        #f1f5f9;
  --bs-border-color:      #334155;
  --bs-card-bg:           #1e293b;
  --bs-card-border-color: #334155;
  --bs-primary:           #2563eb;
  --bs-primary-rgb:       37, 99, 235;
  --bs-secondary-rgb:     100, 116, 139;
  --bs-table-bg:          transparent;
  --bs-table-border-color:#334155;
}

/* ─── Body / Layout base ─────────────────────────────────── */
body {
  background: var(--bs-body-bg);
  min-height: 100vh;
}

/* ─── Sidebar desktop ────────────────────────────────────── */
.dd-sidebar {
  width: var(--dd-sidebar-width);
  min-height: 100vh;
  background: var(--dd-sidebar-bg);
  border-right: 1px solid var(--dd-border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 1000;
}

/* Scrollbar fina na sidebar */
.dd-sidebar::-webkit-scrollbar        { width: 4px; }
.dd-sidebar::-webkit-scrollbar-thumb  { background: var(--dd-border); border-radius: 2px; }
.dd-sidebar::-webkit-scrollbar-track  { background: transparent; }

/* ─── Main content offset ────────────────────────────────── */
.dd-main-wrapper {
  margin-left: var(--dd-sidebar-width);
  min-height: 100vh;
}

/* Mobile: sem offset — sidebar é offcanvas */
@media (max-width: 991.98px) {
  .dd-main-wrapper { margin-left: 0; }
}

/* ─── Sidebar nav links ──────────────────────────────────── */
.dd-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 8px;
  margin: 2px 8px;
  transition: background 0.15s, color 0.15s;
  font-size: 0.9rem;
}

.dd-nav-link:hover {
  background: rgba(37, 99, 235, 0.12);
  color: #e2e8f0;
}

.dd-nav-link.active {
  background: rgba(37, 99, 235, 0.2);
  color: #60a5fa;
  font-weight: 500;
}

.dd-nav-link .bi {
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ─── Status dot na sidebar ──────────────────────────────── */
.dd-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--dd-surface-2);
  border: 1px solid var(--dd-border);
  border-radius: 12px;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--dd-border);
  padding: 1rem 1.25rem;
}

/* ─── Stat cards ─────────────────────────────────────────── */
.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-value {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1;
}

/* ─── Tables ─────────────────────────────────────────────── */
.table {
  --bs-table-hover-bg: rgba(37, 99, 235, 0.08);
  --bs-table-striped-bg: rgba(255,255,255,0.02);
}

.table > thead > tr > th {
  background: var(--dd-sidebar-bg);
  border-bottom: 1px solid var(--dd-border);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  white-space: nowrap;
}

.table > tbody > tr:last-child > td { border-bottom: 0; }

.table-responsive { border-radius: 0 0 12px 12px; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-control,
.form-select {
  background-color: var(--dd-surface);
  border-color: var(--dd-border);
  color: #f1f5f9;
}

.form-control:focus,
.form-select:focus {
  background-color: var(--dd-surface);
  border-color: var(--dd-primary);
  color: #f1f5f9;
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25);
}

.form-control::placeholder { color: #64748b; }

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--bs-danger);
}

/* Input groups */
.input-group-text {
  background-color: var(--dd-surface);
  border-color: var(--dd-border);
  color: #64748b;
}

/* ─── Modals ─────────────────────────────────────────────── */
.modal-content {
  background: var(--dd-surface-2);
  border: 1px solid var(--dd-border);
}

.modal-header,
.modal-footer {
  border-color: var(--dd-border);
}

/* ─── Offcanvas (sidebar mobile) ─────────────────────────── */
.offcanvas {
  background: var(--dd-sidebar-bg);
  border-right: 1px solid var(--dd-border);
}

.offcanvas-header { border-bottom: 1px solid var(--dd-border); }

/* ─── Botões ─────────────────────────────────────────────── */
.btn { font-weight: 500; border-radius: 8px; }

.btn-outline-secondary {
  --bs-btn-color: #94a3b8;
  --bs-btn-border-color: #475569;
  --bs-btn-hover-bg: #334155;
  --bs-btn-hover-color: #f1f5f9;
  --bs-btn-hover-border-color: #475569;
}

/* ─── Badges ─────────────────────────────────────────────── */
.badge { font-weight: 500; border-radius: 6px; }

/* ─── Pagination ─────────────────────────────────────────── */
.page-link {
  background: var(--dd-surface-2);
  border-color: var(--dd-border);
  color: #94a3b8;
}

.page-link:hover {
  background: var(--dd-surface);
  border-color: var(--bs-primary);
  color: #f1f5f9;
}

.page-item.active .page-link {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
}

.page-item.disabled .page-link { background: var(--dd-surface-2); }

/* ─── Accordion ──────────────────────────────────────────── */
.accordion-item {
  background: var(--dd-surface-2);
  border: 1px solid var(--dd-border);
  border-radius: 10px !important;
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.accordion-button {
  background: var(--dd-surface-2);
  color: #f1f5f9;
  font-weight: 600;
}

.accordion-button:not(.collapsed) {
  background: rgba(37, 99, 235, 0.12);
  color: #60a5fa;
  box-shadow: none;
}

.accordion-button::after {
  filter: invert(1) brightness(0.8);
}

.accordion-body { background: var(--dd-surface); }

/* ─── Log viewer ─────────────────────────────────────────── */
.log-viewer {
  background: #0d1117;
  border-radius: 8px;
  padding: 1rem;
  max-height: 680px;
  overflow-y: auto;
  font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
}

.log-viewer::-webkit-scrollbar        { width: 6px; }
.log-viewer::-webkit-scrollbar-thumb  { background: #334155; border-radius: 3px; }

.log-line {
  padding: 2px 0.5rem;
  border-radius: 3px;
  border-left: 3px solid transparent;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line-error    { color: #f87171; border-left-color: rgba(248,113,113,0.4); background: rgba(248,113,113,0.05); }
.log-line-warning  { color: #fbbf24; border-left-color: rgba(251,191,36,0.4);  background: rgba(251,191,36,0.05);  }
.log-line-info     { color: #6ee7b7; border-left-color: rgba(110,231,183,0.3); background: rgba(110,231,183,0.03); }
.log-line-debug    { color: #93c5fd; border-left-color: rgba(147,197,253,0.2); }
.log-line-default  { color: #94a3b8; }

/* ─── Health check badges ────────────────────────────────── */
.health-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
}

/* ─── Spinner no botão de refresh ───────────────────────── */
@keyframes dd-spin { to { transform: rotate(360deg); } }
.dd-spin { animation: dd-spin 0.8s linear infinite; display: inline-block; }

/* ─── Animação de entrada da página ─────────────────────── */
.dd-main-wrapper .main-content {
  animation: ddFadeIn 0.2s ease;
}

@keyframes ddFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Proxy type badges ──────────────────────────────────── */
.proxy-badge-http   { background: rgba(37,99,235,0.2);   color: #93c5fd; }
.proxy-badge-socks4 { background: rgba(245,158,11,0.2);  color: #fcd34d; }
.proxy-badge-socks5 { background: rgba(139,92,246,0.2);  color: #c4b5fd; }
.proxy-badge-all    { background: rgba(16,185,129,0.2);  color: #6ee7b7; }
