/* ============================================================================
   VelvetOS — windows
   ========================================================================== */

.win {
  position: absolute;
  display: flex; flex-direction: column;
  min-width: 320px; min-height: 200px;
  background: var(--window-bg);
  border-radius: var(--window-radius);
  box-shadow: var(--elevation-3);
  overflow: hidden;
  outline: 1px solid transparent;
  transition: box-shadow var(--dur-m) var(--ease-standard), border-radius var(--dur-m) var(--ease-standard);
  contain: layout paint;
}
.win.inactive { box-shadow: var(--elevation-2); outline-color: var(--window-border); }
.win.focused { box-shadow: var(--elevation-4); }
.win.minimized { display: none; }
.win.opening { animation: win-open var(--dur-m) var(--ease-decelerate); }
@keyframes win-open { from { opacity: 0; transform: scale(.94); } }
.win.closing { animation: win-close var(--dur-s) var(--ease-accelerate) forwards; }
@keyframes win-close { to { opacity: 0; transform: scale(.95); } }
.win.maximized, .win.snapped { border-radius: 0; }
.win.fullscreen { border-radius: 0; z-index: 9999 !important; }
.win.animating { transition: left var(--dur-l) var(--ease-decelerate), top var(--dur-l) var(--ease-decelerate),
                 width var(--dur-l) var(--ease-decelerate), height var(--dur-l) var(--ease-decelerate),
                 border-radius var(--dur-m); }
.win.resizing, .win.dragging { transition: none; }
.win.dragging { box-shadow: var(--elevation-5); }

/* ---------- header ---------- */
.win-header {
  display: flex; align-items: center; gap: var(--sp-2);
  height: var(--window-header-h); flex: none;
  padding: 0 6px 0 10px;
  background: var(--window-header);
  border-bottom: 1px solid transparent;
  cursor: default;
}
.win.focused .win-header { background: var(--window-header-active); }
.win-header.scrolled { border-bottom-color: var(--divider); }

/* ---------- tabs merged into the title bar (browser-like apps) ---------- */
.win-header.has-tabs { background: var(--window-header); cursor: default; }
.win.focused .win-header.has-tabs { background: var(--window-header-active); }
.win-title.header-hidden { display: none; }
.win-title {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-label); font-weight: var(--fw-medium);
  color: var(--on-surface-2);
}
.win.focused .win-title { color: var(--on-surface); }
.win-title .icon { width: 14px; height: 14px; flex: none; }
.win-title .wt-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-controls { display: flex; align-items: center; gap: 0; flex: none; }
.win-controls .icon-btn { width: 30px; height: 30px; border-radius: var(--r-s); color: var(--on-surface-2); }
.win-controls .icon-btn .icon { width: 16px; height: 16px; }
.win-controls .wc-close:hover { background: var(--error); color: #fff; }
.win.inactive .win-controls .icon-btn { color: var(--on-surface-4); }
.win .icon-btn { opacity: .92; }
.win.inactive .win-controls { opacity: .55; }

/* tab strip support (browser-like apps) */
.win-tabs {
  display: flex; align-items: flex-end; gap: 2px; flex: 1 1 auto;
  min-width: 0; height: 100%; padding-top: 6px; overflow: hidden;
}
.win-tab {
  display: flex; align-items: center; gap: 6px;
  min-width: 60px; max-width: 200px; height: 28px; padding: 0 8px 0 10px;
  border-radius: 8px 8px 0 0; background: transparent;
  font-size: var(--fs-caption); color: var(--on-surface-3);
  cursor: default; flex: 1 1 auto;
}
.win-tab.active { background: var(--window-bg); color: var(--on-surface); }
.win-tab .wt-text { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-tab .wt-close { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.win-tab .wt-close:hover { background: var(--shelf-icon-hover); }
.win-tab .wt-close .icon { width: 12px; height: 12px; }

/* ---------- body ---------- */
.win-body {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--window-bg);
  overflow: hidden;
}
.win-body > .app { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* ---------- resize handles ---------- */
.rs { position: absolute; z-index: 5; }
.rs-n { top: -3px; left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.rs-s { bottom: -3px; left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.rs-e { right: -3px; top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.rs-w { left: -3px; top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.rs-ne { top: -3px; right: -3px; width: 14px; height: 14px; cursor: nesw-resize; }
.rs-nw { top: -3px; left: -3px; width: 14px; height: 14px; cursor: nwse-resize; }
.rs-se { bottom: -3px; right: -3px; width: 14px; height: 14px; cursor: nwse-resize; }
.rs-sw { bottom: -3px; left: -3px; width: 14px; height: 14px; cursor: nesw-resize; }
.win.maximized .rs, .win.fullscreen .rs { display: none; }

/* ---------- window "ghost" during snap drag ---------- */
.snap-ghost {
  position: absolute; z-index: calc(var(--z-windows) + 30);
  border-radius: var(--r-m); background: color-mix(in srgb, var(--on-surface) 8%, transparent);
  border: 1px dashed color-mix(in srgb, var(--on-surface) 30%, transparent);
  pointer-events: none; transition: all var(--dur-s) var(--ease-standard);
}

/* ---------- window menus / bubbles ---------- */
.win-app-menu-bubble {
  min-width: 240px; padding: 6px !important; border-radius: var(--r-m) !important;
}
.win-app-menu-bubble .menu-item { border-radius: var(--r-s); }
.win-app-menu-hint {
  padding: 10px 14px; font-size: var(--fs-caption); color: var(--on-surface-3);
  border-top: 1px solid var(--divider); margin-top: 6px;
}

/* ---------- notice bars inside windows (e.g. "no internet") ---------- */
.win-notice {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; font-size: var(--fs-label);
  background: var(--warning-container); color: var(--on-surface);
  border-bottom: 1px solid var(--divider); flex: none;
}
.win-notice .icon { width: 16px; height: 16px; color: var(--warning); }
.win-notice.error { background: var(--error-container); color: var(--on-error-container); }
.win-notice.error .icon { color: var(--error); }

/* ---------- window animations for desk switching ---------- */
.win.desk-enter { animation: desk-in var(--dur-l) var(--ease-decelerate); }
@keyframes desk-in { from { opacity: 0; } }
.win.desk-leave { animation: desk-out var(--dur-m) var(--ease-accelerate) forwards; }
@keyframes desk-out { to { opacity: 0; } }

/* ---------- stacked "always on top" indicator ---------- */
.win.ontop .win-header::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 0; height: 0; border-left: 5px solid var(--primary);
  border-bottom: 5px solid transparent;
}

/* ---------- chromeOS style rounded window when not maximized ---------- */
.win.has-shadow { box-shadow: 0 6px 20px rgba(0,0,0,.24), 0 2px 6px rgba(0,0,0,.18); }
