/* =====================================================================
   SysAdmin Prep — עיצוב
   RTL · Dark/Light · ללא תלות חיצונית (עובד גם מ-file://)
   ===================================================================== */

:root {
  --bg:        #0d1117;
  --bg-soft:   #161b22;
  --bg-card:   #1c2230;
  --bg-hover:  #232b3a;
  --border:    #2a3240;
  --text:      #e6edf3;
  --text-dim:  #9aa7b8;
  --text-mut:  #6b7686;
  --accent:    #4f9dff;
  --accent-2:  #7c5cff;
  --accent-soft:#1b2a44;
  --green:     #3fb950;
  --green-soft:#10391c;
  --red:       #f85149;
  --red-soft:  #3d1513;
  --amber:     #d29922;
  --shadow:    0 8px 28px rgba(0,0,0,.45);
  --radius:    14px;
  --maxw:      1180px;
  --font: "Segoe UI", "Assistant", "Rubik", "Heebo", system-ui, -apple-system, Arial, sans-serif;
  --mono: "Cascadia Code", "Consolas", "SF Mono", "Menlo", monospace;
}

:root[data-theme="light"] {
  --bg:        #f4f6fb;
  --bg-soft:   #ffffff;
  --bg-card:   #ffffff;
  --bg-hover:  #eef2f9;
  --border:    #dfe5ef;
  --text:      #1a2230;
  --text-dim:  #5b6678;
  --text-mut:  #8a94a6;
  --accent:    #2563eb;
  --accent-2:  #6d3cff;
  --accent-soft:#e6efff;
  --green:     #18794e;
  --green-soft:#d8f3e3;
  --red:       #c4332b;
  --red-soft:  #fbe3e1;
  --amber:     #9a6700;
  --shadow:    0 8px 28px rgba(40,60,110,.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: hidden; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
::selection { background: var(--accent); color: #fff; }

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

.sidebar {
  width: 290px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-inline-start: 1px solid var(--border);
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.main { flex: 1; min-width: 0; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 28px 32px 80px; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.brand .logo {
  width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-size: 22px; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(79,157,255,.35);
}
.brand h1 { font-size: 19px; margin: 0; letter-spacing: -.2px; }
.brand .track { font-size: 11.5px; color: var(--text-mut); margin-top: 2px; }

/* ---------- Progress ring ---------- */
.progress-box {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; margin: 16px 0 10px;
}
.ring { position: relative; width: 54px; height: 54px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: var(--border); }
.ring .fill { stroke: url(#grad); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring .pct {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.progress-meta { font-size: 12.5px; color: var(--text-dim); }
.progress-meta b { color: var(--text); }

/* ---------- Nav ---------- */
.nav-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-mut); margin: 18px 6px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 10px; cursor: pointer;
  color: var(--text-dim); font-size: 14px; user-select: none;
  border: 1px solid transparent; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft); color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.nav-item .ic { font-size: 16px; width: 22px; text-align: center; }
.nav-item .num {
  margin-inline-start: auto; font-size: 11px; color: var(--text-mut);
  font-family: var(--mono);
}
.nav-item .done { margin-inline-start: auto; color: var(--green); font-size: 14px; }
.nav-item .pill {
  margin-inline-start: auto; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; display: grid; place-items: center;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.search {
  flex: 1; min-width: 200px; position: relative;
}
.search input {
  width: 100%; padding: 11px 40px 11px 14px;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 11px; color: var(--text); font-size: 14px; font-family: var(--font);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search .ic { position: absolute; inset-inline-end: 13px; top: 50%; transform: translateY(-50%); color: var(--text-mut); }

.icon-btn {
  width: 42px; height: 42px; flex-shrink: 0;
  border: 1px solid var(--border); background: var(--bg-soft);
  border-radius: 11px; cursor: pointer; font-size: 18px; color: var(--text);
  display: grid; place-items: center; transition: background .15s;
}
.icon-btn:hover { background: var(--bg-hover); }

/* ---------- Hero (home) ---------- */
.hero {
  background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 30px 32px; margin-bottom: 26px;
}
.hero h2 { margin: 0 0 6px; font-size: 27px; letter-spacing: -.4px; }
.hero p { margin: 0; color: var(--text-dim); font-size: 15px; max-width: 70ch; }
.hero .stats { display: flex; gap: 26px; margin-top: 22px; flex-wrap: wrap; }
.hero .stat .n { font-size: 24px; font-weight: 800; color: var(--accent); }
.hero .stat .l { font-size: 12.5px; color: var(--text-mut); }

/* ---------- Module grid (home) ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 16px; }
.mod-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 18px 16px; cursor: pointer;
  transition: transform .14s, border-color .14s, box-shadow .14s;
  position: relative; overflow: hidden;
}
.mod-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb,var(--accent) 45%,var(--border)); box-shadow: var(--shadow); }
.mod-card .top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.mod-card .ic { font-size: 24px; }
.mod-card .num { margin-inline-start: auto; font-family: var(--mono); font-size: 12px; color: var(--text-mut); }
.mod-card h3 { margin: 0 0 6px; font-size: 16px; }
.mod-card p { margin: 0; font-size: 13px; color: var(--text-dim); }
.mod-card .badge-done {
  position: absolute; inset-block-start: 0; inset-inline-start: 0;
  background: var(--green); color: #fff; font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-end-end-radius: 10px;
}

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; margin: 4px 0 24px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 10px 18px; cursor: pointer; font-size: 14px; color: var(--text-dim);
  border-bottom: 2px solid transparent; margin-bottom: -1px; user-select: none;
  transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Module header ---------- */
.mod-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.mod-head .ic {
  width: 56px; height: 56px; border-radius: 14px; flex-shrink: 0;
  background: var(--accent-soft); display: grid; place-items: center; font-size: 28px;
}
.mod-head h2 { margin: 0; font-size: 24px; letter-spacing: -.3px; }
.mod-head .num { font-family: var(--mono); color: var(--text-mut); font-size: 13px; }
.mod-head .summary { color: var(--text-dim); font-size: 14.5px; margin: 4px 0 0; max-width: 75ch; }

.back-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  color: var(--text-dim); font-size: 13.5px; margin-bottom: 16px; user-select: none;
}
.back-btn:hover { color: var(--accent); }

/* ---------- Content sections ---------- */
.section { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.section h4 { margin: 0 0 14px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.section h4::before { content: ""; width: 4px; height: 18px; border-radius: 3px; background: linear-gradient(var(--accent),var(--accent-2)); }

/* list type */
.kv { display: grid; gap: 10px; }
.kv .row { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 14px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.kv .row:last-child { border-bottom: none; }
.kv .k { font-weight: 700; color: var(--text); font-size: 14px; }
.kv .v { color: var(--text-dim); font-size: 14px; }

/* steps */
.steps { counter-reset: s; display: grid; gap: 10px; }
.steps .step { display: flex; gap: 12px; align-items: flex-start; }
.steps .step .n {
  counter-increment: s; flex-shrink: 0;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent); font-weight: 800;
  display: grid; place-items: center; font-size: 13px;
}
.steps .step .n::before { content: counter(s); }
.steps .step .t { padding-top: 2px; font-size: 14px; color: var(--text-dim); }

/* table */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: start; padding: 9px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-mut); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
tbody tr:hover { background: var(--bg-hover); }
td:first-child { font-weight: 600; }
table code, .v code, .k code { font-family: var(--mono); }

/* callout */
.callout {
  background: var(--accent-soft); border: 1px solid color-mix(in srgb,var(--accent) 30%,transparent);
  border-radius: 10px; padding: 14px 16px; font-family: var(--mono); font-size: 14px;
  color: var(--text); direction: ltr; text-align: center;
}

/* ---------- Flashcards ---------- */
.fc-wrap { max-width: 620px; margin: 0 auto; }
.fc-counter { text-align: center; color: var(--text-mut); font-size: 13px; margin-bottom: 12px; }
.flashcard {
  perspective: 1400px; height: 280px; cursor: pointer; margin-bottom: 18px;
}
.flashcard .inner {
  position: relative; width: 100%; height: 100%;
  transition: transform .55s cubic-bezier(.4,.2,.2,1); transform-style: preserve-3d;
}
.flashcard.flip .inner { transform: rotateY(180deg); }
.flashcard .face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px; text-align: center; box-shadow: var(--shadow);
}
.flashcard .front { background: var(--bg-card); }
.flashcard .back { background: linear-gradient(135deg, var(--accent-soft), var(--bg-card)); transform: rotateY(180deg); }
.flashcard .face .label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-mut); margin-bottom: 14px; }
.flashcard .face .q { font-size: 19px; font-weight: 700; }
.flashcard .face .a { font-size: 16px; color: var(--text); }
.flashcard .hint { position: absolute; inset-block-end: 14px; inset-inline: 0; font-size: 11.5px; color: var(--text-mut); }
.fc-controls { display: flex; gap: 10px; justify-content: center; }
.fc-rate { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; min-height: 42px; }
.btn.rate-good { border-color: var(--green); color: var(--green); }
.btn.rate-good:hover { background: var(--green-soft); }
.btn.rate-bad { border-color: var(--red); color: var(--red); }
.btn.rate-bad:hover { background: var(--red-soft); }
.btn.rate-bad.on { background: var(--red-soft); }

/* ---------- Buttons ---------- */
.btn {
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-soft); color: var(--text); cursor: pointer; font-size: 14px;
  font-family: var(--font); transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg,var(--accent),var(--accent-2)); border-color: transparent; color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Quiz ---------- */
.quiz-wrap { max-width: 660px; margin: 0 auto; }
.quiz-progress { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 22px; }
.quiz-progress > div { height: 100%; background: linear-gradient(90deg,var(--accent),var(--accent-2)); transition: width .4s; }
.q-toprow { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.q-text { font-size: 19px; font-weight: 700; margin-bottom: 10px; }
.q-num { color: var(--text-mut); font-size: 13px; font-weight: 500; }
.q-timer { font-family: var(--mono); font-size: 14px; color: var(--accent); font-weight: 700; }
.q-source { font-size: 12.5px; color: var(--text-mut); margin-bottom: 16px; }
.exam-choices { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 24px 0; }
.options { display: grid; gap: 11px; }
.option {
  padding: 14px 16px; border: 1px solid var(--border); border-radius: 11px;
  background: var(--bg-card); cursor: pointer; font-size: 14.5px;
  transition: border-color .15s, background .15s; display: flex; align-items: center; gap: 12px;
}
.option:hover { border-color: var(--accent); }
.option .mark { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border); flex-shrink: 0; display: grid; place-items: center; font-size: 13px; }
.option.correct { border-color: var(--green); background: var(--green-soft); }
.option.correct .mark { background: var(--green); border-color: var(--green); color: #fff; }
.option.wrong { border-color: var(--red); background: var(--red-soft); }
.option.wrong .mark { background: var(--red); border-color: var(--red); color: #fff; }
.option.disabled { cursor: default; }
.explain {
  margin-top: 16px; padding: 14px 16px; border-radius: 11px;
  background: var(--bg-soft); border: 1px solid var(--border);
  font-size: 14px; color: var(--text-dim); display: none;
}
.explain.show { display: block; }
.explain b { color: var(--text); }
.quiz-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; }

/* quiz result */
.result { text-align: center; padding: 30px 20px; }
.result .score { font-size: 54px; font-weight: 800; background: linear-gradient(135deg,var(--accent),var(--accent-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.result .msg { font-size: 18px; margin: 6px 0 4px; }
.result .sub { color: var(--text-dim); margin-bottom: 24px; }

/* ---------- Reference page ---------- */
.ref-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.ref-tab { padding: 7px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--bg-soft); cursor: pointer; font-size: 13px; color: var(--text-dim); }
.ref-tab.active { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }

/* ---------- Search results ---------- */
.sr-item { background: var(--bg-card); border: 1px solid var(--border); border-radius: 11px; padding: 14px 16px; margin-bottom: 10px; cursor: pointer; transition: border-color .15s; }
.sr-item:hover { border-color: var(--accent); }
.sr-item .crumb { font-size: 12px; color: var(--text-mut); margin-bottom: 4px; }
.sr-item .txt { font-size: 14px; }
mark { background: color-mix(in srgb,var(--accent) 35%,transparent); color: var(--text); border-radius: 3px; padding: 0 2px; }

/* ---------- Misc ---------- */
.empty { text-align: center; color: var(--text-mut); padding: 60px 20px; font-size: 15px; }
.mobile-toggle { display: none; }
.fade { animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-mut); }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .app { display: block; }
  .main { width: 100%; }
  .sidebar {
    position: fixed; right: 0; left: auto; top: 0; z-index: 50;
    width: min(310px, 86vw); height: 100vh; height: 100dvh;
    border-inline-start: none; border-inline-end: 1px solid var(--border);
    transform: translateX(100%); transition: transform .25s; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-toggle { display: grid; }
  .container { padding: 16px 14px 72px; max-width: 100%; }
  .hero { padding: 22px 18px; }
  .hero h2 { font-size: 21px; }
  .hero p { font-size: 14px; }
  .hero .stats { gap: 16px 22px; margin-top: 18px; }
  .grid { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; }
  .mod-head .ic { width: 48px; height: 48px; font-size: 24px; }
  .mod-head h2 { font-size: 19px; }
  .kv .row { grid-template-columns: 1fr; gap: 4px; }
  .exam-choices { flex-direction: column; }
  .exam-choices .btn { width: 100%; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; display: none; }
  .scrim.show { display: block; }
}

@media (max-width: 420px) {
  .hero h2 { font-size: 19px; }
  .hero .stats .n { font-size: 21px; }
  .fc-controls { flex-wrap: wrap; }
  .q-text { font-size: 17px; }
}
