/* WebOS — Window Styles */

/* ===== Window Container ===== */
.window {
  position: absolute;
  min-width: var(--window-min-width);
  min-height: var(--window-min-height);
  background: var(--color-window-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  box-shadow: 0 4px 24px var(--color-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  transition: box-shadow var(--transition-fast),
              opacity var(--transition-normal),
              transform var(--transition-normal);
  transform-origin: center center;
  opacity: 1;
}

/* Window open animation */
.window.opening {
  animation: windowOpen 200ms ease-out forwards;
}

@keyframes windowOpen {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Window close animation */
.window.closing {
  animation: windowClose 200ms ease-in forwards;
  pointer-events: none;
}

@keyframes windowClose {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.92);
  }
}

.window.focused {
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55);
}

/* Minimize animation: shrink toward taskbar */
.window.minimizing {
  animation: windowMinimize 250ms ease-in forwards;
}

@keyframes windowMinimize {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.85) translateY(40px);
  }
}

/* Restore animation: grow from taskbar */
.window.restoring {
  animation: windowRestore 250ms ease-out forwards;
}

@keyframes windowRestore {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(40px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.window.minimized {
  display: none;
}

/* ===== Window Header (Title Bar) ===== */
.window-header {
  height: var(--window-header-height);
  min-height: var(--window-header-height);
  background: var(--color-window-header);
  display: flex;
  align-items: center;
  padding: 0 var(--space-sm);
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  gap: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.window-title-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.window-title {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* ===== Window Controls ===== */
.window-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.window-controls button {
  width: 28px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
  padding: 0;
}

.window-controls button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text);
}

.window-controls .btn-close:hover {
  background: var(--color-accent);
  color: #fff;
}

/* ===== Window Body ===== */
.window-body {
  flex: 1;
  overflow: auto;
  padding: var(--space-md);
  position: relative;
}

/* ===== Resize Handles ===== */
.resize-handle {
  position: absolute;
  z-index: 2;
}

.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-nw { top: -4px; left: -4px; width: 14px; height: 14px; cursor: nw-resize; }
.resize-handle-ne { top: -4px; right: -4px; width: 14px; height: 14px; cursor: ne-resize; }
.resize-handle-sw { bottom: -4px; left: -4px; width: 14px; height: 14px; cursor: sw-resize; }
.resize-handle-se { bottom: -4px; right: -4px; width: 14px; height: 14px; cursor: se-resize; }

/* ===== Taskbar App Indicators ===== */
.taskbar-app-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  height: 36px;
  background: transparent;
  border: none;
  color: var(--color-text);
  font-size: var(--font-size-sm);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  white-space: nowrap;
  max-width: 180px;
  transition: background var(--transition-fast);
}

.taskbar-app-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.taskbar-app-item.focused {
  background: rgba(255, 255, 255, 0.12);
  border-bottom: 2px solid var(--color-accent);
}

.taskbar-app-item-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.taskbar-app-item-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Light Theme ===== */
[data-theme="light"] .window {
  background: var(--lt-color-window-bg);
  border-color: var(--lt-color-border);
}

[data-theme="light"] .window.focused {
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .window-header {
  background: var(--lt-color-window-header);
}

[data-theme="light"] .window-controls button:hover {
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .window-controls .btn-close:hover {
  background: var(--lt-color-accent);
  color: #fff;
}

[data-theme="light"] .taskbar-app-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .taskbar-app-item.focused {
  background: rgba(0, 0, 0, 0.08);
  border-bottom-color: var(--lt-color-accent);
}
