/* ============================================
   macOS Window Manager CSS
   Premium Window Styles with Traffic Lights
   ============================================ */

.macos-window {
  position: absolute;
  background: var(--bg-window);
  border-radius: 12px;
  box-shadow: var(--shadow-window);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 300px;
  min-height: 200px;
  border: 0.5px solid var(--border-color);
  transition: box-shadow 0.3s ease, border-radius 0.3s ease;
  will-change: transform;
}

.macos-window.focused {
  z-index: 100;
  box-shadow: var(--shadow-window);
}

.macos-window:not(.focused) {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

/* Window Opening Animation */
.macos-window.window-opening {
  animation: windowOpen 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes windowOpen {
  0% {
    opacity: 0;
    transform: scale(0.85);
    filter: blur(4px);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

/* Window Closing Animation */
.macos-window.window-closing {
  animation: windowClose 0.22s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes windowClose {
  0% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.85);
    filter: blur(4px);
  }
}

/* Window Minimize Animation */
.macos-window.window-minimizing {
  animation: windowMinimize 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  transform-origin: bottom center;
}

@keyframes windowMinimize {
  0% {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.12) translateY(450px);
    filter: blur(2px);
  }
}

/* Window Unminimize Animation */
.macos-window.window-unminimizing {
  animation: windowUnminimize 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform-origin: bottom center;
}

@keyframes windowUnminimize {
  0% {
    opacity: 0;
    transform: scale(0.12) translateY(450px);
    filter: blur(2px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}

/* Window Maximize/Fullscreen Animation */
.macos-window.window-maximizing {
  transition: all 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.macos-window.maximized {
  border-radius: 0 !important;
}

/* ============ TITLE BAR ============ */
.window-titlebar {
  height: 38px;
  min-height: 38px;
  background: var(--bg-toolbar);
  display: flex;
  align-items: center;
  padding: 0 12px;
  position: relative;
  cursor: default;
  border-bottom: 1px solid var(--separator-color);
  -webkit-app-region: drag;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.macos-window:not(.focused) .window-titlebar {
  background: var(--bg-secondary);
}

/* Traffic Lights */
.traffic-lights {
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 2;
  -webkit-app-region: no-drag;
}

.traffic-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.traffic-close {
  background: var(--traffic-close);
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.06);
}

.traffic-minimize {
  background: var(--traffic-minimize);
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.06);
}

.traffic-maximize {
  background: var(--traffic-maximize);
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.06);
}

/* Inactive state */
.macos-window:not(.focused) .traffic-close,
.macos-window:not(.focused) .traffic-minimize,
.macos-window:not(.focused) .traffic-maximize {
  background: var(--traffic-inactive);
  border-color: rgba(0, 0, 0, 0.06);
}

/* Hover icons inside traffic lights */
.traffic-light svg {
  width: 8px;
  height: 8px;
  opacity: 0;
  transition: opacity 0.1s ease;
}

.traffic-lights:hover .traffic-light svg {
  opacity: 1;
}

.traffic-close svg {
  color: #4d0000;
}

.traffic-minimize svg {
  color: #995700;
}

.traffic-maximize svg {
  color: #006500;
}

/* Hover effects */
.traffic-lights:hover .traffic-close {
  background: var(--traffic-close-hover);
}

.traffic-lights:hover .traffic-minimize {
  background: var(--traffic-minimize-hover);
}

.traffic-lights:hover .traffic-maximize {
  background: var(--traffic-maximize-hover);
}

.traffic-light:active {
  filter: brightness(0.85);
}

/* Window Title */
.window-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 120px);
  letter-spacing: -0.1px;
  pointer-events: none;
}

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

/* ============ WINDOW TOOLBAR ============ */
.window-toolbar {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  gap: 8px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--separator-color);
  flex-shrink: 0;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  color: var(--text-secondary);
}

.toolbar-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

body.dark-mode .toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.toolbar-btn svg {
  width: 16px;
  height: 16px;
}

.toolbar-separator {
  width: 1px;
  height: 20px;
  background: var(--separator-color);
}

.toolbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.toolbar-breadcrumb span {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.1s;
}

.toolbar-breadcrumb span:hover {
  background: rgba(0, 0, 0, 0.06);
}

.toolbar-breadcrumb .breadcrumb-sep {
  color: var(--text-tertiary);
  font-size: 10px;
}

.toolbar-search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 8px;
  margin-left: auto;
}

body.dark-mode .toolbar-search {
  background: rgba(255, 255, 255, 0.06);
}

.toolbar-search input {
  border: none;
  background: transparent;
  font-size: 12px;
  color: var(--text-primary);
  outline: none;
  width: 140px;
  font-family: var(--system-font);
}

.toolbar-search input::placeholder {
  color: var(--text-tertiary);
}

.toolbar-search svg {
  width: 12px;
  height: 12px;
  color: var(--text-tertiary);
}

/* ============ WINDOW CONTENT ============ */
.window-content {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--bg-primary);
}

/* ============ RESIZE HANDLES ============ */
.resize-handle {
  position: absolute;
  z-index: 10;
}

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

/* ============ SPLIT VIEW ============ */
.window-split-left {
  width: 50%;
  background: var(--bg-sidebar);
  overflow-y: auto;
  border-right: 1px solid var(--separator-color);
}

.window-split-right {
  flex: 1;
  overflow-y: auto;
}
