/* Saqi (ساقي). By Talal Al-Naim and Sarah Al-Falah, AI Club, King Faisal University. */
@font-face { font-family: Saqi; src: url(fonts/noto-sans-arabic-arabic-400-normal.woff); font-weight: 400; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Saqi; src: url(fonts/noto-sans-arabic-arabic-700-normal.woff); font-weight: 700; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Saqi; src: url(fonts/noto-sans-latin-400-normal.woff); font-weight: 400; unicode-range: U+0000-024F; }
@font-face { font-family: Saqi; src: url(fonts/noto-sans-latin-700-normal.woff); font-weight: 700; unicode-range: U+0000-024F; }

:root {
  --bg: #efe6d6; --card: #f8f3ea; --card2: #fffaf2; --line: #e3d7c2; --ink: #2b2a24; --mute: #7d7465;
  --green: #1f4a3f; --green2: #2d6153; --gold: #c9a45c; --water: #2f7fb5;
  --ok: #5a9a3c; --warn: #d9a21b; --bad: #c8443a; --r: 22px; --shadow: 0 10px 30px rgba(80, 60, 30, .10);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; color: var(--ink); font-family: Saqi, Tahoma, sans-serif;
  background: radial-gradient(1200px 600px at 85% -10%, #f7f0e3, transparent), radial-gradient(900px 500px at 0% 110%, #e6d9c2, transparent), var(--bg); }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; font-weight: 700; font-size: 14px; border: 1px solid transparent; border-radius: 14px; padding: 10px 16px;
         background: var(--green); color: #fff; cursor: pointer; transition: background .15s, border-color .15s, transform .1s; }
button:hover { background: var(--green2); } button:active { transform: translateY(1px); }
button.ghost { background: var(--card2); color: var(--green); border-color: var(--line); }
button.ghost:hover { border-color: var(--green); }
button:focus-visible, input:focus-visible, .icon-btn:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
button:disabled { opacity: .5; cursor: wait; }

.app { display: grid; grid-template-columns: 230px 1fr 390px; gap: 18px; height: 100%; padding: 18px; }

/* sidebar (right in RTL) */
.sidebar { background: linear-gradient(180deg, #24574a, #1a3f35); color: #eef3ef; border-radius: 26px; display: flex; flex-direction: column;
           padding: 26px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.sidebar::after { content: ""; position: absolute; inset: auto -30px -30px auto; width: 200px; height: 200px; opacity: .12;
  background: repeating-linear-gradient(115deg, var(--gold) 0 2px, transparent 2px 14px); border-radius: 50%; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-bottom: 30px; }
.brand .logo { width: 54px; height: 54px; color: var(--gold); }
.brand b { font-size: 34px; line-height: 1.2; } .brand span { letter-spacing: .4em; font-size: 12px; color: #c8d6cf; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav .tab { display: flex; align-items: center; gap: 12px; background: transparent; color: #dfe9e4; font-weight: 400; font-size: 15.5px; text-align: start; padding: 12px 14px; }
.nav .tab svg { width: 22px; height: 22px; flex: none; }
.nav .tab:hover { background: rgba(255, 255, 255, .07); }
.nav .tab.active { background: rgba(255, 255, 255, .14); color: #fff; font-weight: 700; }
.side-foot { margin-top: auto; text-align: center; position: relative; z-index: 1; display: flex; flex-direction: column; gap: 2px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .12); }
.side-foot small { font-size: 11.5px; color: var(--gold); letter-spacing: .04em; margin-bottom: 2px; }
.side-foot a { color: #fff; font-weight: 700; font-size: 15px; text-decoration: none; border-radius: 8px; padding: 2px 6px; }
.side-foot a:hover { color: var(--gold); text-decoration: underline; text-underline-offset: 4px; }
.side-foot a:focus-visible { outline: 2px solid var(--gold); }
.side-foot span { font-size: 11.5px; color: #b9c9c1; margin-top: 6px; line-height: 1.7; }

/* center column */
.center { display: flex; flex-direction: column; gap: 16px; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 12px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--card2); border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; font-size: 14.5px; box-shadow: var(--shadow); }
.chip svg { width: 18px; height: 18px; color: var(--green); }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--mute); background: var(--card2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(90, 154, 60, .18); }
.status.demo i { background: var(--warn); box-shadow: 0 0 0 3px rgba(217, 162, 27, .2); } .status.demo { color: #8a6a12; }
#newVisitor { margin-inline-start: auto; border-radius: 999px; }

.stage { position: relative; flex: 1; min-height: 0; border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); background: #e9dfcc; }
#view3d, #c { width: 100%; height: 100%; display: block; }
.overlay { position: absolute; pointer-events: none; }
.overlay.top { top: 14px; inset-inline-start: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.pill, .legend span, .tip, .overlay.center, .overlay.caption, .actionbar, .viewctl, .flabel {
  background: rgba(255, 251, 243, .9); border: 1px solid rgba(227, 215, 194, .9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 6px 18px rgba(60, 45, 20, .12); }
.pill.scenario { border-radius: 16px; padding: 8px 14px; display: flex; flex-direction: column; }
.pill small { font-size: 11px; color: var(--mute); } #scenarioLabel { font-weight: 700; font-size: 16px; }
.legend { display: flex; gap: 6px; font-size: 12.5px; }
.legend span { border-radius: 999px; padding: 4px 10px; display: inline-flex; align-items: center; gap: 6px; }
.legend span::before { content: ""; width: 9px; height: 9px; border-radius: 50%; }
.legend .ok::before { background: var(--ok); } .legend .warn::before { background: var(--warn); } .legend .bad::before { background: var(--bad); }
.viewctl { position: absolute; bottom: 16px; inset-inline-end: 16px; display: flex; gap: 4px; padding: 4px; border-radius: 999px; }
.viewctl button { background: transparent; color: var(--ink); padding: 7px 12px; border-radius: 999px; font-size: 13px; }
.viewctl button.on { background: var(--green); color: #fff; }
.viewctl .icon svg { width: 18px; height: 18px; display: block; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.flabel { position: absolute; transform: translate(-50%, calc(-100% - 10px)); border-radius: 14px; padding: 6px 12px; font-size: 13.5px; font-weight: 700; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.flabel small { color: var(--mute); font-weight: 400; }
.flabel::after { content: ""; position: absolute; left: 50%; bottom: -12px; width: 2px; height: 12px; background: rgba(255, 251, 243, .95); transform: translateX(-50%); }
.overlay.center { top: 40%; left: 50%; transform: translate(-50%, -50%); color: var(--water); padding: 12px 24px; border-radius: 16px; font-size: 22px; font-weight: 700; }
.overlay.caption { bottom: 70px; left: 50%; transform: translateX(-50%); padding: 12px 22px; border-radius: 16px; font-size: 19px; white-space: nowrap; }
.tip { position: absolute; border-radius: 12px; padding: 8px 12px; font-size: 13px; pointer-events: none; line-height: 1.7; }
.tip b { color: var(--green); }
.dock { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 6px; box-shadow: var(--shadow); }
.presets { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.presets .alt:first-of-type { margin-inline-start: auto; }
.presets button { background: transparent; color: var(--ink); font-weight: 400; font-size: 13px; padding: 7px 11px; border-radius: 12px; }
.presets button:hover { background: rgba(31, 74, 63, .07); }
.presets button.on { background: rgba(31, 74, 63, .12); color: var(--green); font-weight: 700; }
.presets button.alt { background: var(--green); color: #fff; font-weight: 700; }
.presets .sep { width: 1px; background: var(--line); margin: 4px; }
.actionbar { position: absolute; top: 14px; inset-inline-end: 14px; width: 320px; max-height: 50%; border-radius: 16px; padding: 10px 12px; font-size: 12.5px; overflow: auto; }
.actionbar[hidden] { display: none; }
.actionbar b { color: var(--mute); font-size: 11px; }
.actionbar ol { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.actionbar li { padding: 4px 8px; border-radius: 8px; background: rgba(31, 74, 63, .05); }
.actionbar li:first-child { color: var(--green); background: rgba(31, 74, 63, .12); font-weight: 700; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; box-shadow: var(--shadow); min-width: 0; }
.card > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card small { font-size: 14px; font-weight: 700; }
.card b { font-size: 24px; font-variant-numeric: tabular-nums; }
.card b.alert { color: var(--bad); }
.card span { font-size: 12.5px; color: var(--mute); line-height: 1.6; }
.card .ico { width: 44px; height: 44px; padding: 10px; border-radius: 50%; background: var(--card2); border: 1px solid var(--line); color: var(--green); flex: none; }
.card .ico.sun { color: var(--gold); }

/* assistant (left in RTL) */
.assistant { background: var(--card); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.hello { display: flex; gap: 14px; align-items: center; padding: 20px 20px 16px; background: linear-gradient(180deg, var(--card2), var(--card)); border-bottom: 1px solid var(--line); }
.hello h2 { margin: 0; font-size: 22px; color: var(--green); } .hello p { margin: 4px 0 0; font-size: 13.5px; color: var(--mute); line-height: 1.7; }
.avatar { position: relative; width: 70px; height: 70px; flex: none; border-radius: 22px; background: linear-gradient(160deg, #2d6153, #1a3f35); display: grid; place-items: center; overflow: hidden; }
.avatar svg { width: 44px; height: 44px; color: #fff; } .avatar svg path { fill: rgba(255, 255, 255, .15); stroke: #fff; } .avatar svg circle { fill: #7fe0ff; stroke: none; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tabpane { display: none; flex: 1; flex-direction: column; padding: 14px 18px 18px; gap: 10px; min-height: 0; overflow-y: auto; }
.tabpane.active { display: flex; }
.tabpane h3 { margin: 0; font-size: 18px; color: var(--green); }
#messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.msg { padding: 10px 14px; border-radius: 18px; max-width: 92%; line-height: 1.8; font-size: 15.5px; white-space: pre-wrap; }
.msg.me { align-self: flex-start; background: var(--green); color: #fff; border-end-start-radius: 6px; }
.msg.bot { align-self: flex-end; background: var(--card2); border: 1px solid var(--line); border-end-end-radius: 6px; }
.msg.bot::before { content: "ساقي"; display: block; font-size: 11.5px; color: var(--green); font-weight: 700; }
.msg img { max-width: 100%; border-radius: 12px; display: block; margin-bottom: 6px; }
.msg.typing { color: var(--mute); }
.msg.typing::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-inline-start: 6px; border-radius: 50%; background: var(--green); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.quick-title { font-weight: 700; font-size: 15px; }
.chips { display: flex; flex-direction: column; gap: 6px; max-height: 32%; overflow-y: auto; flex: none; }
.chips button { background: var(--card2); color: var(--ink); border-color: var(--line); font-weight: 400; font-size: 14px; text-align: start; padding: 9px 14px; }
.chips button:hover { border-color: var(--green); background: #fff; }
#chatForm { display: flex; gap: 6px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 5px; }
#msg { flex: 1; font: inherit; font-size: 15.5px; padding: 8px; color: var(--ink); background: transparent; border: 0; min-width: 0; }
#msg:focus-visible { outline: none; }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: var(--mute); cursor: pointer; }
.icon-btn:hover { color: var(--green); } .icon-btn svg { width: 22px; height: 22px; }
.small { font-size: 13.5px; color: var(--mute); line-height: 1.8; margin: 0; }
.budget { font-weight: 700; font-variant-numeric: tabular-nums; } .budget.over { color: var(--bad); }
.slider { display: grid; grid-template-columns: 118px 1fr 38px; align-items: center; gap: 10px; font-size: 14px; padding: 2px 0; }
.slider small { color: var(--mute); }
.slider input { width: 100%; accent-color: var(--green); }
.slider output { font-variant-numeric: tabular-nums; text-align: center; color: var(--green); font-weight: 700; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
#qr svg { width: 220px; height: 220px; display: block; margin: 10px auto; background: #fff; border-radius: 14px; padding: 6px; border: 1px solid var(--line); fill: initial; stroke: none; }
#qr svg path, #qr svg rect { stroke: none; }
#planText { white-space: pre-wrap; font-family: inherit; font-size: 13.5px; background: var(--card2); border: 1px solid var(--line); padding: 10px; border-radius: 12px; }
#planText:empty { display: none; }

/* about dialog */
dialog#about { width: min(620px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow-y: auto; border: 1px solid var(--line); border-radius: 28px; padding: 28px; background: var(--card); color: var(--ink); box-shadow: 0 30px 80px rgba(40, 30, 10, .3); }
dialog#about::backdrop { background: rgba(26, 46, 40, .45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
dialog#about[open] { animation: pop .22s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
#about .close { position: absolute; top: 16px; inset-inline-end: 16px; width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border-radius: 50%; background: var(--card2); color: var(--ink); border: 1px solid var(--line); }
#about .close svg { width: 18px; height: 18px; }
.about-head { display: flex; gap: 16px; align-items: flex-start; padding-inline-end: 40px; }
.about-head .logo { width: 64px; height: 64px; flex: none; color: var(--gold); background: linear-gradient(160deg, #2d6153, #1a3f35); border-radius: 20px; padding: 10px; }
.about-head h2 { margin: 0 0 6px; font-size: 26px; color: var(--green); }
.about-head p { margin: 0; font-size: 14.5px; line-height: 1.9; color: #4d4a40; }
#about h3 { margin: 24px 0 10px; font-size: 13px; color: var(--mute); letter-spacing: .04em; }
.people { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.person, .club { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 20px; background: var(--card2); border: 1px solid var(--line); color: inherit; text-decoration: none; transition: border-color .15s, transform .15s, box-shadow .15s; }
.person:hover, .club:hover { border-color: var(--green); transform: translateY(-2px); box-shadow: var(--shadow); }
.person:focus-visible, .club:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.club { margin-top: 12px; background: linear-gradient(160deg, #24574a, #1a3f35); color: #fff; border-color: transparent; }
.club small { color: #c8d6cf !important; } .club i { color: var(--gold) !important; }
.qr { width: 84px; height: 84px; flex: none; background: #fff; border-radius: 12px; padding: 5px; border: 1px solid var(--line); }
.qr svg { width: 100%; height: 100%; display: block; fill: initial; stroke: none; }
.qr svg path, .qr svg rect { stroke: none; }
.who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.who b { font-size: 17px; } .who small { font-size: 12.5px; color: var(--mute); direction: ltr; text-align: end; }
.who i { font-style: normal; font-size: 12.5px; font-weight: 700; color: #0a66c2; display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; }
.who i svg { width: 16px; height: 16px; }
.thanks { margin: 18px 0 0; font-size: 13px; color: var(--mute); line-height: 1.8; text-align: center; }

/* iPad / phones: one column, the sidebar becomes a top bar */
@media (max-width: 1100px) {
  html, body { height: auto; }
  .app { grid-template-columns: 1fr; padding: 10px; gap: 10px; height: auto; }
  .sidebar { flex-direction: row; align-items: center; padding: 8px 12px; border-radius: 18px; gap: 10px; }
  .brand { flex-direction: row; margin: 0; gap: 6px; } .brand .logo { width: 30px; height: 30px; } .brand b { font-size: 20px; } .brand span, .side-foot { display: none; }
  .people { grid-template-columns: 1fr; } dialog#about { padding: 22px; } .qr { width: 72px; height: 72px; }
  .nav { flex-direction: row; gap: 2px; overflow-x: auto; } .nav .tab { padding: 8px 10px; font-size: 13px; white-space: nowrap; } .nav .tab svg { width: 18px; height: 18px; }
  .stage { height: 52vh; flex: none; }
  .cards { gap: 8px; } .card { padding: 10px 12px; } .card b { font-size: 18px; } .card .ico { display: none; }
  .assistant { height: 70vh; }
  .legend, .overlay.caption { display: none; }
  .presets button { font-size: 12px; padding: 6px 8px; }
  .chip { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
