/* Darkfoo Terminal Window System CSS */

/* Window container styles */
.darkfoo-window {
    border-radius: 8px;
    overflow: hidden;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(0, 255, 255, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.9);
    transition: box-shadow 0.2s ease;
    animation: window-appear 0.3s ease-out;
    will-change: transform;
    transform: translateZ(0); /* Hardware acceleration */
}

.darkfoo-window:hover {
    box-shadow:
        0 15px 40px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(0, 255, 255, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Window states */
.darkfoo-window.dragging {
    transition: none;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.8),
        0 0 0 2px var(--neon-cyan),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);

    /* Removed rotation effect - no tilting during drag */
}

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

.darkfoo-window.maximized {
    border-radius: 0 !important;
    box-shadow: none !important;
}

.darkfoo-window.minimized {
    transform: scale(0.8);
    opacity: 0;
    transition:
        transform 0.3s ease,
        opacity 0.3s ease;
    pointer-events: none;
}

/* Window title bar */
.window-titlebar {
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2) 0%, rgba(240, 0, 204, 0.2) 100%);
    border-bottom: 1px solid rgba(0, 255, 255, 0.4);
    padding: 8px 12px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    cursor: move;
    user-select: none;
    min-height: 32px;
}

.window-titlebar:hover {
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.3) 0%, rgba(240, 0, 204, 0.3) 100%);
}

.window-title {
    display: flex;
    align-items: center;
    flex: 1;
}

.window-title-text {
    color: var(--neon-cyan);
    font-weight: bold;
    font-size: 0.9rem;
    text-shadow: 0 0 5px var(--neon-cyan);
    letter-spacing: 0.05em;
}

/* Window controls */
.window-controls {
    display: flex;
    gap: 4px;
}

.window-btn {
    width: 24px;
    height: 24px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 0.8);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.15s ease;
    font-family: monospace;
}

.window-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.window-minimize:hover {
    background: rgba(255, 193, 7, 0.3);
    border-color: #ffc107;
    color: #ffc107;
}

.window-maximize:hover {
    background: rgba(40, 167, 69, 0.3);
    border-color: #28a745;
    color: #28a745;
}

.window-close:hover {
    background: rgba(220, 53, 69, 0.3);
    border-color: #dc3545;
    color: #dc3545;
}

/* Terminal content area */
.windowed-mode .terminal-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: rgba(0, 0, 0, 0.8);
}

.windowed-mode .terminal-input-line {
    background: rgba(0, 0, 0, 0.9);
    border-top: 1px solid rgba(0, 255, 255, 0.3);
    padding: 12px 15px;
    position: sticky;
    bottom: 0;
}

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

/* Edge handles */
.resize-handle.resize-n {
    top: -3px;
    left: 8px;
    right: 8px;
    height: 6px;
    cursor: n-resize;
}

.resize-handle.resize-s {
    bottom: -3px;
    left: 8px;
    right: 8px;
    height: 6px;
    cursor: s-resize;
}

.resize-handle.resize-e {
    top: 8px;
    right: -3px;
    bottom: 8px;
    width: 6px;
    cursor: e-resize;
}

.resize-handle.resize-w {
    top: 8px;
    left: -3px;
    bottom: 8px;
    width: 6px;
    cursor: w-resize;
}

/* Corner handles */
.resize-handle.resize-nw {
    top: -3px;
    left: -3px;
    width: 12px;
    height: 12px;
    cursor: nw-resize;
}

.resize-handle.resize-ne {
    top: -3px;
    right: -3px;
    width: 12px;
    height: 12px;
    cursor: ne-resize;
}

.resize-handle.resize-sw {
    bottom: -3px;
    left: -3px;
    width: 12px;
    height: 12px;
    cursor: sw-resize;
}

.resize-handle.resize-se {
    bottom: -3px;
    right: -3px;
    width: 12px;
    height: 12px;
    cursor: se-resize;
}

/* Resize handle hover effects */
.resize-handle:hover {
    background: rgba(0, 255, 255, 0.3);
}

.resize-handle.resize-nw:hover,
.resize-handle.resize-ne:hover,
.resize-handle.resize-sw:hover,
.resize-handle.resize-se:hover {
    border-radius: 50%;
}

/* Snap indicator - subtle and non-intrusive */
.snap-indicator {
    border: 1px dashed rgba(0, 255, 255, 0.4) !important;
    background: rgba(0, 255, 255, 0.05) !important;
    border-radius: 4px !important;
    opacity: 0.6 !important;
    transition: opacity 0.2s ease !important;
}

.snap-indicator:hover {
    opacity: 0.8 !important;
}

/* Body states during drag/resize */
body.dragging {
    cursor: move !important;
    user-select: none;
}

body.resizing {
    user-select: none;
}

body.dragging *,
body.resizing * {
    pointer-events: none;
}

body.dragging .darkfoo-window,
body.resizing .darkfoo-window {
    pointer-events: all;
}

/* Terminal toggle button updates for windowed mode */
.windowed-mode ~ .terminal-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 255, 255, 0.1);
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    transition: all 0.3s ease;
    z-index: 999;
    backdrop-filter: blur(5px);
}

.windowed-mode ~ .terminal-toggle:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.4);
    transform: translateY(-2px);
}

/* Hide terminal toggle when window is visible */
.windowed-mode:not([style*='display: none']) ~ .terminal-toggle {
    opacity: 0.3;
}

.windowed-mode:not([style*='display: none']) ~ .terminal-toggle:hover {
    opacity: 1;
}

/* Custom scrollbar for windowed terminal */
.windowed-mode .terminal-content::-webkit-scrollbar {
    width: 8px;
}

.windowed-mode .terminal-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.windowed-mode .terminal-content::-webkit-scrollbar-thumb {
    background: var(--neon-cyan);
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.windowed-mode .terminal-content::-webkit-scrollbar-thumb:hover {
    background: var(--neon-pink);
}

/* Window animations */
@keyframes window-appear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Window animation - moved to main .darkfoo-window rule */

/* Responsive adjustments */
@media (width <= 768px) {
    .darkfoo-window {
        /* On mobile, make windows full screen or near full screen */
        border-radius: 0 !important;
    }

    .window-titlebar {
        padding: 12px;
        min-height: 44px; /* Touch-friendly */
    }

    .window-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .resize-handle {
        /* Make resize handles larger on mobile */
        background: rgba(0, 255, 255, 0.1) !important;
    }

    .resize-handle.resize-n,
    .resize-handle.resize-s {
        height: 12px;
    }

    .resize-handle.resize-e,
    .resize-handle.resize-w {
        width: 12px;
    }

    .resize-handle.resize-nw,
    .resize-handle.resize-ne,
    .resize-handle.resize-sw,
    .resize-handle.resize-se {
        width: 20px;
        height: 20px;
    }
}

/* High DPI display optimizations */
@media (resolution >= 2dppx), (resolution >= 192dpi) {
    .window-titlebar {
        border-bottom-width: 0.5px;
    }

    .resize-handle {
        border-width: 0.5px;
    }
}

/* Focus states for accessibility */
.window-btn:focus {
    outline: 2px solid var(--neon-cyan);
    outline-offset: 2px;
}

.darkfoo-window:focus-within {
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.5),
        0 0 0 2px var(--neon-cyan),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Terminal-specific windowed enhancements */
.windowed-mode .terminal-output {
    margin-bottom: 8px;
}

.windowed-mode .terminal-input {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 4px;
    padding: 8px 12px;
}

.windowed-mode .terminal-input:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 0 2px rgba(0, 255, 255, 0.2);
}

/* Performance optimizations - moved to main .darkfoo-window rule */

.dragging .darkfoo-window,
.resizing .darkfoo-window {
    will-change: transform, left, top, width, height;
}
