/* Window manager chrome */

#windows-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  padding-top: var(--topbar-h);
}

.window {
  position: absolute;
  min-width: 320px;
  min-height: 200px;
  background: var(--bg-secondary);
  color: var(--fg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--window-shadow-unfocused);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
  border: 1px solid var(--border);
  opacity: 0;
  transform: scale(0.96);
  transition:
    opacity 160ms ease,
    transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow var(--transition);
  will-change: left, top, width, height;
}

.window.visible {
  opacity: 1;
  transform: scale(1);
}

.window.closing {
  opacity: 0;
  transform: scale(0.94);
  pointer-events: none;
}

.window.focused {
  box-shadow: var(--window-shadow);
  border-color: color-mix(in srgb, var(--border) 70%, var(--accent));
}

.window.maximized {
  border-radius: 0 !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: none !important;
}

.window.minimized {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: scale(0.85) translateY(40px) !important;
}

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

.window-titlebar {
  height: var(--titlebar-h);
  min-height: var(--titlebar-h);
  background: var(--headerbar-bg);
  border-bottom: 1px solid var(--headerbar-border);
  display: flex;
  align-items: center;
  padding: 0 8px 0 12px;
  gap: 8px;
  flex-shrink: 0;
  cursor: default;
}

.window.focused .window-titlebar {
  background: var(--headerbar-bg);
}

.window-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  order: -1;
  margin-right: 4px;
}

.wc-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--fg-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.wc-btn:hover {
  background: var(--hover);
  color: var(--fg-primary);
}

.wc-btn.close:hover {
  background: var(--destructive);
  color: #fff;
}

.wc-btn svg {
  width: 12px;
  height: 12px;
}

.window-title {
  flex: 1;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  pointer-events: none;
}

.window-titlebar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 72px;
  justify-content: flex-end;
}

.window-titlebar-actions .tb-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--fg-secondary);
}

.window-titlebar-actions .tb-btn:hover {
  background: var(--hover);
  color: var(--fg-primary);
}

.window-titlebar-actions .tb-btn svg {
  width: 16px;
  height: 16px;
}

/* Header bar style (GNOME apps) */
.window-headerbar {
  height: var(--titlebar-h);
  min-height: var(--titlebar-h);
  background: var(--headerbar-bg);
  border-bottom: 1px solid var(--headerbar-border);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
  flex-shrink: 0;
}

.window-headerbar .window-controls {
  order: 0;
  margin-right: 4px;
}

.window-headerbar .hb-start,
.window-headerbar .hb-end {
  display: flex;
  align-items: center;
  gap: 4px;
}

.window-headerbar .hb-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
  font-weight: 700;
  font-size: 14px;
}

.window-headerbar .hb-btn {
  height: 34px;
  min-width: 34px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--fg-primary);
  font-weight: 600;
  font-size: 13px;
}

.window-headerbar .hb-btn:hover {
  background: var(--hover);
}

.window-headerbar .hb-btn.active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}

.window-headerbar .hb-btn.suggested {
  background: var(--accent);
  color: #fff;
}

.window-headerbar .hb-btn.suggested:hover {
  background: var(--accent-hover);
}

.window-headerbar .hb-btn svg {
  width: 16px;
  height: 16px;
}

.window-headerbar .hb-entry {
  height: 34px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  padding: 0 14px;
  min-width: 120px;
  max-width: 320px;
  width: 100%;
  font-size: 13px;
}

.window-headerbar .hb-entry:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.window-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  position: relative;
}

.window-body.no-scroll {
  overflow: hidden;
}

/* Resize handles */
.resize-handle {
  position: absolute;
  z-index: 5;
}

.resize-handle.n {
  top: 0;
  left: 8px;
  right: 8px;
  height: 4px;
  cursor: ns-resize;
}
.resize-handle.s {
  bottom: 0;
  left: 8px;
  right: 8px;
  height: 4px;
  cursor: ns-resize;
}
.resize-handle.e {
  right: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  cursor: ew-resize;
}
.resize-handle.w {
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  cursor: ew-resize;
}
.resize-handle.ne {
  top: 0;
  right: 0;
  width: 10px;
  height: 10px;
  cursor: nesw-resize;
}
.resize-handle.nw {
  top: 0;
  left: 0;
  width: 10px;
  height: 10px;
  cursor: nwse-resize;
}
.resize-handle.se {
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  cursor: nwse-resize;
}
.resize-handle.sw {
  bottom: 0;
  left: 0;
  width: 10px;
  height: 10px;
  cursor: nesw-resize;
}

.window.maximized .resize-handle {
  display: none;
}

/* App content shared */
.app-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.app-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-sidebar.narrow {
  width: 200px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--fg-primary);
  text-align: left;
  width: 100%;
  font-weight: 500;
}

.sidebar-item:hover {
  background: var(--hover);
}

.sidebar-item.active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  font-weight: 700;
}

.sidebar-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-secondary);
  padding: 12px 12px 6px;
}

.app-content {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 20px 24px;
  background: var(--bg-primary);
}

.app-content.flush {
  padding: 0;
}

/* Lists / rows */
.list-box {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}

.list-row:last-child {
  border-bottom: none;
}

.list-row:hover {
  background: var(--hover);
}

.list-row .row-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.list-row .row-text {
  flex: 1;
  min-width: 0;
}

.list-row .row-title {
  font-weight: 600;
  font-size: 14px;
}

.list-row .row-sub {
  font-size: 12.5px;
  color: var(--fg-secondary);
  margin-top: 1px;
}

.list-row .row-suffix {
  color: var(--fg-secondary);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Switch toggle */
.switch {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--bg-dark);
  position: relative;
  flex-shrink: 0;
  transition: background var(--transition-fast);
  border: none;
  cursor: pointer;
  padding: 0;
}

.switch.on {
  background: var(--accent);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform var(--transition-fast);
}

.switch.on::after {
  transform: translateX(20px);
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 24px;
  color: var(--fg-secondary);
  text-align: center;
  flex: 1;
}

.empty-state .empty-icon {
  width: 64px;
  height: 64px;
  opacity: 0.45;
  margin-bottom: 8px;
}

.empty-state h3 {
  margin: 0;
  color: var(--fg-primary);
  font-size: 17px;
}

.empty-state p {
  margin: 0;
  max-width: 280px;
  line-height: 1.4;
  font-size: 13.5px;
}

/* Status bar */
.app-statusbar {
  height: 28px;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 12px;
  color: var(--fg-secondary);
  flex-shrink: 0;
  gap: 12px;
}

/* Path bar / breadcrumbs */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.breadcrumb button {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  color: var(--fg-secondary);
  white-space: nowrap;
}

.breadcrumb button:hover {
  background: var(--hover);
  color: var(--fg-primary);
}

.breadcrumb button.current {
  color: var(--fg-primary);
}

.breadcrumb .sep {
  color: var(--fg-disabled);
  font-size: 12px;
}

/* Selection */
::selection {
  background: var(--selection);
}

.selectable {
  user-select: text;
  cursor: text;
}

/* Focus visible */
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
