/* ============================================================
   Materia OS — Fenêtres
   ============================================================ */

.win {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 320px;
  min-height: 220px;
  border-radius: var(--r-l);
  background: var(--surface-container-low);
  box-shadow: var(--shadow-2);
  border: 1px solid var(--outline-variant);
  overflow: hidden;
  animation: win-open var(--dur-m) var(--ease-out);
  transition: box-shadow var(--dur-s) var(--ease), opacity var(--dur-m) var(--ease);
}
.win.focused { box-shadow: var(--shadow-4); }
.win.maxed { border-radius: var(--r-m); }
.win.dragging, .win.resizing { transition: none; }
.win.dragging { opacity: .92; }

@keyframes win-open {
  from { opacity: 0; transform: scale(.9) translateY(24px); }
}
.win.closing {
  opacity: 0;
  transform: scale(.9) translateY(16px);
  transition: opacity var(--dur-s) var(--ease), transform var(--dur-s) var(--ease);
  pointer-events: none;
}
.win.minimized {
  opacity: 0;
  transform: translateY(48vh) scale(.4);
  transition: opacity var(--dur-m) var(--ease), transform var(--dur-m) var(--ease);
  pointer-events: none;
}
.win.snap-anim { transition: left var(--dur-m) var(--ease), top var(--dur-m) var(--ease),
                             width var(--dur-m) var(--ease), height var(--dur-m) var(--ease); }

/* --- Barre de titre --- */
.win-tb {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 8px 0 14px;
  background: var(--surface-container-low);
  flex: none;
  cursor: default;
  touch-action: none;
}
.win.focused .win-tb { background: var(--surface-container); }
.win-tb-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--r-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg, var(--primary-container));
  color: var(--fg, var(--on-primary-container));
  flex: none;
}
.win-tb-icon .material-symbols-rounded { font-size: 16px; }
.win-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface-variant);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.win.focused .win-title { color: var(--on-surface); }

.win-ctl { display: flex; gap: 2px; }
.wc {
  width: 34px;
  height: 34px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-surface-variant);
  transition: background var(--dur-s) var(--ease), color var(--dur-s) var(--ease);
}
.wc .material-symbols-rounded { font-size: 18px; }
.wc:hover { background: color-mix(in srgb, var(--on-surface) 10%, transparent); }
.wc.close:hover { background: var(--error); color: var(--on-error); }

/* --- Corps --- */
.win-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-container-lowest);
  overflow: hidden;
}
:root[data-mode="dark"] .win-body { background: var(--surface-container-low); }

/* --- Poignées de redimensionnement --- */
.rz { position: absolute; z-index: 10; }
.rz-n  { top: -4px; left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.rz-s  { bottom: -4px; left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.rz-e  { right: -4px; top: 12px; bottom: 12px; width: 8px; cursor: ew-resize; }
.rz-w  { left: -4px; top: 12px; bottom: 12px; width: 8px; cursor: ew-resize; }
.rz-ne { top: -5px; right: -5px; width: 14px; height: 14px; cursor: nesw-resize; }
.rz-nw { top: -5px; left: -5px; width: 14px; height: 14px; cursor: nwse-resize; }
.rz-se { bottom: -5px; right: -5px; width: 14px; height: 14px; cursor: nwse-resize; }
.rz-sw { bottom: -5px; left: -5px; width: 14px; height: 14px; cursor: nesw-resize; }

/* --- Barre d'outils générique d'app --- */
.app-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--outline-variant);
  flex: none;
  flex-wrap: wrap;
}
.app-content { flex: 1; min-height: 0; overflow: auto; }
.app-statusbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--on-surface-variant);
  border-top: 1px solid var(--outline-variant);
  flex: none;
}
