/* Universal Window Resize CSS Framework */

/* Base window resize styles */
.win98-window {
  position: absolute;
  background-color: var(--win98-window-bg);
  border: 2px solid;
  border-color: var(--win98-button-highlight) var(--win98-button-shadow) var(--win98-button-shadow) var(--win98-button-highlight);
  box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  font-family: 'MS Sans Serif', sans-serif;
  font-size: 11px;
  min-width: 200px;
  min-height: 150px;
  transition: none;
}

.win98-window.active {
  z-index: 1000;
}

.win98-window.maximized {
  left: 0 !important;
  top: 0 !important;
  width: 100vw !important;
  height: calc(100vh - 40px) !important; /* Account for taskbar */
  border: none;
  box-shadow: none;
}

.win98-window.resizing {
  transition: none;
  user-select: none;
}

.win98-window.dragging {
  transition: none;
  user-select: none;
  opacity: 0.9;
}

/* Window header */
.win98-window-header {
  background: linear-gradient(90deg, var(--win98-title-active) 0%, #1084d0 100%);
  color: var(--win98-title-text-active);
  padding: 2px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
  user-select: none;
  height: 18px;
}

.win98-window:not(.active) .win98-window-header {
  background: linear-gradient(90deg, var(--win98-title-inactive) 0%, #c0c0c0 100%);
  color: var(--win98-title-text-inactive);
}

.win98-window-title-content {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  overflow: hidden;
}

.win98-window-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.win98-window-title {
  font-weight: bold;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.win98-window-controls {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.win98-window-button {
  width: 16px;
  height: 14px;
  background-color: var(--win98-button-face);
  border: 1px solid;
  border-color: var(--win98-button-highlight) var(--win98-button-shadow) var(--win98-button-shadow) var(--win98-button-highlight);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: bold;
  color: var(--win98-text);
  padding: 0;
  line-height: 1;
}

.win98-window-button:hover {
  background-color: var(--win98-button-highlight);
}

.win98-window-button:active {
  border-color: var(--win98-button-shadow) var(--win98-button-highlight) var(--win98-button-highlight) var(--win98-button-shadow);
  background-color: var(--win98-button-shadow);
}

.button-icon {
  display: block;
  line-height: 1;
}

/* Window content */
.win98-window-content {
  padding: 4px;
  height: calc(100% - 26px); /* Account for header */
  overflow: hidden;
  background-color: var(--win98-window-bg);
}

/* Resize handles */
.win98-resize-handle {
  position: absolute;
  background: transparent;
  z-index: 10;
}

/* Corner handles */
.resize-handle-nw {
  top: -3px;
  left: -3px;
  width: 6px;
  height: 6px;
  cursor: nw-resize;
}

.resize-handle-ne {
  top: -3px;
  right: -3px;
  width: 6px;
  height: 6px;
  cursor: ne-resize;
}

.resize-handle-sw {
  bottom: -3px;
  left: -3px;
  width: 6px;
  height: 6px;
  cursor: sw-resize;
}

.resize-handle-se {
  bottom: -3px;
  right: -3px;
  width: 6px;
  height: 6px;
  cursor: se-resize;
}

/* Side handles */
.resize-handle-n {
  top: -3px;
  left: 6px;
  right: 6px;
  height: 6px;
  cursor: n-resize;
}

.resize-handle-s {
  bottom: -3px;
  left: 6px;
  right: 6px;
  height: 6px;
  cursor: s-resize;
}

.resize-handle-w {
  left: -3px;
  top: 6px;
  bottom: 6px;
  width: 6px;
  cursor: w-resize;
}

.resize-handle-e {
  right: -3px;
  top: 6px;
  bottom: 6px;
  width: 6px;
  cursor: e-resize;
}

/* Resize handle hover effects */
.win98-resize-handle:hover {
  background-color: rgba(0, 0, 255, 0.1);
}

/* Visual feedback during resize */
.win98-window.resizing {
  outline: 1px dashed rgba(0, 0, 255, 0.5);
  outline-offset: -1px;
}

.win98-window.resizing .win98-resize-handle {
  background-color: rgba(0, 0, 255, 0.2);
}

/* Resize animations */
.win98-window:not(.resizing):not(.dragging) {
  transition: left 0.1s ease, top 0.1s ease, width 0.1s ease, height 0.1s ease;
}

/* Touch support for mobile devices */
@media (hover: none) and (pointer: coarse) {
  .win98-resize-handle {
    width: 12px !important;
    height: 12px !important;
  }
  
  .resize-handle-nw {
    top: -6px;
    left: -6px;
  }
  
  .resize-handle-ne {
    top: -6px;
    right: -6px;
  }
  
  .resize-handle-sw {
    bottom: -6px;
    left: -6px;
  }
  
  .resize-handle-se {
    bottom: -6px;
    right: -6px;
  }
  
  .resize-handle-n {
    top: -6px;
    left: 12px;
    right: 12px;
    height: 12px;
  }
  
  .resize-handle-s {
    bottom: -6px;
    left: 12px;
    right: 12px;
    height: 12px;
  }
  
  .resize-handle-w {
    left: -6px;
    top: 12px;
    bottom: 12px;
    width: 12px;
  }
  
  .resize-handle-e {
    right: -6px;
    top: 12px;
    bottom: 12px;
    width: 12px;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .win98-resize-handle:hover {
    background-color: rgba(255, 255, 255, 0.3);
    border: 1px solid #000;
  }
  
  .win98-window.resizing {
    outline: 2px solid #000;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .win98-window {
    transition: none !important;
  }
  
  .win98-window.resizing {
    outline: none;
  }
}

/* Resize constraint visual feedback */
.win98-window.resize-constrained {
  box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.5);
}

/* Resize preview (for future implementation) */
.win98-resize-preview {
  position: absolute;
  border: 2px dashed rgba(0, 0, 255, 0.7);
  background: rgba(0, 0, 255, 0.1);
  pointer-events: none;
  z-index: 9999;
}

/* Keyboard resize indicator */
.win98-window.keyboard-resizing {
  outline: 2px solid rgba(0, 255, 0, 0.7);
  outline-offset: -2px;
}

/* Window state indicators */
.win98-window::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  pointer-events: none;
  z-index: -1;
}

.win98-window.active::before {
  box-shadow: 0 0 0 1px rgba(0, 0, 255, 0.3);
}

/* Performance optimizations */
.win98-window.resizing * {
  pointer-events: none;
}

.win98-window.dragging * {
  pointer-events: none;
}

/* Accessibility improvements */
.win98-resize-handle:focus {
  outline: 2px solid #0066cc;
  outline-offset: 1px;
  background-color: rgba(0, 102, 204, 0.2);
}

/* Screen reader support */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}