/* ═══════════════════════════════════════════════════════════
   FileOS Desktop — Window Manager CSS
   Draggable, resizable, stackable windows
   ═══════════════════════════════════════════════════════════ */

/* ── Window ── */
.window {
  position: absolute;
  min-width: 420px;
  min-height: 300px;
  background: var(--bg-window);
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  border: 1px solid var(--border-glass-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-window);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: windowOpen 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.window.closing {
  animation: windowClose 0.15s ease forwards;
}

.window.maximized {
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 0;
  border: none;
}

.window.focused {
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow-window), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.window:not(.focused) {
  opacity: 0.92;
}

.window.minimized {
  display: none;
}

/* ── Title Bar ── */
.window-titlebar {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 8px 0 12px;
  background: var(--bg-window-titlebar);
  border-bottom: 1px solid var(--border-glass);
  cursor: default;
  flex-shrink: 0;
  -webkit-app-region: drag;
}

.window-titlebar-icon {
  font-size: 14px;
  margin-right: 8px;
  flex-shrink: 0;
}

.window-titlebar-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  pointer-events: none;
}

.window:not(.focused) .window-titlebar-text {
  color: var(--text-secondary);
}

/* ── Window Controls ── */
.window-controls {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  height: 100%;
  margin-left: auto;
  -webkit-app-region: no-drag;
}

.window-control {
  width: 46px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 10px;
  transition: background 0.1s ease, color 0.1s ease;
}

.window-control:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.window-control.close:hover {
  background: var(--red);
  color: white;
}

.window-control svg {
  width: 10px;
  height: 10px;
  stroke: currentColor;
  stroke-width: 1.2;
  fill: none;
}

/* ── Window Body ── */
.window-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.window-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

.window-body-content {
  width: 100%;
  height: 100%;
  padding: 16px;
  overflow-y: auto;
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.6;
}

/* ── Resize Handles ── */
.window .resize-handle {
  position: absolute;
  z-index: 10;
}

.resize-handle.n  { top: -3px; left: 8px; right: 8px; height: 6px; cursor: n-resize; }
.resize-handle.s  { bottom: -3px; left: 8px; right: 8px; height: 6px; cursor: s-resize; }
.resize-handle.e  { right: -3px; top: 8px; bottom: 8px; width: 6px; cursor: e-resize; }
.resize-handle.w  { left: -3px; top: 8px; bottom: 8px; width: 6px; cursor: w-resize; }
.resize-handle.ne { top: -3px; right: -3px; width: 12px; height: 12px; cursor: ne-resize; }
.resize-handle.nw { top: -3px; left: -3px; width: 12px; height: 12px; cursor: nw-resize; }
.resize-handle.se { bottom: -3px; right: -3px; width: 12px; height: 12px; cursor: se-resize; }
.resize-handle.sw { bottom: -3px; left: -3px; width: 12px; height: 12px; cursor: sw-resize; }

/* ── Loading State ── */
.window-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
}

.window-loading .boot-spinner {
  width: 24px;
  height: 24px;
}

/* ── Snap Preview ── */
.snap-preview {
  position: fixed;
  z-index: calc(var(--z-windows) - 1);
  background: var(--accent-light);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, top 0.15s ease, left 0.15s ease, width 0.15s ease, height 0.15s ease;
}

.snap-preview.visible {
  opacity: 1;
}
