/* ── Reset & Base ─────────────────────────────────────────────────────────── */

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

:root {
  /* Sidebar */
  --sb-bg:        #0f1117;
  --sb-border:    #1f2430;
  --sb-text:      #8b92a5;
  --sb-text-hover:#e2e8f0;
  --sb-accent:    #ef4444;
  --sb-width:     240px;

  /* Content */
  --bg:           #f8fafc;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --text:         #1e293b;
  --text-muted:   #64748b;

  /* Brand */
  --primary:      #ef4444;
  --primary-hover:#dc2626;
  --success:      #10b981;
  --danger:       #ef4444;
  --warning:      #f59e0b;

  /* Type */
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  --radius:       6px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:    0 4px 16px rgba(0,0,0,.12);
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Loading overlay ─────────────────────────────────────────────────────── */

.loading-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--sb-bg);
  z-index: 9999;
  transition: opacity .3s;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,.1);
  border-top-color: var(--sb-accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App shell ───────────────────────────────────────────────────────────── */

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sb-width);
  flex-shrink: 0;
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Brand */
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px 18px;
  border-bottom: 1px solid var(--sb-border);
}
.brand-icon {
  width: 28px; height: 28px;
  color: var(--sb-accent);
  flex-shrink: 0;
}
.brand-name {
  font-size: 16px; font-weight: 600;
  color: #f1f5f9;
  letter-spacing: -.2px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--sb-border); border-radius: 2px; }

/* Footer */
.sidebar-footer {
  padding: 12px 12px 16px;
  border-top: 1px solid var(--sb-border);
  display: flex; flex-direction: column; gap: 10px;
}

.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--sb-accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}
.user-details {
  display: flex; flex-direction: column; overflow: hidden;
}
.user-name {
  font-size: 13px; font-weight: 500;
  color: var(--sb-text-hover);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-email {
  font-size: 11px; color: var(--sb-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-actions {
  display: flex; gap: 4px;
}
.btn-sidebar {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--sb-border);
  border-radius: var(--radius);
  color: var(--sb-text);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-sidebar svg { width: 16px; height: 16px; }
.btn-sidebar:hover {
  background: rgba(255,255,255,.06);
  color: var(--sb-text-hover);
  border-color: rgba(255,255,255,.12);
}
.btn-sidebar.active {
  background: rgba(239,68,68,.12);
  color: var(--sb-accent);
  border-color: rgba(239,68,68,.25);
}
.btn-logout:hover {
  background: rgba(239,68,68,.1);
  color: #fca5a5;
  border-color: rgba(239,68,68,.2);
}

/* ── Main content ────────────────────────────────────────────────────────── */

.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex; flex-direction: column;
}

/* ── Views ───────────────────────────────────────────────────────────────── */

.view { flex: 1; }

/* Dashboard placeholder */
.dashboard-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; min-height: 400px;
  text-align: center; padding: 40px;
  color: var(--text-muted);
}
.dashboard-placeholder svg {
  width: 64px; height: 64px;
  color: #cbd5e1; margin-bottom: 20px;
}
.dashboard-placeholder h1 {
  font-size: 24px; font-weight: 600;
  color: var(--text); margin-bottom: 8px;
}
.dashboard-placeholder p { font-size: 14px; max-width: 420px; }
.dashboard-placeholder .hint {
  margin-top: 12px; font-size: 12px;
  padding: 10px 16px;
  background: #f1f5f9; border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ── Settings ────────────────────────────────────────────────────────────── */

#view-settings {
  padding: 32px;
  max-width: 1000px;
}

.settings-header {
  margin-bottom: 24px;
}
.settings-header h2 {
  font-size: 20px; font-weight: 600; color: var(--text);
}

/* Tabs */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}
.tab {
  padding: 8px 16px;
  background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
  border-radius: var(--radius) var(--radius) 0 0;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Table toolbar */
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.item-count { font-size: 12px; color: var(--text-muted); }

/* Table wrapper */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.data-table {
  width: 100%; border-collapse: collapse;
}
.data-table th {
  padding: 10px 14px;
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }

.col-active  { width: 64px;  text-align: center; }
.col-actions { width: 140px; text-align: right; }

.mono { font-family: var(--font-mono); font-size: 12px; }

.empty { text-align: center; color: var(--text-muted); padding: 32px !important; font-style: italic; }

/* Status dot */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
}
.status-dot.active  { background: var(--success); }
.status-dot.inactive{ background: #cbd5e1; }

/* Badges (grupo) */
.badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 100px;
  font-size: 11px; font-weight: 500;
  background: #f1f5f9; color: var(--text-muted);
}
.badge-phishing       { background: #fee2e2; color: #991b1b; }
.badge-financeiro     { background: #fef3c7; color: #92400e; }
.badge-institucional  { background: #ede9fe; color: #5b21b6; }
.badge-tecnologia     { background: #dbeafe; color: #1e40af; }
.badge-engenharia_social { background: #fce7f3; color: #9d174d; }
.badge-marca          { background: #d1fae5; color: #065f46; }
.badge-global         { background: #dbeafe; color: #1e40af; }
.badge-brasil         { background: #d1fae5; color: #065f46; }
.badge-alto_risco     { background: #fee2e2; color: #991b1b; }
.badge-saas_cloud     { background: #e0e7ff; color: #3730a3; }
.badge-corporativo    { background: #ede9fe; color: #5b21b6; }
.badge-secundario     { background: #f1f5f9; color: #475569; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent; border-radius: var(--radius);
  cursor: pointer; transition: all .15s;
  text-decoration: none;
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

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

.btn-ghost {
  background: transparent; color: var(--text-muted); border-color: var(--border);
}
.btn-ghost:hover { background: #f1f5f9; color: var(--text); }

.btn-danger {
  background: transparent; color: var(--danger); border-color: #fecaca;
}
.btn-danger:hover { background: #fee2e2; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  width: 100%; max-width: 440px;
  animation: modal-in .15s ease;
}
@keyframes modal-in {
  from { transform: scale(.96); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 20px; line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.form-row input, .form-row select {
  padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: var(--font);
  background: var(--surface); color: var(--text);
  transition: border-color .15s;
}
.form-row input:focus, .form-row select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(239,68,68,.1);
}
.form-row input[readonly] { background: #f8fafc; color: var(--text-muted); cursor: not-allowed; }

.checkbox-row { flex-direction: row; align-items: center; }
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 400; color: var(--text);
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary); }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* Loading state inside tab */
.loading-tab {
  display: flex; align-items: center; justify-content: center;
  padding: 48px; color: var(--text-muted); font-size: 13px;
}

/* ── Sidebar nav items ───────────────────────────────────────────────────── */

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 12px;
  background: transparent;
  border: none; border-radius: var(--radius);
  color: var(--sb-text);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-align: left;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: var(--sb-text-hover);
}
.nav-item.active {
  background: rgba(239,68,68,.12);
  color: var(--sb-accent);
}

/* ── Scan view ───────────────────────────────────────────────────────────── */

#view-scan { display: flex; flex-direction: column; }

.scan-page {
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
}

/* Top bar: heading + form */
.scan-topbar {
  flex-shrink: 0;
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-direction: column; gap: 16px;
}
.scan-header h2 { font-size: 20px; font-weight: 600; color: var(--text); }
.scan-subtitle   { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.scan-form-bar {
  display: flex; align-items: flex-end; gap: 10px;
}
.scan-form-bar .form-row { flex: 1; max-width: 520px; }

/* Results scroll area */
.scan-results-area {
  flex: 1; overflow-y: auto;
  padding: 24px 32px;
}

/* ── Scan states ─────────────────────────────────────────────────────────── */

.scan-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  min-height: 320px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.scan-state svg { color: #cbd5e1; }
.scan-state-hint {
  font-size: 12px; color: var(--text-muted);
  max-width: 360px; line-height: 1.6;
}
.scan-state-error svg { color: #fca5a5; }
.scan-state-error { color: var(--danger); }

/* Spinning gear */
.gear-spin {
  color: var(--primary);
  animation: spin 1.6s linear infinite;
}
.scan-loading-msg {
  font-size: 15px; font-weight: 500; color: var(--text);
}

/* ── Summary ─────────────────────────────────────────────────────────────── */

.scan-summary {
  margin-bottom: 20px;
}
.summary-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}
.summary-title {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 16px;
  font-size: 15px; color: var(--text);
}
.summary-ts {
  font-size: 12px; color: var(--text-muted); font-weight: 400;
}
.summary-cards {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.summary-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.summary-card-warn  { border-color: #fcd34d; background: #fffbeb; }
.summary-card-danger{ border-color: #fca5a5; background: #fff5f5; }
.summary-card-value {
  font-size: 24px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.summary-card-warn  .summary-card-value { color: #92400e; }
.summary-card-danger .summary-card-value{ color: #b91c1c; }
.summary-card-label { font-size: 12px; color: var(--text-muted); }

/* ── Results log ─────────────────────────────────────────────────────────── */

.scan-log-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.scan-log-header h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.scan-dns { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-mx-active { color: var(--danger); font-weight: 500; }
.scan-lsh { color: var(--text-muted); font-size: 12px; }
