/* ============================================================
   PhishGuard — Custom Stylesheet
   Dark cybersecurity theme built on Bootstrap 5 dark mode
   ============================================================ */

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --pg-bg:          #0d1117;
  --pg-surface:     #161b22;
  --pg-surface2:    #1c2128;
  --pg-border:      rgba(255,255,255,0.08);
  --pg-border2:     rgba(255,255,255,0.12);
  --pg-text:        #e6edf3;
  --pg-muted:       #7d8590;
  --pg-primary:     #2f81f7;
  --pg-primary-dim: rgba(47,129,247,0.12);
  --pg-danger:      #f85149;
  --pg-success:     #3fb950;
  --pg-warning:     #d29922;
  --pg-info:        #58a6ff;
  --pg-navbar-h:    60px;
  --pg-radius:      10px;
  --pg-radius-sm:   6px;
  --pg-font:        'Inter', system-ui, -apple-system, sans-serif;
  --pg-font-mono:   'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --pg-shadow:      0 4px 24px rgba(0,0,0,0.4);
  --pg-shadow-sm:   0 2px 8px rgba(0,0,0,0.3);
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--pg-font);
  background-color: var(--pg-bg);
  color: var(--pg-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.6;
}

.font-mono { font-family: var(--pg-font-mono) !important; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--pg-bg); }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

/* ── Navbar ─────────────────────────────────────────────────── */
.pg-navbar {
  height: var(--pg-navbar-h);
  background: rgba(13,17,23,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--pg-border);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04);
  z-index: 1030;
}

.brand-icon {
  font-size: 1.3rem;
  color: var(--pg-primary);
  line-height: 1;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--pg-text);
}

.pg-navbar .nav-link {
  color: var(--pg-muted) !important;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--pg-radius-sm);
  transition: color .15s, background .15s;
}
.pg-navbar .nav-link:hover,
.pg-navbar .nav-link.active {
  color: var(--pg-text) !important;
  background: rgba(255,255,255,0.06);
}
.pg-navbar .nav-link.active { color: var(--pg-primary) !important; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--pg-muted);
}
.status-dot {
  width: 7px; height: 7px;
  background: var(--pg-success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { opacity:1; }
  50% { opacity:.4; }
}

/* ── Layout ─────────────────────────────────────────────────── */
.pg-main {
  margin-top: var(--pg-navbar-h);
  flex: 1;
}

.pg-footer {
  background: var(--pg-surface);
  border-top: 1px solid var(--pg-border);
  padding: 14px 0;
}

/* ── Hero section ───────────────────────────────────────────── */
.hero-section {
  background: linear-gradient(135deg, var(--pg-surface) 0%, #0a0f16 100%);
  border-bottom: 1px solid var(--pg-border);
  padding: 60px 0 48px;
  position: relative;
  overflow: hidden;
}
.hero-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(47,129,247,0.07) 0%, transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  background: var(--pg-primary-dim);
  border: 1px solid rgba(47,129,247,0.3);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--pg-primary);
}

.hero-title {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.5px;
  margin-bottom: 1rem;
}

.hero-sub {
  font-size: 1rem;
  max-width: 560px;
  margin: 0 auto 2rem;
  line-height: 1.7;
}

.hero-scan-form .input-group {
  max-width: 720px;
  margin: 0 auto;
  border-radius: var(--pg-radius);
  overflow: hidden;
  box-shadow: var(--pg-shadow);
}
.hero-scan-form .form-control:focus { box-shadow: none; border-color: var(--pg-primary); }

/* ── Stat cards ─────────────────────────────────────────────── */
.stat-card {
  background: var(--pg-surface);
  border: 1px solid var(--pg-border);
  border-radius: var(--pg-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color .2s, transform .2s;
}
.stat-card:hover {
  border-color: var(--pg-border2);
  transform: translateY(-1px);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--pg-radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.5px;
}
.stat-label { font-size: 0.78rem; color: var(--pg-muted); margin-top: 3px; }

/* ── Feature cards ──────────────────────────────────────────── */
.feature-card {
  background: var(--pg-surface);
  border: 1px solid var(--pg-border);
  border-radius: var(--pg-radius);
  padding: 28px 20px;
  transition: border-color .2s, transform .2s;
}
.feature-card:hover { border-color: var(--pg-border2); transform: translateY(-2px); }
.feature-icon { font-size: 2rem; line-height: 1; }

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

.pg-card-header {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--pg-border);
  font-weight: 600;
  font-size: 0.875rem;
  background: var(--pg-surface2);
}

.pg-card-body { padding: 20px; }

/* ── Page header ────────────────────────────────────────────── */
.page-header { border-bottom: 1px solid var(--pg-border); padding-bottom: 16px; }
.page-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }

/* ── Meta fields ────────────────────────────────────────────── */
.meta-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pg-muted);
  margin-bottom: 4px;
}
.meta-value { font-size: 0.875rem; word-break: break-word; }

/* ── Risk gauge ─────────────────────────────────────────────── */
.risk-gauge-wrap {
  position: relative;
  display: inline-block;
}
.risk-gauge-center {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}
.risk-score-big {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
}

/* ── Checks list ────────────────────────────────────────────── */
.checks-list { }

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--pg-border);
  transition: background .15s;
}
.check-item:last-child { border-bottom: none; }
.check-item:hover { background: rgba(255,255,255,0.02); }

.check-fail { border-left: 3px solid var(--pg-danger); }
.check-pass { border-left: 3px solid transparent; }

.check-icon { font-size: 1.1rem; margin-top: 1px; flex-shrink: 0; }
.check-content { flex: 1; min-width: 0; }
.check-header { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.check-desc, .check-detail { line-height: 1.4; }

/* ── Recommendations list ───────────────────────────────────── */
.rec-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.rec-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--pg-border);
  display: flex;
  align-items: flex-start;
  gap: 4px;
  line-height: 1.5;
}
.rec-list li:last-child { border-bottom: none; padding-bottom: 0; }

/* ── Table ──────────────────────────────────────────────────── */
.pg-table {
  font-size: 0.85rem;
}
.pg-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--pg-muted);
  font-weight: 600;
  border-color: var(--pg-border);
  padding: 10px 14px;
  white-space: nowrap;
  background: var(--pg-surface2);
}
.pg-table td {
  border-color: var(--pg-border);
  padding: 10px 14px;
  vertical-align: middle;
}
.table-hover > tbody > tr:hover > * { background: rgba(255,255,255,0.03); }

/* ── API rows (About page) ──────────────────────────────────── */
.api-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--pg-border);
  flex-wrap: wrap;
}
.api-row:last-child { border-bottom: none; }
.api-row > div { flex-basis: 100%; margin-top: 2px; padding-left: 6px; }

/* ── About check rows ───────────────────────────────────────── */
.about-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--pg-border);
}
.about-check:last-child { border-bottom: none; }

/* ── Sample checks (URL scan placeholder) ───────────────────── */
.sample-check {
  background: var(--pg-surface2);
  border: 1px solid var(--pg-border);
  border-radius: var(--pg-radius-sm);
  padding: 6px 14px;
  font-family: var(--pg-font-mono);
  font-size: 0.8rem;
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination .page-link {
  background: var(--pg-surface);
  border-color: var(--pg-border);
  color: var(--pg-muted);
  font-size: 0.82rem;
}
.pagination .page-link:hover { background: var(--pg-surface2); color: var(--pg-text); }
.pagination .page-item.active .page-link { background: var(--pg-primary); border-color: var(--pg-primary); color: #fff; }
.pagination .page-item.disabled .page-link { background: var(--pg-surface); opacity: .4; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-control:focus, .form-select:focus {
  border-color: var(--pg-primary) !important;
  box-shadow: 0 0 0 3px rgba(47,129,247,0.15) !important;
}
.form-control, .form-select {
  color: var(--pg-text) !important;
  background-color: var(--pg-surface2) !important;
  border-color: var(--pg-border2) !important;
}
textarea.form-control { resize: vertical; }
.input-group-text {
  background-color: var(--pg-surface2) !important;
  border-color: var(--pg-border2) !important;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary   { background-color: var(--pg-primary); border-color: var(--pg-primary); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-outline-primary { color: var(--pg-primary); border-color: var(--pg-primary); }
.btn-outline-primary:hover { background: var(--pg-primary); color: #fff; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  font-weight: 500;
  letter-spacing: 0.03em;
}

/* ── Progress bars ───────────────────────────────────────────── */
.progress {
  background-color: rgba(255,255,255,0.08);
  border-radius: 99px;
}

/* ── Alert tweaks ────────────────────────────────────────────── */
.alert { border-radius: var(--pg-radius-sm); font-size: 0.875rem; }

/* ── Utilities ───────────────────────────────────────────────── */
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Print styles ────────────────────────────────────────────── */
@media print {
  .pg-navbar, .pg-footer, .btn, form { display: none !important; }
  .pg-main { margin-top: 0 !important; }
  .pg-card { break-inside: avoid; border: 1px solid #ccc; }
  body { background: #fff !important; color: #000 !important; }
  .text-muted { color: #555 !important; }
}

/* ── Responsive tweaks ───────────────────────────────────────── */
@media (max-width: 576px) {
  .hero-title { font-size: 1.7rem; }
  .pg-card-body { padding: 14px; }
  .check-item { padding: 12px 14px; }
  .pg-table th, .pg-table td { padding: 8px 10px; }
}

/* ── Arabic / RTL support ────────────────────────────────────── */
[lang="ar"] {
  --pg-font: 'Tajawal', 'Inter', sans-serif;
  font-family: var(--pg-font);
}

/* Flip border indicators for RTL */
[dir="rtl"] .check-fail {
  border-left: none;
  border-right: 3px solid var(--pg-danger);
}
[dir="rtl"] .check-pass {
  border-left: none;
  border-right: 3px solid transparent;
}

/* Brand name: no letter-spacing in Arabic */
[dir="rtl"] .brand-name { letter-spacing: 0; }

/* Mono font elements stay LTR (URLs, code, IPs) */
[dir="rtl"] .font-mono {
  direction: ltr;
  unicode-bidi: embed;
  text-align: left;
}
[dir="rtl"] .pg-table td.font-mono { text-align: left; }

/* Align API endpoint rows */
[dir="rtl"] .api-row { direction: ltr; }

/* Flip chevron icon direction for RTL breadcrumb/arrows */
[dir="rtl"] .fa-chevron-right { transform: scaleX(-1); }
[dir="rtl"] .fa-chevron-left  { transform: scaleX(-1); }
[dir="rtl"] .fa-arrow-left    { transform: scaleX(-1); }
[dir="rtl"] .fa-angle-right   { transform: scaleX(-1); }
