/* NOTE: CSS containment — isolate the drawer from window DOM insertions/removals.
   Omitted on .mud-main-content because contain:layout/paint creates a containing
   block that breaks position:fixed for inline overlays (e.g. MudDatePicker Dialog). */
.mud-drawer { contain: layout paint; }

.mw-win {
    position: fixed;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    overflow: hidden;
    min-width: 200px;
    min-height: 120px;
    visibility: hidden;
}
.mw-win--active {
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
}
/* NOTE: Remove border-radius when maximized to fill viewport cleanly */
.mw-win--maximized {
    border-radius: 0;
}

/* NOTE: Active titlebar dimming — inactive windows have reduced opacity
   on the titlebar so the frontmost window is visually prominent */
.mw-win-titlebar {
    display: flex;
    align-items: center;
    padding: 6px 8px 6px 12px;
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.mw-win--active .mw-win-titlebar { opacity: 1; }
.mw-win-titlebar:active { cursor: grabbing; }

.mw-win-title {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* NOTE: Shared style for all titlebar buttons (minimize, maximize, close) */
.mw-win-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 2px;
    display: flex;
    border-radius: 4px;
    margin-left: 2px;
}
.mw-win-btn:hover { background: rgba(255, 255, 255, 0.2); }
.mw-win-close:hover { background: rgba(255, 80, 80, 0.5); }

.mw-win-body {
    flex: 1;
    overflow: auto;
    padding: 12px;
}

/* NOTE: Window animations — GPU-composited only (transform + opacity).
   Never animate layout properties (width, height, top, left).
   Maximize/restore uses FLIP technique: instant layout change masked by
   an inverse transform that transitions to identity. */

/* NOTE: Open/restore initial state — scaled down + transparent.
   Applied before visibility:visible, then removed to trigger transition. */
.mw-win--from-hidden {
    opacity: 0;
    transform: scale(0.85);
}
/* NOTE: Open/restore transition — Apple-style deceleration */
.mw-win--anim-open {
    transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1),
                opacity 0.2s cubic-bezier(0.2, 0, 0, 1);
}
/* NOTE: Close animation — accelerates out, pointer-events disabled during fade */
.mw-win--anim-close {
    opacity: 0;
    transform: scale(0.85);
    transition: transform 0.18s cubic-bezier(0.4, 0, 1, 1),
                opacity 0.15s cubic-bezier(0.4, 0, 1, 1);
    pointer-events: none;
}
/* NOTE: Directional minimize/restore — JS sets inline transform + opacity
   to fly the window toward/from its taskbar item position. CSS only
   provides the transition timing. Opacity finishes before transform so
   the window fades before reaching full scale-down. */
.mw-win--anim-minimize {
    transition: transform 0.4s cubic-bezier(0.2, 0, 0, 1),
                opacity 0.25s cubic-bezier(0.2, 0, 0, 1);
    pointer-events: none;
}
/* NOTE: FLIP transition for maximize/restore — uses computed inverse
   transform set by JS. Opacity dip (0.7 → 1) adds depth to match
   the minimize animation feel. */
.mw-win--anim-flip {
    transition: transform 0.4s cubic-bezier(0.2, 0, 0, 1),
                opacity 0.3s cubic-bezier(0.2, 0, 0, 1);
}

/* NOTE: Resize grip — positioned at bottom-right corner of window.
   Uses ::after for subtle diagonal lines indicating drag affordance. */
.mw-win-resize-grip {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    z-index: 1;
}
.mw-win-resize-grip::after {
    content: '';
    position: absolute;
    right: 3px;
    bottom: 3px;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--mud-palette-text-secondary);
    border-bottom: 2px solid var(--mud-palette-text-secondary);
    opacity: 0.4;
}
.mw-win-resize-grip:hover::after { opacity: 0.8; }
/* NOTE: Hide resize grip when maximized — resize not allowed */
.mw-win--maximized .mw-win-resize-grip { display: none; }

/* NOTE: Taskbar strip — fixed at viewport bottom. Created lazily
   by JS on first minimize, removed when empty. */
.mw-win-taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 2px;
    padding: 2px 4px;
    background: var(--mud-palette-surface);
    border-top: 1px solid var(--mud-palette-lines-default);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    z-index: 999;
}
.mw-win-task-item {
    padding: 4px 12px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 4px;
    background: var(--mud-palette-background);
    color: var(--mud-palette-text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: mw-win-task-enter 0.15s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.mw-win-task-item:hover {
    background: var(--mud-palette-background-gray);
}
@keyframes mw-win-task-enter {
    from { opacity: 0; transform: translateY(4px); }
}
