/* =====================================================================
   CloudLab Simulator - base styles (layout, windows, shared controls)
   ===================================================================== */
:root {
  --font: 'Segoe UI Variable Text', 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Segoe UI Variable Display', 'Segoe UI', system-ui, sans-serif;
  --mono: 'Cascadia Mono', Consolas, 'Courier New', monospace;
  --icons: 'Segoe Fluent Icons', 'Segoe MDL2 Assets';
  --accent: #0067c0;
  --accent-hover: #1975c5;
  --accent-press: #3183ca;
  --accent-light: #cce4f7;
  --taskbar-h: 48px;
  --hud-w: 360px;
  --win-border: rgba(0, 0, 0, 0.18);
  --text: #1a1a1a;
  --text2: #5f5f5f;
  --stroke: #e5e5e5;
  --mica: #f3f3f3;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: var(--font); font-size: 14px; color: var(--text); background: #000; }
body { display: flex; user-select: none; -webkit-user-select: none; }
input, textarea, select, button { font-family: inherit; font-size: inherit; color: inherit; }
input, textarea, [contenteditable] { user-select: text; -webkit-user-select: text; }
.ico { display: inline-flex; align-items: center; justify-content: center; flex: none; vertical-align: middle; }
.ico svg { width: 100%; height: 100%; display: block; }

/* ---------- page layout: simulated PC + HUD ---------- */
#sim-root { position: relative; flex: 1; min-width: 0; height: 100%; overflow: hidden; }
#desktop {
  position: absolute; left: 0; top: 0; right: 0; bottom: var(--taskbar-h); overflow: hidden;
}
#wallpaper {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 70% at 62% 58%, rgba(255,255,255,.55) 0%, rgba(160,205,255,.35) 18%, rgba(0,0,0,0) 45%),
    radial-gradient(ellipse 35% 55% at 70% 40%, rgba(70,150,255,.75) 0%, rgba(0,0,0,0) 70%),
    radial-gradient(ellipse 40% 45% at 52% 70%, rgba(40,110,235,.85) 0%, rgba(0,0,0,0) 70%),
    radial-gradient(ellipse 30% 40% at 78% 70%, rgba(110,170,255,.7) 0%, rgba(0,0,0,0) 70%),
    linear-gradient(160deg, #cfe0f5 0%, #9fc3ee 35%, #5d93e0 70%, #2f62c4 100%);
}
#wallpaper::after {
  content: ''; position: absolute; left: 38%; top: 22%; width: 46%; height: 70%;
  background:
    conic-gradient(from 200deg at 50% 60%, rgba(255,255,255,0) 0deg, rgba(255,255,255,.35) 40deg, rgba(0,60,190,.35) 90deg, rgba(255,255,255,0) 140deg, rgba(120,190,255,.4) 220deg, rgba(255,255,255,0) 300deg);
  border-radius: 48% 52% 40% 60% / 55% 45% 55% 45%;
  filter: blur(18px); opacity: .9;
}
#screen-overlay { position: absolute; inset: 0; z-index: 100000; display: none; }
#screen-overlay.show { display: block; }

/* ---------- windows ---------- */
.win {
  position: absolute; display: flex; flex-direction: column; background: #fff;
  border: 1px solid var(--win-border); border-radius: 8px; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.12), 0 16px 40px rgba(0,0,0,.18);
}
.win.active { box-shadow: 0 4px 12px rgba(0,0,0,.18), 0 32px 64px rgba(0,0,0,.30); border-color: rgba(0,0,0,.28); }
.win.maximized { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; border-radius: 0; border: none; }
.win.minimized { display: none !important; }
.win.flash { animation: winflash .5s 2; }
@keyframes winflash { 50% { box-shadow: 0 0 0 2px var(--accent), 0 32px 64px rgba(0,0,0,.30); } }
.win-titlebar {
  height: 32px; flex: none; display: flex; align-items: stretch; background: var(--mica);
  color: #1a1a1a; font-size: 12px; position: relative; z-index: 2;
}
.win:not(.active) .win-titlebar { color: #8a8a8a; }
.win:not(.active) .win-titlebar .win-icon { opacity: .6; }
.win-title-slot { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding-left: 12px; overflow: hidden; }
.win-icon { display: inline-flex; width: 16px; height: 16px; flex: none; }
.win-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-controls { display: flex; flex: none; }
.cap-btn { width: 46px; border: none; background: transparent; color: inherit; display: flex; align-items: center; justify-content: center; cursor: default; padding: 0; }
.cap-btn:hover { background: rgba(0,0,0,.06); }
.cap-btn:active { background: rgba(0,0,0,.1); }
.cap-btn.cap-close:hover { background: #c42b1c; color: #fff; }
.cap-btn.cap-close:active { background: #c84031; color: #fff; }
.win-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; overflow: hidden; }
.win.win-blocked .win-body::after { content: ''; position: absolute; inset: 0; z-index: 50; }
.rz { position: absolute; z-index: 5; }
.rz-n { top: -3px; left: 6px; right: 6px; height: 6px; cursor: n-resize; }
.rz-s { bottom: -3px; left: 6px; right: 6px; height: 6px; cursor: s-resize; }
.rz-e { right: -3px; top: 6px; bottom: 6px; width: 6px; cursor: e-resize; }
.rz-w { left: -3px; top: 6px; bottom: 6px; width: 6px; cursor: w-resize; }
.rz-ne { right: -3px; top: -3px; width: 10px; height: 10px; cursor: ne-resize; }
.rz-nw { left: -3px; top: -3px; width: 10px; height: 10px; cursor: nw-resize; }
.rz-se { right: -3px; bottom: -3px; width: 10px; height: 10px; cursor: se-resize; }
.rz-sw { left: -3px; bottom: -3px; width: 10px; height: 10px; cursor: sw-resize; }
.win.maximized .rz { display: none; }

/* classic (Win32 dialog) window: white titlebar */
.win.classic .win-titlebar { background: #fff; }
.win.dialog .win-body { background: #f0f0f0; }

/* ---------- message box ---------- */
.win.msgbox .win-titlebar { background: #fff; }
.msgbox-content { display: flex; gap: 14px; padding: 22px 22px 26px; background: #fff; align-items: flex-start; font-size: 12px; line-height: 1.5; }
.msgbox-icon { flex: none; }
.msgbox-text { padding-top: 6px; white-space: normal; user-select: text; }
.msgbox-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 11px 12px; background: #f0f0f0; border-top: 1px solid #dfdfdf; }

/* ---------- Win32 classic controls (Windows 11 common controls look) ---------- */
.w32 { font-family: 'Segoe UI', var(--font); font-size: 12px; }
.w32-btn {
  min-width: 75px; height: 24px; padding: 0 12px; font-size: 12px; background: #fdfdfd;
  border: 1px solid #d0d0d0; border-bottom-color: #b8b8b8; border-radius: 4px; color: #1a1a1a; cursor: default;
}
.w32-btn:hover:not(:disabled) { background: #f5f5f5; border-color: #c4c4c4; }
.w32-btn:active:not(:disabled) { background: #eaeaea; color: #555; }
.w32-btn.default { border: 1px solid var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.w32-btn.primary { background: var(--accent); color: #fff; border-color: #0a5aa8; }
.w32-btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.w32-btn:disabled { color: #a0a0a0; background: #f5f5f5; border-color: #e0e0e0; }
.w32-btn:focus-visible { outline: 2px solid #000; outline-offset: 1px; }
.w32-input, .w32-select {
  height: 23px; font-size: 12px; padding: 0 6px; border: 1px solid #c8c8c8; border-bottom: 1px solid #8a8a8a; border-radius: 3px; background: #fff; outline: none;
}
.w32-input:focus, .w32-select:focus { border-bottom: 2px solid var(--accent); }
.w32-input:disabled, .w32-select:disabled { background: #f6f6f6; color: #999; border-color: #e3e3e3; }
textarea.w32-input { height: auto; padding: 4px 6px; resize: none; }
.w32-check, .w32-radio { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; cursor: default; }
.w32-check input, .w32-radio input { margin: 0; accent-color: var(--accent); width: 13px; height: 13px; }
.w32-group { border: 1px solid #dcdcdc; border-radius: 4px; padding: 10px 12px 12px; margin: 0; }
.w32-group > legend { padding: 0 4px; font-size: 12px; color: #1a1a1a; }
.w32-link { color: #0066cc; cursor: pointer; text-decoration: none; }
.w32-link:hover { text-decoration: underline; }
.w32-menubar { display: flex; height: 22px; align-items: stretch; background: #fff; font-size: 12px; flex: none; padding-left: 2px; }
.w32-menubar .menubar-item { padding: 0 8px; display: flex; align-items: center; border-radius: 3px; margin: 1px 0; cursor: default; }
.w32-menubar .menubar-item:hover, .w32-menubar .menubar-item.open { background: #e5f1fb; }
.w32-toolbar { display: flex; align-items: center; gap: 2px; padding: 2px 4px; background: #fff; border-bottom: 1px solid #e5e5e5; flex: none; min-height: 28px; }
.w32-toolbar .tb-btn { height: 24px; min-width: 24px; display: inline-flex; align-items: center; gap: 4px; padding: 0 4px; border: 1px solid transparent; border-radius: 3px; background: none; font-size: 12px; cursor: default; }
.w32-toolbar .tb-btn:hover:not(:disabled) { background: #e5f1fb; border-color: #cce4f7; }
.w32-toolbar .tb-btn:disabled { opacity: .4; }
.w32-toolbar .tb-sep { width: 1px; height: 18px; background: #ddd; margin: 0 3px; }
.w32-tabs { display: flex; gap: 0; border-bottom: 1px solid #d9d9d9; padding: 0 6px; flex: none; }
.w32-tabs .tab { padding: 4px 12px; font-size: 12px; border: 1px solid transparent; border-bottom: none; margin-bottom: -1px; cursor: default; border-radius: 3px 3px 0 0; }
.w32-tabs .tab:hover { background: #e8f2fc; }
.w32-tabs .tab.sel { background: #fff; border-color: #d9d9d9; }
.w32-tree { font-size: 12px; overflow: auto; background: #fff; }
.w32-tree .node { display: flex; align-items: center; gap: 4px; height: 20px; padding-right: 8px; white-space: nowrap; cursor: default; }
.w32-tree .node:hover { background: #e5f3ff; }
.w32-tree .node.sel { background: #cce8ff; }
.w32-tree .twisty { width: 14px; display: inline-flex; justify-content: center; color: #555; font-size: 9px; }
.w32-list { width: 100%; border-collapse: collapse; font-size: 12px; background: #fff; }
.w32-list th { text-align: left; font-weight: 400; color: #4c607a; padding: 3px 6px; border-right: 1px solid #e5e5e5; border-bottom: 1px solid #e5e5e5; background: #fff; position: sticky; top: 0; white-space: nowrap; }
.w32-list td { padding: 2px 6px; white-space: nowrap; height: 20px; }
.w32-list tbody tr:hover td { background: #e5f3ff; }
.w32-list tbody tr.sel td { background: #cce8ff; }
.w32-list tbody tr.sel:not(:focus-within) td { background: #cce8ff; }
.w32-status { height: 22px; border-top: 1px solid #e5e5e5; background: #f0f0f0; display: flex; align-items: center; padding: 0 8px; font-size: 12px; color: #333; flex: none; }
.w32-progress { height: 15px; border: 1px solid #bcbcbc; background: #e6e6e6; border-radius: 2px; overflow: hidden; }
.w32-progress > div { height: 100%; background: #06b025; width: 0; transition: width .25s; }
.w32-progress.indeterminate > div { width: 30%; animation: indet 1.4s linear infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(350%); } }
.w32-spin { display: inline-flex; align-items: stretch; }
.w32-spin input { width: 70px; }

/* ---------- Windows 11 (Fluent / WinUI) controls ---------- */
.fl-btn {
  height: 32px; padding: 0 14px; border-radius: 4px; border: 1px solid rgba(0,0,0,.073); border-bottom-color: rgba(0,0,0,.16);
  background: #fbfbfb; font-size: 14px; color: #1a1a1a; cursor: default; display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.fl-btn:hover:not(:disabled) { background: #f6f6f6; }
.fl-btn:active:not(:disabled) { background: #f5f5f5; color: #5d5d5d; }
.fl-btn.accent { background: var(--accent); color: #fff; border-color: rgba(255,255,255,.08); border-bottom-color: rgba(0,0,0,.4); }
.fl-btn.accent:hover:not(:disabled) { background: var(--accent-hover); }
.fl-btn.accent:active:not(:disabled) { background: var(--accent-press); color: rgba(255,255,255,.8); }
.fl-btn:disabled { color: rgba(0,0,0,.36); background: #f5f5f5; }
.fl-btn.accent:disabled { background: rgba(0,0,0,.22); color: #fff; }
.fl-input { height: 32px; padding: 0 10px; border-radius: 4px; border: 1px solid rgba(0,0,0,.06); border-bottom: 1px solid rgba(0,0,0,.45); background: #fff; outline: none; font-size: 14px; }
.fl-input:focus { border-bottom: 2px solid var(--accent); }
.fl-toggle { position: relative; width: 40px; height: 20px; border-radius: 10px; border: 1px solid #8a8a8a; background: #f6f6f6; cursor: default; flex: none; display: inline-block; }
.fl-toggle::after { content: ''; position: absolute; left: 4px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: #5d5d5d; transition: left .15s; }
.fl-toggle.on { background: var(--accent); border-color: var(--accent); }
.fl-toggle.on::after { left: 23px; background: #fff; }

/* ---------- context / dropdown menus ---------- */
.ctx-menu {
  position: fixed; z-index: 200000; min-width: 180px; background: #f9f9f9; border: 1px solid rgba(0,0,0,.12);
  border-radius: 8px; padding: 4px; box-shadow: 0 8px 16px rgba(0,0,0,.14); font-size: 14px; color: #1a1a1a;
  animation: menuin .12s ease-out;
}
.ctx-menu.from-menubar, .ctx-menu.small { font-size: 12px; min-width: 200px; }
@keyframes menuin { from { opacity: 0; transform: translateY(-4px); } }
.ctx-item { display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 10px; border-radius: 4px; cursor: default; white-space: nowrap; }
.from-menubar .ctx-item, .small .ctx-item { height: 26px; }
.ctx-item:hover:not(.disabled) { background: rgba(0,0,0,.055); }
.ctx-item.disabled { color: #a0a0a0; }
.ctx-item.bold .ctx-label { font-weight: 600; }
.ctx-icon { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ctx-label { flex: 1; }
.ctx-shortcut { color: #6b6b6b; margin-left: 24px; font-size: 12px; }
.ctx-arrow { display: inline-flex; color: #555; }
.ctx-sep { height: 1px; background: rgba(0,0,0,.09); margin: 4px -4px; }

/* ---------- toasts ---------- */
#toast-host { position: absolute; right: 12px; bottom: calc(var(--taskbar-h) + 12px); display: flex; flex-direction: column; gap: 8px; z-index: 150000; pointer-events: none; }
.toast {
  width: 364px; background: rgba(243,243,243,.97); border: 1px solid rgba(0,0,0,.1); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2);
  padding: 12px 14px 14px; transform: translateX(400px); transition: transform .3s cubic-bezier(.1,.9,.2,1); pointer-events: auto; cursor: default;
}
.toast.show { transform: none; }
.toast-app { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #444; margin-bottom: 8px; }
.toast-app .toast-x { margin-left: auto; border: none; background: none; width: 24px; height: 24px; border-radius: 4px; display: flex; align-items: center; justify-content: center; }
.toast-app .toast-x:hover { background: rgba(0,0,0,.06); }
.toast-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.toast-text { font-size: 13px; color: #333; line-height: 1.4; }

/* ---------- common file dialog ---------- */
.filedlg .win-body { background: #fff; font-size: 12px; }
.fd-top { display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: #f9f9f9; border-bottom: 1px solid #e5e5e5; }
.fd-nav { width: 30px; height: 30px; border: none; border-radius: 4px; background: none; display: flex; align-items: center; justify-content: center; color: #444; }
.fd-nav:hover { background: rgba(0,0,0,.05); }
.fd-addr { flex: 1; height: 30px; border: 1px solid #e0e0e0; border-radius: 4px; background: #fff; display: flex; align-items: center; padding: 0 8px; gap: 2px; overflow: hidden; white-space: nowrap; }
.fd-crumb { padding: 2px 4px; border-radius: 3px; cursor: default; }
.fd-crumb:hover { background: rgba(0,0,0,.05); }
.fd-chev { color: #888; padding: 0 2px; }
.fd-search { width: 200px; height: 30px; border: 1px solid #e0e0e0; border-radius: 4px; padding: 0 8px; outline: none; font-size: 12px; }
.fd-mid { flex: 1; display: flex; min-height: 0; }
.fd-navpane { width: 190px; border-right: 1px solid #eee; overflow: auto; padding: 6px 4px; flex: none; }
.fd-navitem { display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 10px; border-radius: 4px; cursor: default; }
.fd-navitem:hover { background: rgba(0,0,0,.04); }
.fd-navitem.sel { background: rgba(0,0,0,.07); }
.fd-navsep { height: 1px; background: #eee; margin: 6px 6px; }
.fd-list { flex: 1; overflow: auto; padding: 0 4px; }
.fd-head, .fd-item { display: grid; grid-template-columns: minmax(220px, 2.4fr) 1.3fr 1.2fr .8fr; align-items: center; gap: 8px; padding: 0 8px; }
.fd-head { height: 30px; color: #555; border-bottom: 1px solid #eee; position: sticky; top: 0; background: #fff; }
.fd-item { height: 28px; border-radius: 4px; cursor: default; }
.fd-item:hover { background: #f0f6fd; }
.fd-item.sel { background: #cce8ff; }
.fd-n { display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fd-sz { text-align: right; }
.fd-empty { color: #777; padding: 20px; text-align: center; }
.fd-bottom { border-top: 1px solid #e5e5e5; background: #f3f3f3; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.fd-row { display: flex; align-items: center; gap: 8px; }
.fd-row label { width: 70px; text-align: right; }
.fd-row .fd-name { flex: 1; }
.fd-row .fd-filter { width: 230px; }
.fd-btns { justify-content: flex-end; }
.fd-btns .w32-btn { min-width: 90px; height: 28px; }

/* ---------- scrollbars (Win11 thin) ---------- */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.28); border-radius: 6px; border: 4px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.45); border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- misc ---------- */
.spinner-dots { position: relative; width: 48px; height: 48px; }
.spinner-dots i { position: absolute; left: 50%; top: 0; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: #fff; transform-origin: 3px 24px; animation: winspin 2.6s infinite cubic-bezier(.5,.1,.5,.9); opacity: 0; }
.spinner-dots i:nth-child(2) { animation-delay: .12s; } .spinner-dots i:nth-child(3) { animation-delay: .24s; }
.spinner-dots i:nth-child(4) { animation-delay: .36s; } .spinner-dots i:nth-child(5) { animation-delay: .48s; }
@keyframes winspin { 0% { transform: rotate(0); opacity: 1; } 60% { transform: rotate(560deg); opacity: 1; } 75% { transform: rotate(720deg); opacity: 0; } 100% { transform: rotate(720deg); opacity: 0; } }
.fl-ring { width: 32px; height: 32px; border: 3px solid rgba(0,103,192,.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
