@font-face {
    font-family: 'FallingSky'; /* Nombre que usaremos en CSS */
    src: url('../fonts/FallingSky-JKwK.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

body { 
	font-family: 'FallingSky', sans-serif;
	overflow: hidden;
}

#taskbar { 
	position: absolute; 
	bottom: 0; 
	width: 100%; 
	height: 40px; 
	background: rgba(0,0,0,0.8); 
	display: flex; 
	align-items: center; 
	color: white; 
}

.window {
    background: #1e1e1e !important; /* Gris muy oscuro casi negro */
    border: 1px solid #333;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}
.header {
    background: #1e1e1e;
    border-bottom: 1px solid #333;
}
.win-btn:hover { background: #333; }
.win-close:hover { background: #c42b1c !important; color: white; }

.hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    position: fixed; /* Asegura que no afecte el flujo del documento */
}

#desktop-icons {
    position: relative;
    width: 100vw;
    height: 100vh;
    touch-action: none; /* Crucial para arrastre en móviles y web */
    user-select: none;
}

.desktop-icon {
    position: absolute; /* Esto es obligatorio */
    width: 80px;
    height: 90px;
    cursor: move;
    touch-action: none;
    user-select: none;
    /* Transición para que el imán se vea profesional */
    transition: left 0.2s ease, top 0.2s ease;
}
/* Animación de deslizamiento */
#login-screen {
    transition: transform 0.8s cubic-bezier(0.65, 0, 0.35, 1);
    z-index: 1000;
}
.login-up { transform: translateY(-100%); }

#start-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 0.25s ease-out, transform 0.25s ease-out, visibility 0.25s;
    pointer-events: auto;
    visibility: visible;
    
    /* Estilos */
    display: block !important;
    background: rgba(32, 32, 32, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: -20px;
}

#start-menu.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    visibility: hidden; 
}

/* Estilo Barra de Tareas */
.taskbar {
    background: rgba(32, 32, 32, 0.85);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}
/* Estilo base del botón en la taskbar */
.taskbar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    background: transparent;
    color: white;
    
    /* Propiedades de interacción */
    touch-action: none;
    user-select: none;
    will-change: transform;
    
    /* ANIMACIÓN: Estado inicial */
    opacity: 1;
    transform: scale(1);
    
    /* ANIMACIÓN: Transición suave */
    /* Quitamos el !important para permitir que la clase .icon-closing funcione */
    transition: background 0.2s, opacity 0.3s ease-out, transform 0.3s ease-out;
}

/* Hover suave */
.taskbar-item:hover { background: rgba(255, 255, 255, 0.1); }

/* Cuando la app está activa (añadiremos esta clase con JS) */
.taskbar-item.active {
    background: rgba(255, 255, 255, 0.15);
    position: relative;
}

/* La línea azul debajo */
.taskbar-item.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 25%;
    right: 25%;
    height: 3px;
    background: #3b82f6; /* Color azul */
    border-radius: 2px;
}

#desktop-icons { user-select: none; }

body {
    cursor: url('/assets/cursors/cursor.png'), auto;
}

/* Cursor para cuando pasas sobre botones o elementos clickeables */
button, a, .cursor-pointer {
    cursor: url('/assets/cursors/clicker.png'), pointer;
}

.alert-window {
    position: fixed;
    z-index: 9999;
    background: #f7f7f7;
    border: 1px solid #71a9da; /* Borde azul claro clásico */
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    width: 380px;
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    color: #000;
    padding: 1px; /* Para simular el borde de ventana */
}

.alert-header {
    background: linear-gradient(to bottom, #dbeaf9 0%, #a7cbf2 100%);
    padding: 4px 8px;
    color: #123e6f;
    font-size: 13px;
    font-weight: 600;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

/* El botón X clásico */
.alert-close-btn {
    background: #dbeaf9;
    border: 1px solid #71a9da;
    font-size: 10px;
    padding: 0px 6px;
    cursor: pointer;
}

.alert-content {
    padding: 20px 15px;
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.alert-icon { font-size: 35px; }

.alert-footer {
    padding: 10px;
    background: #f0f0f0;
    border-top: 1px solid #ccc;
    text-align: right;
}

.alert-footer button {
    background: #e1e1e1;
    border: 1px solid #767676;
    padding: 4px 20px;
    font-size: 13px;
}

/* Agrega este CSS */
.taskbar-preview {
    bottom: 100%; /* Posiciónalo justo encima del icono */
    margin-bottom: 10px; /* Un pequeño margen para que no tape el icono */
    /* Lo más importante: al ser hijo de iconDiv, 
       al mover el cursor del icono al preview, 
       técnicamente sigues dentro del mismo elemento padre */
}

.window {
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.window.active {
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.2); /* Resalta el borde al estar activa */
}

.window.minimized {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.window.dragging {
    transition: none !important;
}

@keyframes window-appear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.window.appearing {
    animation: window-appear 0.25s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes window-fade {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.window.appearing { animation: window-fade 0.2s ease-out forwards; }
.window.closing { animation: window-fade 0.2s ease-in reverse forwards; }

.window.maximized { 
    top: 0 !important; left: 0 !important; 
    width: 100vw !important; height: 100vh !important; 
    transform: translate(0, 0) !important; 
}

.app-indicator {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 3px;
    background: #3b82f6; /* Color azul estilo Windows 11 */
    border-radius: 2px;
    transition: width 0.2s ease;
}

/* Cuando está minimizada, el indicador es más pequeño */
.app-minimized-indicator {
    width: 3px;
    background: #6b7280; /* Color gris si está minimizada */
}

.icon-opening {
    animation: icon-enter-up 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Entrada: De abajo hacia arriba */
@keyframes icon-enter-up {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(0.5);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Salida: De arriba hacia abajo (Inversa exacta) */
@keyframes icon-exit-down {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(40px) scale(0.3); /* Coherente con el 0.5 de entrada */
        margin: 0;
        width: 0;
        height: 0;
    }
}

#desktop, #lock-screen, #login-screen {
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.click-animation {
	transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.click-animation:active {
	transform: scale(0.9); /* Se reduce al 90% */
}

/* 1. Anchura de la barra (El "carril") */
::-webkit-scrollbar {
    width: 10px;        /* Grosor vertical */
    height: 10px;       /* Grosor horizontal */
}

/* 2. El fondo de la barra (Track) */
::-webkit-scrollbar-track {
    background: #0a0a0a; 
}

/* 3. La "manija" que mueves (Thumb) */
::-webkit-scrollbar-thumb {
    background: #333333; /* Color gris oscuro */
    border-radius: 5px;  /* Bordes redondeados tipo Windows */
    border: 2px solid #0a0a0a; /* Crea el efecto de margen, igual que en Windows */
}

/* 4. Efecto al pasar el mouse (Hover) */
::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a; /* Un gris un poco más claro al tocarlo */
}

/* 5. Efecto al hacer clic (Active) */
::-webkit-scrollbar-thumb:active {
    background: #555555;
}

/* 1. Desactiva la selección en TODA la aplicación por defecto */
body, .wiki-container {
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

input, textarea, select, 
[contenteditable="true"], 
#wiki-text {
    -webkit-user-select: text;
    -ms-user-select: text;
    user-select: text;
    cursor: text;
}



.taskbar-item:active { cursor: grabbing; }



.window {
    position: absolute;
    display: flex;
    flex-direction: column;
    /* Esto es vital para que la ventana no se desborde */
    overflow: hidden; 
    /* Asegura que la ventana tenga un tamaño base si no se especifica */
    min-height: 100px; 
    min-width: 200px;
}

.header {
    flex-shrink: 0; /* La cabecera nunca cambia de tamaño */
}

.content {
    flex: 1; /* Ocupa el resto del espacio */
    overflow-y: auto; /* Scroll solo si es necesario */
    min-height: 0;   /* NECESARIO para que flex no fuerce el tamaño del contenido */
}

/* El elemento base */
.taskbar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    background: transparent;
    color: white;
    opacity: 1;
    transform: scale(1);
    /* Solo transiciones para estados que no son animación */
    transition: background 0.2s; 
    touch-action: none;
    user-select: none;
    will-change: transform;
}

/* Definición de la animación de salida */
@keyframes icon-exit-down {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) translateY(20px);
    }
}

.icon-closing {
    /* Aplicamos la animación */
    animation: icon-exit-down 0.25s cubic-bezier(0.4, 0, 1, 1) forwards;
    pointer-events: none;
    overflow: hidden;
}

.taskbar-item.stacked::before,
.taskbar-item.stacked::after {
    content: '';
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    width: 1.5rem; /* Tamaño del icono */
    height: 1.5rem;
    background: inherit;
    border-radius: 0.5rem;
    z-index: -1;
    border: 1px solid rgba(255,255,255,0.1);
}
.taskbar-item.stacked::after { left: 0.7rem; bottom: 0.7rem; }

#custom-menu.hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none; /* Evita que el usuario haga clic en un menú invisible */
}

#custom-menu {
    position: fixed; /* OBLIGATORIO: se fija al viewport, no al contenedor */
    z-index: 999999; /* OBLIGATORIO: para que esté por encima de todo */
    background: #1f2937; /* Asegúrate de que tenga color, sino será transparente */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: hidden;
}

/* Indicador base (Estado minimizado/inactivo) */
.indicator {
    width: 12px;      /* Barra pequeña */
    height: 4px;
    background-color: #6b7280; /* Gris */
    border-radius: 2px;
    transition: all 0.3s ease; /* Transición suave */
    position: absolute;
    bottom: 0;
}

#start-menu-content {
    flex: 1; /* Esto ocupa todo el espacio sobrante */
    overflow-y: auto; /* Permite scroll si hay muchos elementos */
}

#start-menu-footer {
    flex-shrink: 0 !important;
    position: absolute;
    bottom: 20px;
    left: 0;         /* Asegura que empiece desde la izquierda */
    width: 100%;     /* Fuerza el ancho total para que el justify-between funcione */
    padding: 20px 30px 0px 30px; /* Usa el mismo padding que el menú principal */
    box-sizing: border-box; /* Importante para que el padding no rompa el ancho */
    
    /* Mantenemos la alineación */
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Indicador activo (La "barra azul más anchita") */
.indicator.active-indicator {
    width: 24px;      /* Barra más ancha */
    height: 4px;
    background-color: #3b82f6; /* Azul brillante */
    border-radius: 2px;
}

.minimized-indicator {
    opacity: 0.5 !important;
}

.stacked::after {
    content: '';
    position: absolute;
    bottom: 0.2rem;
    right: 0.2rem;
    width: 100%;
    height: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    z-index: -1;
}

#desktop {
    position: relative; /* CRUCIAL */
    user-select: none;  /* Evita que se seleccione texto al arrastrar */
}

.desktop-icon.selected {
    background: rgba(59, 130, 246, 0.3); /* Color de selección */
    border: 1px solid rgba(59, 130, 246, 0.5);
    border-radius: 4px;
}

/* 1. Estado base: Qué pasa cuando el mouse pasa por encima (sin hacer clic) */
.desktop-icon-container {
    cursor: pointer !important;
    user-select: none;
    transition: cursor 0.1s ease; /* Pequeña suavidad al cambiar */
}

/* 2. Estado de arrastre: Cuando tu JS añade la clase .is-dragging */
.desktop-icon-container.is-dragging {
    cursor: move !important;
}

/* 3. Estado de clic activo: Cuando el usuario tiene el botón presionado */
/* Esto sobreescribe el 'pointer' solo en el momento del clic */
.desktop-icon-container:active {
    cursor: move !important;
}

.fade-transition {
    transition: opacity 0.5s ease-in-out;
}

#login-form, #error-container {
    transition: opacity 0.5s ease-in-out;
}

.refreshing {
    animation: blink 0.05s ease-in-out;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 1; }
}

/* CREACION DE FOLDER */
.folder-temp input {
    border-radius: 2px;
    box-shadow: 0 0 5px rgba(0, 120, 215, 0.5);
    z-index: 1005;
}

.folder-temp {
    animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* SELECTED STATUS */
.desktop-icon-container span, 
.desktop-icon-container p {
    display: block !important;
    width: 100%;
    text-align: center;    
    white-space: normal !important; 
    word-spacing: -1px;
    line-height: 1.6;

    word-break: normal;
    overflow-wrap: break-word;

    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.desktop-icon-container.selected span, 
.desktop-icon-container.selected p {
    -webkit-line-clamp: unset !important;
    display: block !important;
    overflow: visible !important;
}

.desktop-icon-container.selected {
    background-color: rgba(255, 255, 255, 0.2) !important;
    position: relative; /* Necesario para el hijo absoluto */
    border-radius: 5px !important;
    height: auto !important;
    min-height: 90px;
    z-index: 999;
}

/* Creamos el borde punteado redondeado por separado */
.desktop-icon-container.selected::before {
    content: "";
    position: absolute;
    top: 1px;
    left: 1px;
    right: 1px;
    bottom: 1px;
    border: 1px dotted #ffffff;
    border-radius: 3px; /* Un poco menos que el padre para que encaje perfecto */
    pointer-events: none; /* Para que no interfiera con los clics */
}

.hidden {
    display: none !important;
}

/* AVANZADA */
@keyframes bounce-custom {
    0%, 100% { 
        transform: translateY(0); 
        animation-timing-function: ease-out; /* Sube suave */
    }
    50% { 
        transform: translateY(-5px); /* Salto un poco más pronunciado */
        animation-timing-function: ease-in; /* Cae rápido */
    }
}

.animate-arrow-bounce {
    animation: bounce-custom 1s infinite ease-in-out;
}