/* window.css — additive styles for the in-page window manager (window.js).
 *
 * Reuses shared common-web classes wherever possible:
 *   .card               — the window frame (background, border, radius, padding)
 *   .fs-title           — the sticky header bar (font, spacing, sticky top)
 *   .err-close          — the ✕ button (matches fullscreen + toast close)
 *   .fs-active          — the MAXIMIZED state (inset: 0, backdrop shadow)
 *
 * Only bits that don't have a shared equivalent live here:
 *   - Fixed-position + drag origin
 *   - Minimize/maximize buttons (fs-trigger sized, not styled elsewhere)
 *   - Taskbar strip for minimised windows
 */

.cw-window {
  position: fixed;
  padding: 0;
  border: 4px solid var(--surface2, #334155);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  display: flex; flex-direction: column;
  min-width: 320px; min-height: 200px;
  overflow: visible;
  z-index: 100;
}
.cw-window.fs-active .cw-resize { display: none; }

.cw-window.cw-window-minimized { display: none; }

/* Header: reuses .fs-title layout (font, sticky). We just add drag affordance. */
.cw-window > .fs-title {
  cursor: move; user-select: none;
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  position: static;               /* .fs-title is sticky-top; not needed here */
}
.cw-window .cw-window-title-text {
  flex: 1 1 auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cw-window .cw-window-controls { display: flex; gap: 0.15rem; }

/* Min / Max buttons — sized to match .err-close (which we use for Close). */
.cw-window-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0;
  background: var(--surface2); color: var(--muted);
  border: 1px solid var(--surface2); border-radius: 5px;
  font-size: 1rem; line-height: 1; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.cw-window-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.cw-window-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 2px;
  border-radius: 0 0 4px 4px;
}
.cw-window-loading { color: var(--muted); }
.cw-window-error   { color: var(--accent); }

/* Rich error card shown when the fetched partial fails to load. */
.cw-window-error-card {
  display: flex; flex-direction: column; gap: 0.6rem;
  padding: 0.4rem 0;
}
.cw-window-error-title {
  margin: 0; color: var(--accent);
  font-size: 1.1rem; font-weight: 600;
}
.cw-window-error-meta {
  margin: 0; color: var(--muted); font-size: 0.85rem;
  word-break: break-all;
}
.cw-window-error-meta code {
  background: var(--surface2); padding: 0.1rem 0.35rem; border-radius: 3px;
}
.cw-window-error-detail {
  margin: 0; padding: 0.5rem 0.75rem;
  background: var(--surface2); border-radius: 4px;
  font-size: 0.85rem; white-space: pre-wrap; word-break: break-word;
  max-height: 8rem; overflow: auto;
}
.cw-window-error-body {
  border: 1px solid var(--surface2); border-radius: 4px;
  padding: 0.4rem 0.6rem;
}
.cw-window-error-body summary {
  cursor: pointer; color: var(--muted); font-size: 0.85rem;
  padding-bottom: 0.3rem;
}
.cw-window-error-body pre {
  margin: 0; padding: 0.5rem; background: var(--surface2);
  border-radius: 4px; font-size: 0.8rem; overflow: auto;
  max-height: 20rem; white-space: pre-wrap; word-break: break-word;
}
.cw-window-error-frame {
  width: 100%; min-height: 20rem; border: 0; background: #fff;
  border-radius: 4px;
}
.cw-window-error-hint {
  margin: 0; color: var(--muted); font-size: 0.8rem;
}

/* Taskbar (minimised windows collect here at page bottom). */
#cw-window-taskbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; gap: 0.25rem; padding: 0.25rem;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9999;
}
.cw-window-taskbtn {
  padding: 0.35rem 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  color: #fff; border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px; cursor: pointer;
  font-size: 0.85rem; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cw-window-taskbtn:hover { background: rgba(255, 255, 255, 0.2); }

/* Phones: windows fill the viewport (matches .fs-active behavior). */
@media (max-width: 720px) {
  .cw-window { inset: 0 !important; width: auto !important; height: auto !important;
               border-radius: 0; box-sizing: border-box; }
  .cw-window > .fs-title { cursor: default; }
}
