/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:           #0f1117;
  --bg-secondary: #141720;
  --card:         #1a1d27;
  --card-hover:   #1f2335;
  --border:       #252836;
  --border-light: #2d3148;
  --accent:       #3b82f6;
  --accent-hover: #2563eb;
  --accent-dim:   rgba(59,130,246,0.12);
  --text:         #e2e8f0;
  --text-muted:   #8892a4;
  --text-dim:     #4a5568;
  --green:        #22c55e;
  --green-dim:    rgba(34,197,94,0.12);
  --red:          #ef4444;
  --red-dim:      rgba(239,68,68,0.12);
  --yellow:       #f59e0b;
  --yellow-dim:   rgba(245,158,11,0.12);
  --purple:       #a78bfa;
  --purple-dim:   rgba(167,139,250,0.12);
  --sidebar-w:    240px;
  --header-h:     56px;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --font-mono:    'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }
ul { list-style: none; }

/* ─── Layout ───────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

#main-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

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

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active .nav-icon { opacity: 1; }

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

.sidebar-tagline {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ─── Mobile Header ────────────────────────────────────────────────────────── */
#mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  align-items: center;
  gap: 12px;
  z-index: 200;
}

#menu-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

#menu-toggle:hover { background: var(--card); color: var(--text); }

#nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

#nav-overlay.visible { display: block; }

/* ─── Main Content ─────────────────────────────────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 48px;
}

#tool-container {
  max-width: 900px;
  margin: 0 auto;
}

/* ─── Tool Header ──────────────────────────────────────────────────────────── */
.tool-header {
  margin-bottom: 32px;
}

.tool-header h1 {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 8px;
}

.tool-header p {
  color: var(--text-muted);
  font-size: 0.9375rem;
  max-width: 600px;
}

/* ─── Input Form ───────────────────────────────────────────────────────────── */
.input-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 28px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.input-group {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.input-field {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.9375rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

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

.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 3px rgba(59,130,246,0.3);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(59,130,246,0.4);
}

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

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

.btn-secondary:hover { background: var(--border); }

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 5px 10px;
  font-size: 0.8125rem;
}

.btn-ghost:hover { background: var(--card); color: var(--text); }

/* ─── Results Area ─────────────────────────────────────────────────────────── */
.results-area {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 20px; }

/* ─── Tables ───────────────────────────────────────────────────────────────── */
.dns-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.dns-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.dns-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(37,40,54,0.7);
  color: var(--text);
  vertical-align: top;
}

.dns-table tr:last-child td { border-bottom: none; }

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

.dns-table td.mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: #c8d3e6;
  word-break: break-all;
}

/* ─── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--bg);
  border-radius: 8px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.tab-btn:hover { color: var(--text); background: var(--card); }

.tab-btn.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-family: var(--font-mono);
}

.badge-blue   { background: var(--accent-dim);  color: var(--accent);  }
.badge-green  { background: var(--green-dim);   color: var(--green);   }
.badge-red    { background: var(--red-dim);     color: var(--red);     }
.badge-yellow { background: var(--yellow-dim);  color: var(--yellow);  }
.badge-purple { background: var(--purple-dim);  color: var(--purple);  }
.badge-muted  { background: var(--border);      color: var(--text-muted); }

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

.status-dot.green  { background: var(--green);  box-shadow: 0 0 6px var(--green); }
.status-dot.red    { background: var(--red);    box-shadow: 0 0 6px var(--red); }
.status-dot.yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }

/* ─── Loading Spinner ──────────────────────────────────────────────────────── */
.spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 16px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.spinner-label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ─── Empty / Error States ─────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  gap: 12px;
  text-align: center;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.empty-state-text {
  font-size: 0.875rem;
  color: var(--text-dim);
  max-width: 300px;
}

.error-box {
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--red);
  font-size: 0.875rem;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.error-box svg { flex-shrink: 0; margin-top: 1px; }

/* ─── Info Card (IP Tool) ──────────────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.info-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.info-item-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.info-item-value {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
}

.info-item-value.large {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.info-item.accent { border-color: var(--accent); }
.info-item.accent .info-item-value { color: var(--accent); }

/* ─── SSL Grade Badge ──────────────────────────────────────────────────────── */
.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 12px;
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -2px;
  border: 2px solid;
}

.grade-badge.grade-a  { background: var(--green-dim);  border-color: var(--green);  color: var(--green); }
.grade-badge.grade-b  { background: var(--yellow-dim); border-color: var(--yellow); color: var(--yellow); }
.grade-badge.grade-c,
.grade-badge.grade-d,
.grade-badge.grade-f  { background: var(--red-dim);    border-color: var(--red);    color: var(--red); }
.grade-badge.grade-t,
.grade-badge.grade-m  { background: var(--purple-dim); border-color: var(--purple); color: var(--purple); }

/* ─── SSL Summary Row ──────────────────────────────────────────────────────── */
.ssl-summary {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.ssl-summary-details {
  flex: 1;
  min-width: 200px;
}

.ssl-summary-details h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.ssl-summary-details p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ─── Blacklist List ───────────────────────────────────────────────────────── */
.bl-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bl-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: background 0.1s;
}

.bl-item:hover { background: rgba(255,255,255,0.03); }

.bl-status-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.bl-name {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.bl-result {
  font-weight: 600;
  font-size: 0.8125rem;
}

.bl-result.clean { color: var(--green); }
.bl-result.listed { color: var(--red); }
.bl-result.error { color: var(--text-dim); }

/* ─── Blacklist Summary ────────────────────────────────────────────────────── */
.bl-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.bl-summary-count {
  font-size: 2rem;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1;
}

.bl-summary-count.all-clear { color: var(--green); }
.bl-summary-count.has-issues { color: var(--red); }

.bl-summary-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ─── HTTP Status Badge ────────────────────────────────────────────────────── */
.http-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
}

.http-status.s2xx { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(34,197,94,0.25); }
.http-status.s3xx { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(59,130,246,0.25); }
.http-status.s4xx { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(245,158,11,0.25); }
.http-status.s5xx { background: var(--red-dim);    color: var(--red);    border: 1px solid rgba(239,68,68,0.25); }

/* ─── Important Header Highlight ───────────────────────────────────────────── */
.header-row.important td:first-child {
  color: var(--accent);
  font-weight: 500;
}

/* ─── Redirect Chain ───────────────────────────────────────────────────────── */
.redirect-chain {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.redirect-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8125rem;
}

.redirect-step .arrow {
  color: var(--text-dim);
  flex-shrink: 0;
}

.redirect-step .url {
  font-family: var(--font-mono);
  color: var(--text-muted);
  word-break: break-all;
}

.redirect-step .code {
  flex-shrink: 0;
}

/* ─── MX Priority Bar ──────────────────────────────────────────────────────── */
.mx-priority {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mx-priority-num {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 32px;
}

.mx-priority-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.6;
}

/* ─── Progress Bar ─────────────────────────────────────────────────────────── */
.progress-wrap {
  background: var(--bg);
  border-radius: 4px;
  height: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
  animation: pulse-bar 2s ease-in-out infinite;
}

@keyframes pulse-bar {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ─── Copy Button ──────────────────────────────────────────────────────────── */
.copy-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  padding: 3px 8px;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.copy-btn:hover { background: var(--card-hover); color: var(--text); border-color: var(--border-light); }
.copy-btn.copied { color: var(--green); border-color: var(--green); }

/* ─── Section divider ──────────────────────────────────────────────────────── */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ─── Pill Tags ────────────────────────────────────────────────────────────── */
.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.8125rem;
  font-family: var(--font-mono);
  background: var(--bg);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  word-break: break-all;
}

/* ─── Days Expiry ──────────────────────────────────────────────────────────── */
.expiry-days {
  font-weight: 700;
  font-family: var(--font-mono);
}

.expiry-days.safe   { color: var(--green); }
.expiry-days.warn   { color: var(--yellow); }
.expiry-days.danger { color: var(--red); }

/* ─── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ─── Utilities ────────────────────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-dim    { color: var(--text-dim); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-accent { color: var(--accent); }
.mono        { font-family: var(--font-mono); }
.mb-4        { margin-bottom: 4px; }
.mb-8        { margin-bottom: 8px; }
.mb-12       { margin-bottom: 12px; }
.mb-16       { margin-bottom: 16px; }
.mt-8        { margin-top: 8px; }
.mt-12       { margin-top: 12px; }
.mt-16       { margin-top: 16px; }
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.font-bold   { font-weight: 700; }
.text-sm     { font-size: 0.875rem; }
.text-xs     { font-size: 0.75rem; }
.w-full      { width: 100%; }
.overflow-x-auto { overflow-x: auto; }

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }

  #mobile-header {
    display: flex;
  }

  #main-content {
    margin-left: 0;
    padding: 20px 16px;
    padding-top: calc(var(--header-h) + 20px);
  }

  .info-grid {
    grid-template-columns: 1fr 1fr;
  }

  .input-form {
    flex-direction: column;
    align-items: stretch;
  }

  .btn { width: 100%; justify-content: center; }

  .ssl-summary { flex-direction: column; align-items: flex-start; }

  .dns-table th:nth-child(4),
  .dns-table td:nth-child(4) { display: none; }
}

@media (max-width: 480px) {
  .info-grid { grid-template-columns: 1fr; }
  #tool-container { padding: 0; }
  .card-body { padding: 16px; }
  .tool-header h1 { font-size: 1.5rem; }
}

/* ─── Animations ───────────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.2s ease-out forwards;
}

/* ─── Poll Status ──────────────────────────────────────────────────────────── */
.poll-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.poll-status .spinner {
  width: 18px;
  height: 18px;
  border-width: 2px;
}
