/* ────────────────────────────────────────────────
   COMMON SHARED STYLES
   Used by all pages (landing + risk-matrix + future tools)
──────────────────────────────────────────────── */

/* ── Global Reset & RTL Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary:   #2e2a35;
  --bg-secondary: #3d3644;
  --bg-card:      rgba(75, 68, 83, 0.55);
  --bg-card-solid:#3d3644;
  --bg-hover:     rgba(78, 131, 151, 0.12);
  --border:       rgba(190, 166, 160, 0.18);
  --border-solid: #5e4555;
  --text-primary: #f2ede7;
  --text-secondary: #c2b3a2;
  --text-muted:   #9b7f8a;
  --accent:       #4e8397;
  --accent-light: #6faebb;
  --accent-glow:  rgba(78, 131, 151, 0.2);
  --rose:         #bea6a0;
  --rose-glow:    rgba(190, 166, 160, 0.15);
  --risk-low:     #22c55e;
  --risk-medium:  #f59e0b;
  --risk-high:    #f97316;
  --risk-critical:#ef4444;
  --shadow-lg:    0 10px 40px rgba(0,0,0,0.35);
  --shadow-glass: 0 8px 32px rgba(0,0,0,0.2);
  --radius:       14px;
  --radius-sm:    8px;
}

.light-mode {
  --bg-primary:   #f2ede7;
  --bg-secondary: #ffffff;
  --bg-card:      rgba(255, 255, 255, 0.75);
  --bg-card-solid:#ffffff;
  --bg-hover:     rgba(78, 131, 151, 0.06);
  --border:       rgba(190, 166, 160, 0.3);
  --border-solid: #d5c7c1;
  --text-primary: #2e2a35;
  --text-secondary: #504538;
  --text-muted:   #8d7a63;
  --accent:       #3d6f82;
  --accent-light: #4e8397;
  --accent-glow:  rgba(78, 131, 151, 0.1);
  --rose:         #a88b84;
  --rose-glow:    rgba(190, 166, 160, 0.12);
  --shadow-lg:    0 4px 24px rgba(0,0,0,0.06);
  --shadow-glass: 0 8px 32px rgba(0,0,0,0.06);
}

html {
  scroll-behavior: smooth;
}

html, body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.4s ease, color 0.4s ease;
  direction: rtl;
  overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rose); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  font-family: 'Cairo', sans-serif; font-size: 13px; font-weight: 600;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, #4e8397, #3d6f82);
  color: #f2ede7;
  box-shadow: 0 2px 10px rgba(78, 131, 151, 0.25);
}
.btn-primary:hover {
  opacity: 0.92; transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(78, 131, 151, 0.35);
}
.btn-danger  { background: rgba(239,68,68,0.12); color: #ef4444; border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover  { background: rgba(239,68,68,0.2); }
.btn-ghost   { background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover   { color: var(--text-primary); background: var(--rose-glow); }
.btn-success { background: rgba(34,197,94,0.12); color: #22c55e; border: 1px solid rgba(34,197,94,0.2); }
.btn-success:hover { background: rgba(34,197,94,0.2); }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-icon { padding: 7px; border-radius: 8px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(46, 42, 53, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200; display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.light-mode .modal-backdrop {
  background: rgba(213, 202, 189, 0.6);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: 18px; padding: 32px;
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.modal-title  { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-close  {
  background: var(--bg-hover); border: 1px solid var(--border); cursor: pointer; color: var(--text-muted);
  font-size: 14px; line-height: 1; padding: 8px 10px; border-radius: 8px;
  transition: all 0.2s;
}
.modal-close:hover { color: var(--text-primary); background: var(--rose-glow); }

/* ── Form ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: 'Cairo', sans-serif; font-size: 13px;
  transition: all 0.25s;
  appearance: none; -webkit-appearance: none;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-muted); }
.form-error { font-size: 11px; color: #ef4444; margin-top: 4px; display: none; }
.form-group.error .form-control { border-color: #ef4444; }
.form-group.error .form-error { display: block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Toast Notifications ── */
#toast-container { position: fixed; bottom: 24px; left: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--bg-card-solid);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  min-width: 280px;
  animation: toastIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 4px solid var(--accent);
  font-size: 13px; font-weight: 500;
}
.toast.success { border-right-color: #22c55e; }
.toast.success i { color: #22c55e; }
.toast.warning { border-right-color: #f59e0b; }
.toast.warning i { color: #f59e0b; }
.toast.error   { border-right-color: #ef4444; }
.toast.error i { color: #ef4444; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(-24px); } }
.toast.out { animation: toastOut 0.3s ease forwards; }

/* ── Skeleton loader ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Notification Bell & Panel ── */
.notif-bell {
  position: relative;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  transition: all 0.25s;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notif-bell:hover { background: var(--accent-glow); color: var(--accent); }
.notif-bell.has-notifs { animation: bellRing 0.6s ease; }
@keyframes bellRing {
  0% { transform: rotate(0); }
  15% { transform: rotate(14deg); }
  30% { transform: rotate(-14deg); }
  45% { transform: rotate(8deg); }
  60% { transform: rotate(-8deg); }
  75% { transform: rotate(3deg); }
  100% { transform: rotate(0); }
}
#notif-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: 'Cairo', sans-serif;
  padding: 0 4px;
  box-shadow: 0 2px 6px rgba(239,68,68,0.4);
}

.notif-panel {
  position: fixed;
  top: 72px;
  left: 24px;
  width: 380px;
  max-height: 500px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideDown 0.25s ease;
}
.notif-panel.open { display: flex; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.notif-panel-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.notif-panel-title i { color: var(--accent); }
.notif-panel-actions { display: flex; gap: 6px; }
.notif-panel-actions button {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Cairo', sans-serif;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.2s;
}
.notif-panel-actions button:hover { color: var(--accent); border-color: var(--accent); }

#notif-list {
  overflow-y: auto;
  max-height: 420px;
  flex: 1;
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item.read { opacity: 0.55; }
.notif-item:last-child { border-bottom: none; }

.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.notif-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.notif-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 6px;
}

/* ── Notification Settings Modal ── */
.notif-settings-form .form-group { margin-bottom: 18px; }
.notif-settings-form .checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}
.notif-settings-form .checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}
.notif-settings-form .checkbox-row label {
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
}

/* ── Print Styles ── */
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body { background: white !important; color: #222 !important; font-size: 11pt; }
  #sidebar, #sidebar-overlay, .topbar-btn, .btn, #toast-container,
  .cell-tooltip, .notif-bell, .notif-panel, .modal-backdrop,
  .filter-bar, .pagination, button, .search-wrap, .data-action button,
  .notif-panel, #notif-badge { display: none !important; }
  #app { display: block !important; }
  #main { margin: 0 !important; }
  #main::before { display: none !important; }
  #topbar {
    position: static !important;
    background: white !important;
    border-bottom: 2px solid #333 !important;
    backdrop-filter: none !important;
    padding: 10px 0 !important;
    height: auto !important;
  }
  #topbar h1 { color: #222 !important; font-size: 18pt !important; }
  #content { padding: 16px 0 !important; }
  .card {
    background: white !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .card-title { color: #222 !important; }
  .stat-card {
    background: white !important;
    border: 1px solid #ddd !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }
  .stat-label, .stat-icon { color: #555 !important; }
  .matrix-cell { border: 1px solid #999 !important; }
  table { border-collapse: collapse; }
  th { background: #eee !important; color: #333 !important; }
  td { color: #222 !important; border-color: #ccc !important; }
  .risk-badge, .status-badge { border: 1px solid currentColor; }
  @page { size: A4; margin: 15mm; }
}

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Demo Banner ── */
#demo-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(249, 115, 22, 0.12));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(245, 158, 11, 0.3);
  padding: 0;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
  animation: demoBannerSlide 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes demoBannerSlide {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.demo-banner-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.demo-banner-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}
.demo-banner-info > i {
  font-size: 18px;
  color: #f59e0b;
  flex-shrink: 0;
}
.demo-banner-info span {
  line-height: 1.6;
}
.demo-banner-info strong {
  color: #f59e0b;
}

.demo-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.demo-btn-clear {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #ef4444;
  border-radius: 8px;
  font-family: 'Cairo', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
}
.demo-btn-clear:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.45);
  transform: translateY(-1px);
}

.demo-btn-dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
.demo-btn-dismiss:hover {
  color: var(--text-primary);
  background: var(--rose-glow);
}

/* Push body content down when banner is present */
body:has(#demo-banner) .landing-nav,
body:has(#demo-banner) .hero {
  margin-top: 48px;
}
body:has(#demo-banner) #app {
  padding-top: 48px;
}

@media print {
  #demo-banner { display: none !important; }
  .tools-footer { display: none !important; }
}

/* ── Tools Footer (shared across tool pages) ── */
.tools-footer {
  margin-top: auto;
  padding: 24px 28px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  text-align: center;
}
.tools-footer-content p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.tools-footer-content p i {
  margin-left: 6px;
  color: var(--accent);
}
.tools-footer-credit {
  font-size: 11px !important;
  opacity: 0.7;
}

@media (max-width: 768px) {
  .demo-banner-content {
    flex-direction: column;
    gap: 10px;
    padding: 10px 14px;
  }
  .demo-banner-info {
    font-size: 12px;
    text-align: center;
  }
  body:has(#demo-banner) .landing-nav,
  body:has(#demo-banner) .hero {
    margin-top: 100px;
  }
  body:has(#demo-banner) #app {
    padding-top: 100px;
  }
}
