/* ============================================================
   DMARC Insights — Design System v2.0
   Tom: amigável, sofisticado, seguro
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&family=Inter:wght@400;450;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Brand: Teal / verde-azulado profundo */
  --brand: #0F6E6E;
  --brand-600: #0D5C5C;
  --brand-500: #128080;
  --brand-400: #2BA2A2;
  --brand-100: #D5F0F0;
  --brand-050: #EAF8F8;

  /* Background: tom papel com leve frieza */
  --bg-app: #F6F8F8;
  --bg-card: #FFFFFF;
  --bg-subtle: #EEF2F2;
  --bg-hover: #F0F4F4;

  /* Text */
  --text-primary: #1A2B2B;
  --text-secondary: #5A6B6B;
  --text-muted: #8A9B9B;
  --text-inverse: #FFFFFF;

  /* Status (tint backgrounds + strong text) */
  --pass: #0B8043;
  --pass-tint: #DCFCE7;
  --warn: #B45309;
  --warn-tint: #FEF3C7;
  --fail: #C2410C;
  --fail-tint: #FFEDD5;
  --danger: #BE123C;
  --danger-tint: #FFE4E6;
  --info: #0369A1;
  --info-tint: #DBEAFE;

  /* Borders & Shadow */
  --border: #E0E6E6;
  --border-strong: #C8D0D0;
  --shadow-sm: 0 1px 2px rgba(16,42,42,0.04), 0 1px 3px rgba(16,42,42,0.06);
  --shadow-md: 0 4px 6px -1px rgba(16,42,42,0.05), 0 2px 4px -2px rgba(16,42,42,0.05);
  --shadow-lg: 0 10px 20px -5px rgba(16,42,42,0.08), 0 4px 6px -4px rgba(16,42,42,0.05);

  /* Radius */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Fonts */
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html[data-bs-theme="dark"] {
  /* Brand: Teal em destaque no modo escuro */
  --brand: #2BA2A2;
  --brand-600: #128080;
  --brand-500: #2BA2A2;
  --brand-400: #54C4C4;
  --brand-100: #133939;
  --brand-050: #0C2626;

  /* Backgrounds escuros */
  --bg-app: #0B0F17;
  --bg-card: #151C28;
  --bg-subtle: #1E293B;
  --bg-hover: #26334D;

  /* Texto */
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-inverse: #0F172A;

  /* Tints de Status */
  --pass-tint: rgba(11, 128, 67, 0.2);
  --warn-tint: rgba(180, 83, 9, 0.2);
  --fail-tint: rgba(194, 65, 12, 0.2);
  --danger-tint: rgba(190, 18, 60, 0.2);
  --info-tint: rgba(3, 105, 161, 0.2);

  /* Bordas e Sombras */
  --border: #243044;
  --border-strong: #334155;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.5);
  --shadow-lg: 0 10px 20px -5px rgba(0,0,0,0.6);
}

/* ====== Base ====== */
* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

h1, h2, h3, h4, h5, h6, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.mono, code, .ip-cell {
  font-family: var(--font-mono);
  font-size: 0.85em;
  letter-spacing: -0.02em;
}

/* ====== Layout: Sidebar + Content ====== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 248px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--brand);
}

.sidebar-brand .logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0.75rem;
  overflow-y: auto;
}

.sidebar-nav .nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 1rem 0.75rem 0.375rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 450;
  font-size: 0.9rem;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.sidebar-nav .nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-nav .nav-link.active {
  background: var(--brand-050);
  color: var(--brand);
  font-weight: 500;
}

.sidebar-nav .nav-link i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.15s;
}

.sidebar-user:hover { background: var(--bg-hover); }

.sidebar-user .avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--brand-100);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.main-content {
  flex: 1;
  margin-left: 248px;
  padding: 2rem 2.5rem;
  min-width: 0;
}

/* Mobile bottom nav */
.mobile-nav { display: none; }

@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-bottom: 80px;
  }
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 100;
    justify-content: space-around;
    padding: 0.5rem 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  }
  .mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.625rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
  }
  .mobile-nav a.active { color: var(--brand); }
  .mobile-nav a i { font-size: 1.25rem; }
}

/* ====== Cards ====== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1.125rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.card-body { padding: 1.25rem; }

/* ====== Stat Cards ====== */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: transparent;
  z-index: 2;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card-primary::before { background: #2563eb; }
.stat-card-success::before { background: #16a34a; }
.stat-card-warning::before { background: #d97706; }
.stat-card-danger::before  { background: #dc2626; }

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.stat-card .stat-value {
  font-family: var(--font-display, inherit);
  font-size: clamp(1.35rem, 1.7vw, 1.7rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  letter-spacing: -0.01em;
}

/* ====== Badges ====== */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
}
.badge-pass { background: var(--pass-tint); color: var(--pass); }
.badge-warn { background: var(--warn-tint); color: var(--warn); }
.badge-fail { background: var(--fail-tint); color: var(--fail); }
.badge-danger { background: var(--danger-tint); color: var(--danger); }
.badge-info { background: var(--info-tint); color: var(--info); }
.badge-neutral { background: var(--bg-subtle); color: var(--text-secondary); }

/* ====== Trust Signal Bar ====== */
.trust-bar {
  display: flex;
  height: 8px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--bg-subtle);
}
.trust-bar .seg-pass { background: var(--pass); }
.trust-bar .seg-warn { background: var(--warn); }
.trust-bar .seg-fail { background: var(--fail); }

/* ====== Signal Trail (assinatura visual) ====== */
.signal-trail {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 1rem 0;
}
.signal-trail .node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  position: relative;
  z-index: 1;
}
.signal-trail .node-circle {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  border: 2px solid var(--border);
  background: var(--bg-card);
}
.signal-trail .node.pass .node-circle { border-color: var(--pass); background: var(--pass-tint); color: var(--pass); }
.signal-trail .node.fail .node-circle { border-color: var(--fail); background: var(--fail-tint); color: var(--fail); }
.signal-trail .node-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}
.signal-trail .connector {
  flex: 1;
  height: 2px;
  min-width: 24px;
}
.signal-trail .connector.solid { background: var(--pass); }
.signal-trail .connector.dashed {
  background: repeating-linear-gradient(90deg, var(--fail) 0, var(--fail) 4px, transparent 4px, transparent 8px);
}

/* ====== Readiness Score ====== */
.readiness-bar {
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  overflow: hidden;
}
.readiness-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

/* ====== Tables ====== */
.table-wrapper {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.table {
  width: 100%;
  margin: 0;
}
.table thead th {
  background: var(--bg-subtle);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.875rem;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-hover); }

/* ====== Forms ====== */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-family: var(--font-body);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px var(--brand-050);
}

/* ====== Buttons ====== */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  transition: all 0.15s;
  border: none;
}
.btn-brand {
  background: var(--brand);
  color: white;
}
.btn-brand:hover { background: var(--brand-600); color: white; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}
.btn-outline:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ====== Alerts ====== */
.alert {
  border-radius: var(--radius);
  border: none;
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
}
.alert-info { background: var(--info-tint); color: var(--info); }
.alert-success { background: var(--pass-tint); color: var(--pass); }
.alert-warning { background: var(--warn-tint); color: var(--warn); }
.alert-danger { background: var(--danger-tint); color: var(--danger); }

/* ====== Domain Card ====== */
.domain-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}
.domain-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--brand-400);
}

/* ====== Empty State ====== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

/* ====== Chart Container ====== */
.chart-container { position: relative; height: 240px; }
.chart-container-sm { position: relative; height: 160px; }
.compliance-gauge { position: relative; width: 180px; height: 180px; margin: 0 auto; display: flex; align-items: center; justify-content: center; }
.compliance-gauge svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.compliance-gauge .gauge-value { position: relative; text-align: center; z-index: 2; }
.compliance-gauge .gauge-value .value { font-size: 1.75rem; font-weight: bold; line-height: 1; }
.compliance-gauge .gauge-value .label { font-size: 0.875rem; color: var(--text-secondary); margin-top: 0.25rem; }

/* ====== Progress thin ====== */
.progress-thin { height: 6px; border-radius: var(--radius-full); }

/* ====== Filter bar ====== */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem;
}

/* ====== Login ====== */
.login-page-body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg-app);
}

.login-split-container {
  min-height: 100vh;
  display: flex;
  width: 100%;
}

.login-hero-side {
  flex: 1.1;
  background: linear-gradient(135deg, #090d16 0%, #0f172a 40%, #1e1b4b 80%, #1e3a8a 100%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3.5rem 4rem;
  position: relative;
  overflow: hidden;
}

.login-hero-side::before {
  content: '';
  position: absolute;
  top: -20%;
  left: -20%;
  width: 140%;
  height: 140%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.2) 0%, rgba(99, 102, 241, 0.15) 30%, rgba(0, 0, 0, 0) 70%);
  pointer-events: none;
}

.login-hero-card {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl);
  padding: 1.5rem 1.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.login-form-side {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem 2.5rem;
  background: var(--bg-card);
  position: relative;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.05);
}

.login-theme-toggle {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
}

@media (max-width: 991.98px) {
  .login-hero-side {
    display: none;
  }
  .login-form-side {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    justify-content: center;
    box-shadow: none;
  }
}

/* ====== Tabs ====== */
.nav-tabs {
  border-bottom: 1px solid var(--border);
  gap: 0.25rem;
}
.nav-tabs .nav-link {
  border: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 0.625rem 1rem;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
}
.nav-tabs .nav-link.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  background: transparent;
}

/* ====== Focus & Accessibility ====== */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--brand-400);
  outline-offset: 2px;
}

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

/* ====== Responsive table ====== */
@media (max-width: 767px) {
  .table-mobile-stack thead { display: none; }
  .table-mobile-stack tr {
    display: block;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
  }
  .table-mobile-stack td {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border: none;
  }
  .table-mobile-stack td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 1rem;
  }
}

/* Threat Infographic Modal */
.threat-infographic {
    background: var(--bg-subtle);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}
.threat-node {
    width: 120px;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.threat-arrow {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}
.threat-arrow::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: currentColor;
    z-index: 0;
    opacity: 0.2;
}
.threat-arrow i, .threat-arrow small {
    background: var(--bg-subtle);
    padding: 0 8px;
    z-index: 1;
}

/* Unified Input Group Focus */
.input-group:focus-within .input-group-text,
.input-group:focus-within .form-control {
    border-color: #86b7fe;
}
.input-group .form-control:focus {
    box-shadow: none;
}