:root {
  color-scheme: light;
  --teal: #0f9f96;
  --teal-bright: #31d6c2;
  --teal-light: #d9faf4;
  --mint: #f4fbfa;
  --green: #f7fdfc;
  --orange: #f4b860;
  --orange-strong: #bd7830;
  --violet: #8574e8;
  --navy: #102a43;
  --ink: #173b4d;
  --text: #263746;
  --muted: #718394;
  --line: #e1ebef;
  --surface: rgba(255, 255, 255, .92);
  --shadow: 0 18px 50px rgba(16, 42, 67, .08);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Tahoma, Arial, sans-serif;
  background:
    radial-gradient(ellipse at 8% 12%, rgba(49, 214, 194, .12), transparent 32rem),
    radial-gradient(ellipse at 94% 82%, rgba(133, 116, 232, .09), transparent 30rem),
    var(--mint);
  color: var(--text);
  line-height: 1.75;
}
body::before {
  content: "";
  position: fixed;
  z-index: -1;
  width: 340px;
  height: 340px;
  top: 20%;
  left: -210px;
  border-radius: 50%;
  border: 1px solid rgba(15, 159, 150, .12);
  box-shadow: 0 0 0 28px rgba(15, 159, 150, .025), 0 0 0 58px rgba(133, 116, 232, .025);
  pointer-events: none;
}
button { font: inherit; cursor: pointer; transition: transform .2s ease, box-shadow .2s ease, background .2s ease; }
button:hover { transform: translateY(-1px); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(49, 214, 194, .55);
  outline-offset: 3px;
}
input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #d5e2e8;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  transition: border-color .2s ease, box-shadow .2s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 159, 150, .1);
}
::placeholder { color: #94a5b3; }

/* شريط علوي زجاجي بهوية تقنية */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 13px clamp(16px, 3vw, 38px);
  background: rgba(13, 39, 59, .94);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  box-shadow: 0 8px 30px rgba(16, 42, 67, .16);
  backdrop-filter: blur(18px);
}
.topbar h1 { margin: 0; font-size: 1.35rem; font-weight: 800; letter-spacing: -.4px; white-space: nowrap; }
.topbar h1::before {
  content: "✦";
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-inline-end: 10px;
  border-radius: 12px;
  color: #082f39;
  background: linear-gradient(135deg, var(--teal-bright), #a6f4e8);
  box-shadow: 0 5px 18px rgba(49, 214, 194, .22);
}
.topbar input {
  flex: 1;
  max-width: 620px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  padding: 10px 17px;
  color: #fff;
  background: rgba(255,255,255,.09);
}
.topbar input::placeholder { color: #c1d0dc; }
.topbar input:focus { background: rgba(255,255,255,.14); border-color: var(--teal-bright); box-shadow: 0 0 0 4px rgba(49,214,194,.1); }
.actions { display: flex; gap: 9px; align-items: center; }
.topbar button {
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  background: rgba(255,255,255,.07);
  color: #fff;
  white-space: nowrap;
}
.topbar button:hover { background: rgba(49,214,194,.17); border-color: rgba(49,214,194,.6); }
#logout-btn { color: #f8d8d4; }
.search-results {
  position: absolute;
  top: calc(100% - 4px);
  right: min(24%, 360px);
  width: min(620px, 90vw);
  max-height: 60vh;
  overflow: auto;
  margin: 0;
  padding: 8px;
  list-style: none;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(16,42,67,.2);
}
.search-results li { padding: 10px 12px; border-bottom: 1px solid #edf2f5; cursor: pointer; border-radius: 10px; }
.search-results li:hover { background: #effbf9; }
.search-results small { display: block; color: var(--muted); }

/* تخطيط مساحة العمل */
.layout { display: flex; min-height: calc(100vh - 66px); max-width: 1800px; margin: 0 auto; }
.sidebar {
  width: 290px;
  flex-shrink: 0;
  background: rgba(255,255,255,.72);
  border-left: 1px solid rgba(215,230,235,.9);
  padding: 22px 16px;
  overflow: auto;
  position: sticky;
  top: 66px;
  height: calc(100vh - 66px);
  backdrop-filter: blur(14px);
}
.sidebar h3 {
  margin: 18px 8px 8px;
  padding: 0 0 8px;
  font-size: .9rem;
  font-weight: 800;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.sidebar a {
  display: block;
  margin: 3px 0;
  padding: 9px 12px;
  border-radius: 11px;
  color: #526879;
  text-decoration: none;
  transition: color .2s ease, background .2s ease, transform .2s ease;
}
.sidebar a:hover { background: #eaf8f6; color: #087f79; transform: translateX(-2px); }
.sidebar a.active {
  background: linear-gradient(100deg, #d9faf4, #f0fbfa);
  color: #087f79;
  font-weight: 800;
  box-shadow: inset -3px 0 0 var(--teal);
}
.content {
  flex: 1;
  min-width: 0;
  margin: clamp(14px, 2.4vw, 32px);
  padding: clamp(22px, 3.4vw, 48px);
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.95);
  border-radius: 24px;
  box-shadow: var(--shadow);
  min-height: 420px;
  animation: rise-in .45s ease both;
}
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.hint { color: var(--muted); }
.crumb { display: inline-flex; align-items: center; gap: 8px; color: var(--teal); font-weight: 800; font-size: .9rem; }
.crumb::before { content: ""; width: 20px; height: 2px; border-radius: 4px; background: var(--orange); }
.page h2 { margin: 8px 0 18px; color: var(--navy); font-size: clamp(1.65rem, 3vw, 2.3rem); line-height: 1.35; letter-spacing: -.5px; }
.page .body { font-size: 1.06rem; padding: 12px 0 22px; line-height: 2; overflow-wrap: anywhere; }
.media-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding: 15px 17px;
  background: linear-gradient(120deg, #fffaf1, #fff);
  border: 1px solid #f3dfbf;
  border-right: 4px solid var(--orange);
  border-radius: 14px;
  transition: transform .2s ease, box-shadow .2s ease;
}
.media-card:hover { transform: translateY(-2px); box-shadow: 0 10px 25px rgba(189,120,48,.09); }
.media-card a { color: var(--ink); font-weight: 700; text-decoration-thickness: 1px; text-underline-offset: 3px; overflow-wrap: anywhere; }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #e2f8f4;
  color: #087f79;
  font-size: .8rem;
  font-weight: 800;
}

/* لوحة الإدارة */
.admin h2 { color: var(--navy); margin: 0 0 8px; font-size: 1.8rem; }
.admin h3 { color: var(--ink); margin-top: 26px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 18px; }
.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  background: linear-gradient(145deg, #fff, #f7fcfb);
  border: 1px solid var(--line);
  border-top: 3px solid var(--teal);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(16,42,67,.04);
}
.card label { font-weight: 800; color: var(--ink); margin-top: 6px; }
.admin button, .box button {
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: linear-gradient(110deg, #0c948b, #19b8a7);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(15,159,150,.13);
}
.admin button:hover, .box button:hover { box-shadow: 0 9px 22px rgba(15,159,150,.22); }
.admin button.danger { background: #fff1ed; border-color: #f7d4cc; color: #b44332; box-shadow: none; }
.admin button[data-act="back"] { background: #eaf0f4; color: #42586a; box-shadow: none; }
.row { display: flex; flex-wrap: wrap; gap: 9px; }
.list { list-style: none; padding: 0; margin: 0; }
.list li, .item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 10px;
  border-bottom: 1px solid #eaf0f3;
}
.list li span, .item span { flex: 1; min-width: 140px; }
.list small { color: var(--muted); margin-inline-start: 6px; }
.msg { padding: 10px 14px; border-radius: 12px; background: #e2f8f4; color: #087f79; border: 1px solid #c6eee7; }
.msg:empty { display: none; }

/* تسجيل الدخول */
body:has(.box) {
  display: grid;
  place-items: center;
  padding: 28px 18px;
  background:
    radial-gradient(circle at 15% 18%, rgba(49,214,194,.18), transparent 25rem),
    radial-gradient(circle at 90% 80%, rgba(133,116,232,.15), transparent 28rem),
    linear-gradient(145deg, #f2fbfa, #f5f7fc);
}
body:has(.box)::after {
  content: "";
  position: fixed;
  width: 220px;
  height: 220px;
  right: -100px;
  top: -80px;
  border-radius: 50%;
  border: 1px solid rgba(15,159,150,.2);
  box-shadow: 0 0 0 24px rgba(15,159,150,.04), 0 0 0 50px rgba(133,116,232,.04);
  pointer-events: none;
}
.box {
  position: relative;
  z-index: 1;
  width: min(100%, 440px);
  margin: 0 auto;
  padding: clamp(26px, 5vw, 42px);
  background: rgba(255,255,255,.91);
  border: 1px solid rgba(255,255,255,.95);
  border-radius: 26px;
  border-top: 4px solid var(--teal);
  box-shadow: 0 24px 80px rgba(16,42,67,.12);
  backdrop-filter: blur(18px);
  animation: rise-in .5s ease both;
}
.box h1 { margin: 0 0 8px; color: var(--navy); font-size: 1.85rem; letter-spacing: -.5px; }
.box h1::before {
  content: "✦";
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 20px;
  border-radius: 16px;
  color: #073a42;
  background: linear-gradient(135deg, var(--teal-bright), #b6f6ec);
  box-shadow: 0 8px 22px rgba(49,214,194,.2);
}
.box label { display: block; margin: 18px 0 7px; color: var(--ink); font-weight: 800; }
.box input { padding: 13px 14px; }
.box button { width: 100%; margin-top: 22px; padding: 13px; font-size: 1rem; }
.box button:disabled { opacity: .6; cursor: wait; transform: none; }
#message { color: #b44332; min-height: 1.5em; margin: 12px 0 0; font-size: .92rem; }

/* تقليل الحركة لمن يفضّل ذلك */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* الأجهزة اللوحية والهواتف */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 12px; }
  .topbar input { order: 3; flex-basis: 100%; max-width: none; }
  .search-results { top: 100%; right: 12px; width: calc(100% - 24px); }
  .layout { flex-direction: column; }
  .sidebar { width: auto; position: static; height: auto; max-height: 34vh; border-left: 0; border-bottom: 1px solid var(--line); }
  .sidebar h3 { margin-top: 8px; }
  .content { margin: 14px; padding: 24px; border-radius: 19px; }
}
@media (max-width: 520px) {
  .topbar { padding: 12px 14px; }
  .topbar h1 { font-size: 1.15rem; }
  .topbar h1::before { width: 30px; height: 30px; margin-inline-end: 7px; }
  .actions { width: 100%; }
  .actions button { flex: 1; }
  .content { margin: 10px; padding: 19px 16px; min-height: 320px; }
  .sidebar { padding: 12px; }
  .box { border-radius: 20px; }
  .list li, .item { align-items: stretch; }
}


/* 3D ambience and subtle component motion (decorative only; app controls stay interactive) */
#three-scene {
  position: fixed;
  z-index: 0;
  left: 8px;
  bottom: -20px;
  width: clamp(180px, 25vw, 320px);
  aspect-ratio: 1;
  opacity: .38;
  pointer-events: none;
  filter: saturate(.9);
  contain: layout paint;
}
#three-scene canvas { display: block; width: 100% !important; height: 100% !important; }
#three-scene.scene-fallback {
  border-radius: 50%;
  background: radial-gradient(circle at 48% 45%, rgba(49,214,194,.16), rgba(133,116,232,.08) 42%, transparent 70%);
}
.topbar, .sidebar, .content { position: relative; }
.topbar { position: sticky; }
.sidebar { z-index: 1; }
.content { z-index: 1; }
.card, .media-card, .sidebar a, .admin button {
  -webkit-tap-highlight-color: transparent;
}
.card {
  transition: transform .24s ease, box-shadow .24s ease, border-color .24s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 32px rgba(16,42,67,.08);
  border-color: #c7e9e4;
}
.admin button:not(.danger):hover {
  background: linear-gradient(110deg, #087d77, #0fa99b);
}
.page h2 {
  background: linear-gradient(100deg, var(--navy), #147f7b 70%, #7d6cce);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  width: fit-content;
  max-width: 100%;
}
@media (max-width: 900px) {
  #three-scene { left: -28px; bottom: -35px; width: 210px; opacity: .24; }
}
@media (max-width: 520px) {
  #three-scene { left: -42px; bottom: -48px; width: 175px; opacity: .18; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .media-card, .sidebar a, .admin button { transition: none !important; }
}


/* Cursor-following spotlight: a small React Bits-inspired interaction */
.content, .card, .media-card {
  background-image:
    radial-gradient(190px circle at var(--spotlight-x, 50%) var(--spotlight-y, 50%), rgba(49,214,194,.09), transparent 72%),
    linear-gradient(145deg, rgba(255,255,255,.98), rgba(247,252,251,.96));
}
.content { background-color: rgba(255,255,255,.92); }
.media-card {
  background-image:
    radial-gradient(170px circle at var(--spotlight-x, 50%) var(--spotlight-y, 50%), rgba(244,184,96,.12), transparent 72%),
    linear-gradient(120deg, #fffaf1, #fff);
}
.card { position: relative; overflow: hidden; }
