/* ============ Shell Portal — design system (ui-ux-pro-max: glassmorphism, dark slate, accent green) ============ */
:root {
  --bg: #0B1120;
  --bg-2: #0F172A;
  --card: #121A2E;
  --glass: rgba(255, 255, 255, 0.045);
  --glass-hi: rgba(255, 255, 255, 0.09);
  --border: rgba(148, 163, 184, 0.16);
  --text: #F1F5F9;
  --muted: #94A3B8;
  --muted-2: #64748B;
  --accent: #22C55E;
  --accent-2: #14B8A6;
  --info: #38BDF8;
  --danger: #EF4444;
  --warn: #FACC15;
  --t-bg: #0A0F1E;
  --radius: 16px;
  --mono: "Fira Code", "JetBrains Mono", "DejaVu Sans Mono", "Liberation Mono", ui-monospace, monospace;
  --sans: "Vazirmatn", "Segoe UI", Tahoma, system-ui, sans-serif;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/Vazirmatn-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/Vazirmatn-arabic-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/Vazirmatn-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/Vazirmatn-arabic-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; border-radius: 6px; }

/* ---- background scene ---- */
.scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.scene .grid-fade {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(148,163,184,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, #000 30%, transparent 75%);
}
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; }
.orb-a { width: 520px; height: 520px; top: -180px; left: -120px; background: radial-gradient(circle, rgba(34,197,94,.32), transparent 65%); animation: drift 22s ease-in-out infinite alternate; }
.orb-b { width: 460px; height: 460px; bottom: -160px; right: -120px; background: radial-gradient(circle, rgba(56,189,248,.26), transparent 65%); animation: drift 26s ease-in-out infinite alternate-reverse; }
.orb-c { width: 300px; height: 300px; top: 40%; left: 55%; background: radial-gradient(circle, rgba(20,184,166,.18), transparent 65%); animation: drift 30s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(40px, 30px) scale(1.08); } }

/* ---- glass card ---- */
.glass {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(2, 6, 23, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.card { border-radius: var(--radius); }

/* ---- views ---- */
.view { position: relative; z-index: 1; min-height: 100dvh; display: flex; flex-direction: column; }
.hidden { display: none !important; }
/* terminal view: the PAGE must never scroll (scroll lives inside xterm only) */
body.term-active { overflow: hidden; height: 100%; }
html:has(body.term-active) { overflow: hidden; height: 100%; }

/* ---- login ---- */
#loginView { align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 390px; padding: 40px 32px 28px; animation: rise .5s cubic-bezier(.22,1,.36,1) both; }
.logo-wrap { display: flex; justify-content: center; margin-bottom: 18px; }
.logo-glow { filter: drop-shadow(0 0 22px rgba(34,197,94,.35)); animation: breathe 4.5s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.045); } }
.login-title { text-align: center; font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 8px 0 26px; }
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 7px; font-weight: 500; }
.field input {
  width: 100%; padding: 12px 14px; border-radius: 11px;
  background: rgba(2, 6, 23, .5); border: 1px solid var(--border);
  color: var(--text); transition: border-color .18s, box-shadow .18s;
}
.field input::placeholder { color: var(--muted-2); }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,197,94,.15); }
.alert { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.35); color: #FCA5A5; border-radius: 10px; padding: 10px 13px; font-size: 13px; margin-bottom: 14px; }
.login-foot { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted-2); font-size: 11.5px; margin-top: 22px; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 11px;
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  transition: transform .15s cubic-bezier(.22,1,.36,1), box-shadow .2s, background .2s, border-color .2s;
  user-select: none; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-block { width: 100%; padding: 13px; font-size: 15px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #062822; box-shadow: 0 10px 26px rgba(34,197,94,.28);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 32px rgba(34,197,94,.38); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); font-weight: 500; }
.btn-ghost:hover { background: var(--glass-hi); color: var(--text); border-color: rgba(148,163,184,.3); }
.btn-icon { padding: 9px; border-radius: 10px; }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(6,40,34,.3); border-top-color: #062822;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- hub ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-radius: 0; border-left: none; border-right: none; border-top: none;
  background: rgba(11, 17, 32, .72);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 9px; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -.3px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.pill { font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.pill.online { color: var(--accent); border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.08); }
.hub-body { flex: 1; width: 100%; max-width: 1060px; margin: 0 auto; padding: 46px 24px 60px; }
.hero { margin-bottom: 34px; animation: rise .55s cubic-bezier(.22,1,.36,1) both; }
.hero-title { font-size: clamp(26px, 4.2vw, 38px); font-weight: 700; letter-spacing: -.8px; line-height: 1.25; }
.grad-text {
  background: linear-gradient(120deg, var(--accent), var(--info));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { color: var(--muted); margin-top: 10px; font-size: 15px; line-height: 1.8; max-width: 560px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 16px; }
.server-card {
  --card-accent: #38BDF8;
  position: relative; text-align: right; width: 100%;
  background: linear-gradient(180deg, var(--glass), rgba(255,255,255,.02));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; overflow: hidden;
  transition: transform .22s cubic-bezier(.22,1,.36,1), border-color .22s, box-shadow .25s;
  animation: rise .5s cubic-bezier(.22,1,.36,1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.server-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--card-accent), transparent 70%);
  opacity: .85;
}
.server-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--card-accent) 55%, transparent);
  box-shadow: 0 18px 44px rgba(2, 6, 23, .6), 0 0 0 1px color-mix(in srgb, var(--card-accent) 30%, transparent);
}
.server-card:disabled { pointer-events: none; }
.card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-name { font-size: 16px; font-weight: 700; }
.card-desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot-online { background: var(--accent); box-shadow: 0 0 10px rgba(34,197,94,.8); }
.dot-offline { background: var(--danger); }
.dot-busy { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.dot-idle { background: var(--muted-2); }
@keyframes pulse { 50% { opacity: .35; } }
.card-meta {
  display: flex; align-items: center; gap: 8px; margin: 14px 0 16px;
  font-family: var(--mono); font-size: 12px; color: var(--muted-2);
  background: rgba(2, 6, 23, .45); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 11px; direction: ltr; text-align: left;
}
.card-meta svg { flex: none; color: var(--card-accent); }
.card-cta {
  width: 100%; padding: 10px;
  background: color-mix(in srgb, var(--card-accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--card-accent) 35%, transparent);
  color: var(--card-accent); font-weight: 600; font-size: 13.5px;
  border-radius: 10px; transition: background .18s, transform .15s;
}
.card-cta:hover { background: color-mix(in srgb, var(--card-accent) 22%, transparent); }
.card-cta:active { transform: scale(.98); }
.card-cta:disabled { opacity: .5; cursor: not-allowed; }

@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---- terminal ---- */
#termView { height: 100dvh; overflow: hidden; }
.term-bar { padding: 10px 14px; }
.term-title { font-weight: 600; font-size: 14.5px; }
.term-wrap {
  flex: 1 1 auto; min-height: 0; position: relative; margin: 14px; border-radius: 14px; overflow: hidden;
  background: var(--t-bg); border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(2, 6, 23, .6), inset 0 1px 0 rgba(255,255,255,.04);
}
#term { position: absolute; inset: 0; padding: 12px 4px 10px 12px; direction: ltr; }
#term .xterm { height: 100%; }
.term-offline {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: rgba(10, 15, 30, .88); backdrop-filter: blur(6px);
  color: var(--muted); font-size: 15px;
}

/* ---- terminal context menu ---- */
.ctx-menu {
  position: absolute; z-index: 40; min-width: 185px; padding: 5px;
  background: rgba(13, 20, 36, .94); backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 18px 44px rgba(2, 6, 23, .65), inset 0 1px 0 rgba(255,255,255,.06);
  animation: rise .16s cubic-bezier(.22,1,.36,1) both;
}
.ctx-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; background: transparent; border: 0; border-radius: 8px;
  color: var(--text); font-size: 13px; font-weight: 500; text-align: right;
  transition: background .13s, color .13s;
}
.ctx-item svg { color: var(--muted); transition: color .13s; flex: none; }
.ctx-item:hover, .ctx-item:focus-visible { background: rgba(34,197,94,.14); color: #fff; }
.ctx-item:hover svg { color: var(--accent); }
.ctx-item:disabled { opacity: .45; cursor: not-allowed; }
.ctx-item:disabled:hover { background: transparent; }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 60; padding: 11px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 500;
  background: var(--glass-hi); border: 1px solid var(--border); backdrop-filter: blur(14px);
  color: var(--text); box-shadow: 0 14px 40px rgba(2,6,23,.6);
  animation: rise .3s cubic-bezier(.22,1,.36,1) both;
}

/* ---- responsive ---- */
@media (max-width: 640px) {
  .hub-body { padding: 28px 16px 44px; }
  .topbar { padding: 10px 12px; }
  .term-wrap { margin: 8px; }
  .login-card { padding: 30px 22px 22px; }
  .topbar-actions .btn-ghost { padding: 9px 12px; font-size: 13px; }
}

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