/**
 * Windows.css - Système de fenêtres flottantes iOS style
 * Gestion complète des fenêtres modulaires, draggables et resizable
 */

/* Container principal des fenêtres */
.space-windows-container {
    position: fixed;
    top: 60px;
    left: 80px;
    right: 0;
    bottom: 0;
    z-index: 100;
    pointer-events: none;
}

/* Fenêtre individuelle */
.space-window {
    position: absolute;
    min-width: 400px;
    min-height: 300px;
    max-width: 95vw;
    max-height: calc(100vh - 80px);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15),
                0 0 0 0.5px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    pointer-events: all;
    transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.space-window.active {
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25),
                0 0 0 1px rgba(0, 0, 0, 0.12);
    z-index: 1000 !important;
}

.space-window.minimized {
    transform: scale(0.8);
    opacity: 0;
    pointer-events: none;
}

.space-window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: calc(100vw - 80px) !important;
    height: calc(100vh - 60px) !important;
    border-radius: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header de la fenêtre */
.window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(180deg, 
                rgba(255, 255, 255, 0.9) 0%, 
                rgba(248, 248, 248, 0.9) 100%);
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
}

.window-header.dragging {
    cursor: grabbing;
    background: linear-gradient(180deg, 
                rgba(245, 245, 245, 0.95) 0%, 
                rgba(240, 240, 240, 0.95) 100%);
}

/* Titre et icône */
.window-title-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.window-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #007AFF;
}

.window-title {
    font-size: 15px;
    font-weight: 600;
    color: #1d1d1f;
    letter-spacing: -0.2px;
}

/* Contrôles de la fenêtre */
.window-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.window-control-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.04);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: #666;
    font-size: 16px;
}

.window-control-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    transform: scale(1.05);
}

.window-control-btn:active {
    transform: scale(0.95);
}

.window-control-btn.minimize {
    color: #FF9500;
}

.window-control-btn.maximize {
    color: #34C759;
}

.window-control-btn.close {
    color: #FF3B30;
}

.window-control-btn.close:hover {
    background: rgba(255, 59, 48, 0.1);
}

/* Contenu de la fenêtre */
.window-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #fff;
}

.window-content::-webkit-scrollbar {
    width: 8px;
}

.window-content::-webkit-scrollbar-track {
    background: transparent;
}

.window-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.window-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

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

.window-resize-handle.n {
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    cursor: n-resize;
}

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

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

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

.window-resize-handle.ne {
    top: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: ne-resize;
}

.window-resize-handle.nw {
    top: 0;
    left: 0;
    width: 16px;
    height: 16px;
    cursor: nw-resize;
}

.window-resize-handle.se {
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: se-resize;
}

.window-resize-handle.sw {
    bottom: 0;
    left: 0;
    width: 16px;
    height: 16px;
    cursor: sw-resize;
}

/* Animations d'ouverture/fermeture */
@keyframes windowOpen {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes windowClose {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
}

.space-window.opening {
    animation: windowOpen 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.space-window.closing {
    animation: windowClose 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Overlay de drag */
.window-drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    cursor: grabbing;
    display: none;
}

.window-drag-overlay.active {
    display: block;
}

/* Mode sombre */
body.dark-mode .space-window {
    background: rgba(30, 30, 30, 0.98);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                0 0 0 0.5px rgba(255, 255, 255, 0.1);
}

body.dark-mode .window-header {
    background: linear-gradient(180deg, 
                rgba(40, 40, 40, 0.9) 0%, 
                rgba(35, 35, 35, 0.9) 100%);
    border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .window-title {
    color: #f5f5f7;
}

body.dark-mode .window-content {
    background: #1e1e1e;
}

body.dark-mode .window-control-btn {
    background: rgba(255, 255, 255, 0.08);
    color: #aaa;
}

body.dark-mode .window-control-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Responsive */
@media (max-width: 768px) {
    .space-window {
        min-width: 90vw;
        max-width: 95vw;
    }
    
    .space-window.maximized {
        width: 100vw !important;
        height: 100vh !important;
        left: 0 !important;
        border-radius: 0;
    }
    
    .window-header {
        padding: 12px 16px;
    }
    
    .window-content {
        padding: 16px;
    }
}

/* Effet glassmorphism amélioré */
.space-window.glass-effect {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(60px) saturate(180%);
    -webkit-backdrop-filter: blur(60px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

body.dark-mode .space-window.glass-effect {
    background: rgba(30, 30, 30, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Fenêtre en plein écran */
.space-window.fullscreen {
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
}

/* Badge de notification sur fenêtre */
.window-notification-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #FF3B30;
    color: white;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.4);
}

/* Loading state */
.window-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.window-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 122, 255, 0.2);
    border-top-color: #007AFF;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}