/* ==========================================================================
   CyberGuard — application stylesheet (RTL/LTR via logical properties)
   Brand colours come from /theme.css (generated from Config\Brand).
   ========================================================================== */

@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../vendor/fonts/ibm-plex-sans-arabic/ibm-plex-sans-arabic-arabic-400-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../vendor/fonts/ibm-plex-sans-arabic/ibm-plex-sans-arabic-arabic-600-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../vendor/fonts/ibm-plex-sans-arabic/ibm-plex-sans-arabic-arabic-700-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../vendor/fonts/ibm-plex-sans-arabic/ibm-plex-sans-arabic-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../vendor/fonts/ibm-plex-sans-arabic/ibm-plex-sans-arabic-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../vendor/fonts/ibm-plex-sans-arabic/ibm-plex-sans-arabic-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --cg-primary: #0e7490;
  --cg-primary-rgb: 14, 116, 144;
  --cg-primary-dark: #0b5d73;
  --cg-accent: #f59e0b;
  --cg-ink: #0b1724;
  --cg-sidebar: #0b1724;
  --cg-sidebar-2: #10243a;
  --cg-surface: #f3f6f9;
  --cg-sidebar-w: 260px;
  --cg-radius: .75rem;

  --bs-font-sans-serif: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
  --bs-body-font-family: var(--bs-font-sans-serif);
  --bs-primary: var(--cg-primary);
  --bs-primary-rgb: var(--cg-primary-rgb);
  --bs-link-color: var(--cg-primary);
  --bs-link-color-rgb: var(--cg-primary-rgb);
  --bs-link-hover-color: var(--cg-primary-dark);
  --bs-border-radius: .5rem;
}

body { background: var(--cg-surface); font-size: .95rem; -webkit-font-smoothing: antialiased; }
code, pre, kbd, .font-monospace { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
[dir="rtl"] code { direction: ltr; unicode-bidi: embed; }

/* ---------- Bootstrap primary overrides (brand) ---------- */
.btn-primary { --bs-btn-bg: var(--cg-primary); --bs-btn-border-color: var(--cg-primary); --bs-btn-hover-bg: var(--cg-primary-dark);
  --bs-btn-hover-border-color: var(--cg-primary-dark); --bs-btn-active-bg: var(--cg-primary-dark); --bs-btn-active-border-color: var(--cg-primary-dark);
  --bs-btn-disabled-bg: var(--cg-primary); --bs-btn-disabled-border-color: var(--cg-primary); }
.btn-outline-primary { --bs-btn-color: var(--cg-primary); --bs-btn-border-color: var(--cg-primary); --bs-btn-hover-bg: var(--cg-primary);
  --bs-btn-hover-border-color: var(--cg-primary); --bs-btn-active-bg: var(--cg-primary-dark); --bs-btn-active-border-color: var(--cg-primary-dark); }
.text-primary { color: var(--cg-primary) !important; }
.bg-primary, .text-bg-primary { background-color: var(--cg-primary) !important; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: rgba(var(--cg-primary-rgb), .6); box-shadow: 0 0 0 .2rem rgba(var(--cg-primary-rgb), .18); }
.form-check-input:checked { background-color: var(--cg-primary); border-color: var(--cg-primary); }
.page-item.active .page-link { background-color: var(--cg-primary); border-color: var(--cg-primary); }
.page-link { color: var(--cg-primary); }
.card { border-radius: var(--cg-radius); }
.card-header:first-child { border-radius: var(--cg-radius) var(--cg-radius) 0 0; }
.table > :not(caption) > * > * { padding-block: .6rem; }
.badge { font-weight: 600; }

/* ---------- Accessibility ---------- */
.skip-link { position: absolute; inset-inline-start: 1rem; top: .5rem; z-index: 2000; background: #fff; padding: .5rem 1rem; border-radius: .5rem; }
:focus-visible { outline: 2px solid var(--cg-accent); outline-offset: 2px; }

/* ---------- Brand ---------- */
.brand-mark { display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: .6rem;
  background: linear-gradient(135deg, var(--cg-primary), var(--cg-primary-dark)); color: #fff; font-size: 1.1rem; box-shadow: 0 4px 12px rgba(var(--cg-primary-rgb), .35); }
.brand-name { font-weight: 700; font-size: 1.1rem; letter-spacing: .2px; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--cg-sidebar), var(--cg-sidebar-2)); color: #cbd5e1; width: var(--cg-sidebar-w); flex-shrink: 0; }
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { --bs-offcanvas-width: var(--cg-sidebar-w); --bs-offcanvas-bg: var(--cg-sidebar); }
}
.sidebar-admin { background: linear-gradient(180deg, #1a1020, #2a1730); }
.sidebar-head { padding: 1.1rem 1rem; }
.sidebar .nav-link { color: #cbd5e1; border-radius: .5rem; padding: .55rem .8rem; margin-bottom: 2px; display: flex; align-items: center; gap: .65rem; }
.sidebar .nav-link .bi { font-size: 1.05rem; opacity: .85; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar .nav-link.active { background: rgba(var(--cg-primary-rgb), .9); color: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.sidebar-admin .nav-link.active { background: var(--cg-accent); color: #1a1020; }
.sidebar .nav-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 1rem .8rem .35rem; }
.org-switch .dropdown-menu { max-height: 60vh; overflow-y: auto; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: #fff; border-bottom: 1px solid #e5e9ef; position: sticky; top: 0; z-index: 1020; }
.content { flex: 1; }
.avatar { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--cg-primary); color: #fff; font-weight: 700; font-size: .85rem; }

/* ---------- Cards & stats ---------- */
.stat-card .card-body { position: relative; }
.stat-icon { font-size: 1.5rem; line-height: 1; margin-bottom: .5rem; }
.stat-value { font-size: 1.7rem; font-weight: 700; color: var(--cg-ink); line-height: 1.2; }
.stat-label { color: #64748b; font-size: .85rem; }
.welcome-card { background: linear-gradient(120deg, #ffffff 60%, rgba(var(--cg-primary-rgb), .08)); }
.empty-state { text-align: center; color: #94a3b8; padding: 2.5rem 1rem; }
.empty-state .bi { font-size: 2.2rem; display: block; margin-bottom: .5rem; }
.empty-state p { margin: 0; }
.chart-box { position: relative; height: 260px; }
.audit-meta { font-size: .72rem; max-width: 360px; max-height: 220px; overflow: auto; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: .4rem; padding: .5rem; white-space: pre-wrap; word-break: break-all; text-align: left; }

/* ---------- Auth ---------- */
.auth-layout { background: radial-gradient(circle at 15% 10%, rgba(var(--cg-primary-rgb), .18), transparent 45%),
  radial-gradient(circle at 85% 90%, rgba(245, 158, 11, .12), transparent 40%), var(--cg-surface); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 460px; }
.auth-card.auth-wide { max-width: 760px; }
.pw-meter { height: 4px; }
.pw-meter .progress-bar { width: 0; transition: width .2s ease; }
.pw-meter .progress-bar.s1 { width: 25%; background: #dc3545; }
.pw-meter .progress-bar.s2 { width: 50%; background: #fd7e14; }
.pw-meter .progress-bar.s3 { width: 75%; background: #ffc107; }
.pw-meter .progress-bar.s4 { width: 100%; background: #198754; }
.otp-input { letter-spacing: .5em; font-size: 1.3rem; text-align: center; font-variant-numeric: tabular-nums; }
.qr-box { width: 200px; height: 200px; background: #fff; border: 1px solid #e2e8f0; border-radius: .5rem; padding: 8px; display: grid; place-items: center; }
.qr-box img { width: 100%; height: 100%; image-rendering: pixelated; }
.recovery-codes code { font-size: .85rem; color: var(--cg-ink); }
.error-icon { font-size: 3rem; color: var(--cg-primary); }
.error-code { font-size: .85rem; letter-spacing: .3em; color: #94a3b8; margin-bottom: .25rem; }

/* ---------- Public ---------- */
.public-layout { background: #fff; }
.public-nav { background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 1030; }
.hero { background: radial-gradient(circle at 90% 10%, rgba(var(--cg-primary-rgb), .12), transparent 50%), linear-gradient(180deg, #f8fbfd, #fff); }
.hero h1 { color: var(--cg-ink); line-height: 1.25; }
.hero-panel { border-radius: 1rem; background: var(--cg-ink); color: #e2e8f0; }
.hero-panel .fw-semibold { color: #fff; }
.hero-steps li { padding: .7rem 0; border-bottom: 1px dashed rgba(255, 255, 255, .12); display: flex; gap: .75rem; align-items: center; }
.hero-steps li:last-child { border-bottom: 0; }
.hero-steps .bi { color: var(--cg-accent); font-size: 1.15rem; }
.feature-card { transition: transform .15s ease, box-shadow .15s ease; }
.feature-card:hover { transform: translateY(-3px); box-shadow: 0 .75rem 1.5rem rgba(15, 23, 42, .08) !important; }
.feature-icon { width: 3rem; height: 3rem; border-radius: .8rem; display: grid; place-items: center; font-size: 1.4rem;
  background: rgba(var(--cg-primary-rgb), .1); color: var(--cg-primary); }
.step-number { width: 3rem; height: 3rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 1.2rem;
  background: var(--cg-primary); color: #fff; box-shadow: 0 6px 16px rgba(var(--cg-primary-rgb), .3); }
.legal { max-width: 860px; line-height: 1.9; }
.public-footer a { color: inherit; }

/* ---------- Loading state for forms ---------- */
button.is-loading { position: relative; color: transparent !important; pointer-events: none; }
button.is-loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 1rem; height: 1rem; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .6); border-top-color: transparent; animation: cg-spin .7s linear infinite; }
.btn-outline-primary.is-loading::after, .btn-outline-secondary.is-loading::after, .btn-light.is-loading::after { border-color: var(--cg-primary); border-top-color: transparent; }
@keyframes cg-spin { to { transform: rotate(360deg); } }

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

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .lang-switch, form, .btn { display: none !important; }
  .app-shell { display: block; }
  body { background: #fff; }
}

/* ---------- Scans ---------- */
.scan-progress { height: 1.1rem; }
.scan-progress .progress-bar { width: 0; transition: width .4s ease; }
.result-item .badge { vertical-align: middle; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary.card-header::after { content: "▾"; float: inline-end; opacity: .6; }

/* ---- Phase 4: findings */
.posture-grade { font-size: 2rem; font-weight: 800; }
.posture-badge { width: 64px; height: 64px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 800; color: #fff; flex-shrink: 0; }
.risk-pill { min-width: 2.2rem; }
.risk-big { font-size: 2.4rem; font-weight: 800; line-height: 1; min-width: 3.5rem; text-align: center; }
.findings-table .finding-cell { max-width: 520px; }
.findings-table td .text-truncate { max-width: 480px; }
.comment-internal { background: var(--bs-tertiary-bg); border-inline-start: 3px solid var(--bs-dark); }
.finding-meta dd { margin-bottom: .35rem; }
.nav-sm .nav-link { font-size: .875rem; }
.w-1 { width: 1%; }

/* ---- Phase 5: intelligence */
.intel-table .intel-adv, .intel-adv { max-width: 420px; }
.intel-table .intel-adv .text-truncate { max-width: 400px; }
.app-shell .nav-link .badge.ms-auto { margin-inline-start: auto !important; }
.active-row { background: var(--bs-tertiary-bg); font-weight: 600; }
