/* ==========================================================
   CoorpDNS - Enterprise Dark Aesthetic Design System
   ========================================================== */

:root {
  --bg-main: #0a0d14;
  --bg-sidebar: #0f1422;
  --bg-card: #151b2d;
  --bg-card-hover: #1b233a;
  --bg-input: #101626;

  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-focus: #3b82f6;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-blue: #38bdf8;
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.25);
  --accent-purple: #a855f7;
  --accent-amber: #f59e0b;

  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand {
  padding: 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #10b981 0%, #0284c7 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 15px var(--accent-emerald-glow);
}

.brand-logo svg {
  width: 22px;
  height: 22px;
}

.brand-text h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.badge-status {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  display: inline-block;
  margin-top: 2px;
}

.badge-status.online {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-status.offline {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.nav-menu {
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-grow: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  width: 100%;
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.15), transparent);
  color: var(--accent-blue);
  border-left: 3px solid var(--accent-blue);
}

.nav-item.highlight-tab.active {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.15), transparent);
  color: var(--accent-emerald);
  border-left: 3px solid var(--accent-emerald);
}

.tab-badge {
  margin-left: auto;
  font-size: 0.65rem;
  background: var(--accent-emerald);
  color: #000;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-full);
}

.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.15);
}

.system-stats .stat-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.system-stats strong {
  color: var(--text-muted);
}

/* Main Content */
.main-content {
  flex-grow: 1;
  padding: 1.75rem 2rem;
  overflow-y: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.75rem;
}

.page-title h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-title p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toggle-control-group {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-card);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

/* Botões */
.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 2px 10px var(--accent-emerald-glow);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-success {
  background: #059669;
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.toggle-btn.paused {
  background: #dc2626;
  box-shadow: 0 2px 10px var(--accent-red-glow);
}

.toggle-dot {
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

/* Tabs */
.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

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

/* Grid de Métricas */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.metric-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

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

.metric-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}

.metric-icon {
  font-size: 1.1rem;
}

.metric-value {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.metric-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.text-emerald { color: var(--accent-emerald); }
.text-red { color: var(--accent-red); }
.text-center { text-align: center; }
.text-muted { color: var(--text-dim); }

/* Cards & Tabelas */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.card-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.view-all-link {
  font-size: 0.85rem;
  color: var(--accent-emerald);
  text-decoration: none;
  font-weight: 500;
}

.view-all-link:hover {
  text-decoration: underline;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* Gráfico */
.chart-container {
  height: 240px;
  width: 100%;
  position: relative;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  padding: 1rem 0;
  overflow: hidden;
}

#timelineSvg {
  width: 100%;
  height: 100%;
}

.chart-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot.emerald { background: var(--accent-emerald); }
.dot.red { background: var(--accent-red); }

/* Tabelas */
.table-container {
  overflow-x: auto;
}

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

.data-table th {
  padding: 0.75rem 1rem;
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

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

.font-mono-table td {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

/* Barra de Proporção Visual */
.proportion-bar-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.proportion-bar-bg {
  flex-grow: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.proportion-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent-blue);
}

.proportion-bar-fill.blocked {
  background: var(--accent-red);
}

/* Badges nas Tabelas */
.tag-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

.tag-badge.allowed {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
}

.tag-badge.blocked {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

/* ==========================================================
   Estilos Específicos da Aba de Relatórios (180 Dias)
   ========================================================== */
.report-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  margin-bottom: 1.25rem;
}

.period-selector {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.filter-label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}

.btn-group {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-main);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.btn-filter {
  background: transparent;
  color: var(--text-muted);
  border: none;
}

.btn-filter.active {
  background: var(--bg-card-hover);
  color: #fff;
  border: 1px solid var(--border-subtle);
}

.btn-filter.highlight.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(2, 132, 199, 0.25));
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.report-nav-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.5rem;
}

.report-subtab {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.report-subtab:hover {
  color: var(--text-main);
  background: var(--bg-card);
}

.report-subtab.active {
  background: var(--bg-card);
  color: var(--accent-emerald);
  border-bottom: 2px solid var(--accent-emerald);
}

.subreport-content {
  display: none;
}

.subreport-content.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

.client-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.client-summary-strip {
  display: flex;
  gap: 1.5rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  font-size: 0.88rem;
  border: 1px dashed var(--border-subtle);
}

/* Formulários & Filtros */
.form-input, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition);
}

.form-input:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.log-filters {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Modais */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  animation: modalPop 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.pause-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-group .form-input {
  width: 100%;
}

.modal-footer {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
}

/* Guia do Roteador */
.guide-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.step-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  position: relative;
}

.step-num {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.8rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.08);
}

.step-content h4 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--accent-blue);
}

.step-content p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

code {
  background: var(--bg-input);
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  color: var(--accent-emerald);
}

/* Regras & Listas */
.rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.add-rule-form {
  margin-bottom: 1.25rem;
}

.add-rule-form .form-input {
  width: 100%;
  margin-bottom: 0.6rem;
}

.rule-action-buttons {
  display: flex;
  gap: 0.5rem;
}

.custom-rules-list {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  margin-top: 0.5rem;
  background: var(--bg-input);
}

.custom-rules-list li {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Responsividade */
@media (max-width: 900px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .dashboard-columns, .rules-grid { grid-template-columns: 1fr; }
  .report-filter-bar { flex-direction: column; gap: 1rem; align-items: flex-start; }
}

/* ==========================================================
   Estilos de Grupos e Relatórios por Grupo
   ========================================================== */
.group-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
}

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

.group-devices-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.group-device-card {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  transition: var(--transition);
}

.group-device-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.group-device-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.group-device-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.group-device-stats {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.85rem;
}

.group-device-domains-container {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.group-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

/* ==========================================================
   Categorias por Grupo & Active Directory
   ========================================================== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 0.85rem;
  max-height: 440px;
  overflow-y: auto;
  padding-right: 0.4rem;
}

.category-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.category-card.blocked {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.04);
}

.category-card.allowed {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.04);
}

.category-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.category-icon-box {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.category-text-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
  display: block;
  margin-bottom: 0.15rem;
}

.category-text-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.25;
}

.category-toggle-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
}

.category-toggle-btn.btn-blocked {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.category-toggle-btn.btn-allowed {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.ad-info-box {
  display: flex;
  gap: 0.9rem;
  padding: 0.9rem 1.1rem;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
}

.ad-info-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.ad-info-text strong {
  color: #60a5fa;
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.88rem;
}

.ad-info-text p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

.ad-info-text code {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  color: #93c5fd;
  font-size: 0.78rem;
}

